0

I am using debian linux , and in this operating system , I am using 2 disk

1 -> Primary disk (/dev/sda1)

2 -> Secondary disk (/dev/sdb1)

First disk is mounted on "/" and the 2nd disk is mounted on /mnt/disk , and the entries of both the disk is defined in fstab file present in /etc.

Every time when I reboot my linux machine , mount points changes automatically , means sometime /dev/sdb1 is attached with / and /dev/sda1 is attached with /mnt/disk and vice-versa.

I have tried so many solutions but failed to find the exact root cause for this issue

1 Answer 1

2

/dev/sdX are not fixed. They will change between reboots and you can't do much about it. This is caused by asynchronous initialization of devices and there is a race condition; whichever happens to be faster this time claims sda, other one is sdb.

So you should not use names like /dev/sdX when building fstab.

Use LABEL, UUID, or /dev/disk/... symlinks, which are stable, e.g. they identify the device or the filesystem and won't change even if sda and sdb switch roles. Or you can use /dev/mapper/VG-LV links if you use LVM, and /dev/md/X if you use MD RAID; those use UUIDs under the hood and also are stable.

For example:

UUID=cac830eb-9fd6-4161-989d-71be3a055978 /boot ext4 defaults 0 2
/dev/mapper/system-debian / ext4 errors=remount-ro 0 1

If the filesystem has this UUID it will be mounted as /boot, period. I don't care if it happens to be sda1, sdb1 or whatever. The root file system is on LVM and will always appear at /dev/mapper/system-debian because it's a LV debian on the VG system.

To know your UUIDs, LABELs and so on, run blkid (as root or with sudo).

1
  • Thanks for your immediate reply. Solution works..Really appreciated Oct 12, 2023 at 10:39

You must log in to answer this question.

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