Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have many disks and volumes in my system. Some of disks IDE, some SATA.

Volumes on SATA disks cause me problems - I have them listed in etc/fstab, but on every boot, they have different name:

  • /dev/sdd* becomes /dev/sdb*
  • /dev/sde* becomes /dev/sdc*

etc. on every boot.

1) Why is this happening?
2) How can I prevent it?
3) If I can't, is there a workaround?

share|improve this question

2 Answers 2

It usually happens because devices get detected in a different order - especially when multiple different device technologies share the same name, such as SATA, SCSI and USB disks. They all share the /dev/sd* names, and they will change according to what you have plugged in at the time.

There are a number of ways you can work around it.

  1. Label the partitions then mount them by label
  2. Mount them by UUID

From man fstab:

Instead of giving the device explicitly, one may indicate the (ext2 or xfs) filesystem that is to be mounted by its UUID or volume label (cf. e2label(8) or xfs_admin(8)), writing LABEL= or UUID=, e.g., LABEL=Boot' orUUID=3e6be9de-8139-11d1-9106-a43f08d823a6'. This will make the system more robust: adding or removing a SCSI disk changes the disk device name but not the filesystem volume label.

Labeling a disk can be done with (for example)

# tune2fs -L MyDiskLabel /dev/sde2

then use LABEL=MyDisklabel as the device name in /etc/fstab

Mounting can be done by using UUID= in /etc/fstab in place of the device name.

The UUID can be obtained by blkid (in Ubuntu at least - not sure about other distros)

share|improve this answer
    
blkid is part of util-linux, it should work on all Linux distributions. –  grawity Apr 25 '11 at 15:15
    
On machines running udev, another method of accessing disks by label or UUID is through /dev/disk/by-label/<label> and /dev/disk/by-uuid/<UUID>. –  grawity Apr 25 '11 at 15:17

Not sure if posting a link to my blog is bad habit in here (I'm quite new around here) so my apologies if so.

Last week I wrote a post about labeling with uuid several old reiserfs partitions so it may be of interest for the former poster to take a look at it.

http://hmontoliu.blogspot.com/2011/04/set-uuid-on-reiserfs-partitions-fun.html

share|improve this answer
    
As long as it's a) not commercial, and b) you say it's yours, that's fine. In fact, if you like blogging, why not contribute to the Super User blog? ;) –  Majenko Apr 25 '11 at 15:39
    
I'll take it in to account :-) –  hmontoliu Apr 25 '11 at 18:05

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.