5

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?

2 Answers 2

7

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)

2
  • blkid is part of util-linux, it should work on all Linux distributions. Apr 25, 2011 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>. Apr 25, 2011 at 15:17
1

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

3
  • 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, 2011 at 15:39
  • I'll take it in to account :-)
    – hmontoliu
    Apr 25, 2011 at 18:05
  • actually, if you decide to contribute, you can include the relevant description/code here, in case one day you decide to change your blog address and the link becomes dead. Aug 7, 2018 at 13:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .