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
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=,
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)