Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am having strange problem. Can't find any solution.

Using Ubuntu 12.04. My hard disk drive assigned as sda. If I plug-in any USB drive, it automatically assigned as sdb. That's fine.

But after reboot, USB drives assigned as sda and hard disk drive shows as sdb. So my fstab mount point showing error on start.

I would like to make any USB drive, goes after hard drive - as usually been in Windows.

Please, anyone help me. I am struggling at this point.

Thanking you in advance.

Raihan

share|improve this question
add comment

1 Answer

I am going to suggest you do two things,

  1. Use UUIDs instead of /dev/sd* in your fstab so that it is not messed up.
  2. Get you started with udev so you can make your thumb drives appear as /dev/whatever

Section 1.

Ensure that all the devices listed in your fstab are plugged into the system. Wait a few seconds and then type

ls -l /dev/disk/by-uuid

This will give you something that looks like the following:total 0

lrwxrwxrwx 1 root root 10 Sep 24 20:19 4e36d61c-e6f4-4a1a-b760-45ee5a76e141 -> ../../sdc2
lrwxrwxrwx 1 root root 10 Sep 24 20:19 52a04f5d-2576-48d1-8340-544cc24e0fcd -> ../../sdc3
lrwxrwxrwx 1 root root 10 Sep 24 20:19 55a1d85d-e5f5-416e-adf7-3aed3e6309f1 -> ../../sdc1
lrwxrwxrwx 1 root root 10 Sep 24 20:19 5c8c3b19-5550-4411-8fc3-692aa94bb4af -> ../../dm-1
lrwxrwxrwx 1 root root 10 Sep 24 20:19 8bfea793-5cb2-480c-a4e3-2b3c331463bb -> ../../sdb3
lrwxrwxrwx 1 root root 10 Sep 24 20:19 a369bc5e-3bf0-454b-b04d-2936e343e959 -> ../../dm-0
lrwxrwxrwx 1 root root 10 Sep 24 20:19 e57e2838-2c56-43c3-b4b8-de0743c67181 -> ../../sdb2
lrwxrwxrwx 1 root root 10 Sep 24 20:19 f7772f0f-19d7-4ced-b0a0-b543e4bd54fe -> ../../dm-2

Now look up what you have in your fstab. Everywhere you have something like /dev/sdc1 I want you to replace it with something like UUID=55a1d85d-e5f5-416e-adf7-3aed3e6309f1. What this will do is tell mount to use the UUID to identify a device instead of it's location under /dev. These UUID are unique and last the lifetime of the filesystem.

Section 2.

udev is the service that is responsible for placing block devices (and other devices) under /dev in Ubuntu. You can actually write your own rules for udev that instruct it to make symlinks under /dev in a consistent way. The way udev works is that everytime a device is attached it scans a long list of rules and takes the actions specified by any that match. The matching is done by inspecting a bunch of parameters of the device such as, UUID, port it is plugged into, PCI address, etc. So you can identify your thumb drive by the filesystem's UUID and have a rule to map that to /dev/myThumbDrive and use /dev/myThumbDrive anywhere you would normally use /dev/sda1 (for example).

You can find a list of attributes to identify your drive with by typing

udevadm info -n /dev/sde --attribute-walk

looking at device '/devices/pci0000:00/0000:00:15.2/0000:05:00.0/usb8/8-1/8-1:1.0/host6/target6:0:0/6:0:0:0/block/sde/sde1':
  KERNEL=="sde1"
  SUBSYSTEM=="block"
  DRIVER==""
  ATTR{partition}=="1"
  ATTR{start}=="1"
  ATTR{size}=="24242084"
  ATTR{ro}=="0"
  ...

looking at parent device '/devices/pci0000:00/0000:00:15.2/0000:05:00.0/usb8/8-1/8-1:1.0/host6/target6:0:0/6:0:0:0/block/sde':
 KERNELS=="sde"
 SUBSYSTEMS=="block"
 DRIVERS==""
 ATTRS{range}=="16"
 ATTRS{ext_range}=="256"
 ATTRS{removable}=="1"
 ATTRS{ro}=="0"
 ATTRS{size}=="31250432"
 ATTRS{alignment_offset}=="0"
 ATTRS{discard_alignment}=="0"
 ATTRS{capability}=="51"
 ...

looking at parent device '/devices/pci0000:00/0000:00:15.2/0000:05:00.0/usb8/8-1/8-1:1.0/host6/target6:0:0/6:0:0:0':
 KERNELS=="6:0:0:0"
 SUBSYSTEMS=="scsi"
 DRIVERS=="sd"
 ATTRS{device_blocked}=="0"
 ATTRS{type}=="0"
 ATTRS{scsi_level}=="3"
 ATTRS{vendor}=="SanDisk "
 ATTRS{model}=="Cruzer          "
 ATTRS{rev}=="1.00"
 ...

looking at parent device '/devices/pci0000:00/0000:00:15.2/0000:05:00.0/usb8/8-1/8-1:1.0/host6/target6:0:0':
 ....

looking at parent device '/devices/pci0000:00/0000:00:15.2/0000:05:00.0/usb8/8-1/8-1:1.0/host6':
 ....

looking at parent device '/devices/pci0000:00/0000:00:15.2/0000:05:00.0/usb8/8-1/8-1:1.0':
 ...
 SUBSYSTEMS=="usb"
 DRIVERS=="usb-storage"

looking at parent device '/devices/pci0000:00/0000:00:15.2/0000:05:00.0/usb8/8-1':
 ....
 ATTRS{idVendor}=="0781"
 ATTRS{idProduct}=="5530"
 ....
 ATTRS{manufacturer}=="SanDisk"
 ATTRS{product}=="Cruzer"
 ATTRS{serial}=="20043513610A15E24E49" 

looking at parent device '/devices/pci0000:00/0000:00:15.2/0000:05:00.0/usb8':
 ....

looking at parent device '/devices/pci0000:00/0000:00:15.2/0000:05:00.0':
 ....

looking at parent device '/devices/pci0000:00/0000:00:15.2':
 ....

looking at parent device '/devices/pci0000:00':
 ....

And then you can create a rule that looks something like this:

KERNEL=="sd*", SUBSYSTEMS=="scsi", ATTRS{model}=="USB 2.0 Storage Device", SYMLINK+="myThumbDrive%n"

So that /dev/myThumbDrive1 can be used instead of /dev/sd[a-z]1

Alternate Method

This is too much typing of UUID's for my taste. Maybe it will be easier for you.

http://scnr.net/blog/index.php/archives/132

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.