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.
- Label the partitions then mount them by label
- 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' or
UUID=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)