0

I have a problem with boot process where my system partition starting as /dev/sda sometimes as /dev/sdb and it's causing for me a problem with disk which I'm connecting

On the controller I have connected 5 drives and 1 esata port for dock. System is installed on the ssd drive Raid md0 is created from 4 drives.

For all other devices I`ve created static entry in /etc/fstab

#### Automount for any other devices - experimental

/dev/sdf1 /media/user/HDD1 auto rw,user,noauto   0 0
/dev/sdg1 /media/user/HDD2 auto rw,user,noauto   0 0
/dev/sdh1 /media/user/HDD3 auto rw,user,noauto   0 0
/dev/sdi1 /media/user/HDD4 auto rw,user,noauto   0 0

Normally esata should appear on /dev/sdf but if the drive with system will start with /dev/sdb then my other raid device moving for new structure /dev/sdc /dev/sdd /dev/sde and /dev/sdf which will cause for me a problem.

all other entries are assigned as

/dev/disk/by-uuid/12345678-1234-1234-1234-123456789012 / ext4 ....

What do I have to do, to fix it, unfortunatly there is no possible to use mount by uuid, becouse every time it`s different disk which I want to plugin.

2 Answers 2

3

Assign sensible labels to the partitions/filesystems and use those instead:

/dev/disk/by-label/my-smartly-labeled-partition...

Then UUID and bus ID become somewhat irrelevant.

7
  • 1
    Please give me more explanation
    – itnoob
    Apr 12, 2017 at 13:21
  • If you use /dev/disk/by-label, then you can switch out the drive to another drive with a different UUID, without breaking the mountpoints in fstab. It will help with replacing disks in the RAID, as well as letting you use a different system drive without having to reconfigure fstab.
    – Mio Rin
    Apr 12, 2017 at 13:26
  • Still its not clear for me, sorry any example?
    – itnoob
    Apr 12, 2017 at 13:38
  • Label the root partition of the system disk system-root then put /dev/disk/by-label/system-root / ext4 defaults 1 1 in /etc/fstab
    – Mio Rin
    Apr 12, 2017 at 13:43
  • 3
    Check also /dev/disk/by-path.
    – VPfB
    Apr 12, 2017 at 16:53
2

Avoid using names like /dev/sda1 as they can change. Use the identification of a partition or filesystem.

You can use UUIDs to reliably designate the same filesystem or swap partition. Use the syntax UUID=12345678-1234-… instead of /dev/sda1 in /etc/fstab. You can also use the file name /dev/disk/by-partuuid/12345678-1234-….

You can also put a label on most filesystems and on a swap partition. For an ext2/ext3/ext4 filesystem, use tune2fs -L to set the label. For an msdos/vfat filesystem, use dosfslabel. For a btrfs filesystem, use btrfs filesystem label. For a swap partition, use mkswap -L. You can specify a label in /etc/fstab with the syntax LABEL=mylabel. You can also use the file name /dev/disk/by-label/mylabel.

If the disks are only meant to be accessed under Linux, then you should use Linux partitions instead of PC partitions. PC partitions don't have labels by themselves (it's the filesystem on the partition that might have a label), but Linux partitions do. Linux's partition scheme is called LVM and offers many advantages beyond a reliable naming scheme for partitions, including ease of resizing partitions, splitting between disks, snapshotting, etc. With LVM, you can designate a partition as /dev/mapper/mygroup-myvolume where mygroup and myvolume are two names you get to pick. There's no way to convert an existing partition to LVM; you should pick LVM when you install your system (any modern Linux distribution should support it).

1
  • Gilles i really apricate your help, but as i mentioned, all other entries in my /etc/fstab using mentioned method by you. Only in the situation of the automount entry i'm using /dev/sda1 /dev/sde1 etc becouse i cannot definied the names or uuid, becouse on this filesystem i`m using many different external disk which cannot be described. From the mentioned comments i understood that after when i will use label for system disk problem should disappear, correct ?
    – itnoob
    Apr 13, 2017 at 10:42

You must log in to answer this question.

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