Mounts are, sometimes, swapped at boot /usr2 becomes /tmp and /tmp becomes /usr2. This causes disaster because /tmp cleanup cron entries start acting on the /usr2 mount.

/etc/fstab contents

/dev/mapper/rhel-root   /                       xfs     defaults        0 0
UUID=****************** /boot                   ext4    defaults        1 2
/dev/mapper/rhel-swap   swap                    swap    defaults        0 0
/dev/sdb1       /data   ext4    data=ordered,relatime   0       0
/dev/sdd1       /usr2   ext4    defaults        0       0
/dev/sdc1       /tmp    ext4    defaults        0       0

How can I prevent the system from booting or from mounting the drives if this occurs? I'm trying to add some kind of safeguard in case the root issue occurs.

  • 8
    Use UUID of the disk in fstab.
    – squareborg
    Feb 15 '17 at 10:17
  • If the person who installed the system had set these partitions up at install time, the RHEL installer would have used the UUIDs automatically and you wouldn't have had this issue. Feb 15 '17 at 22:15

You have two options:

  1. Since you're using an EXT filesystem you can label the partition and use the LABEL option in your fstab.
    e2label /dev/sdb1 /data and use the label /data rather than the partition to get consistent mounts: LABEL=/data /data ext4 data=ordered,relatime 0 0

  2. Your current /etc/fstab already includes an example of it, but you also can mount partitions, volumes and disks by their unique UUID. Use blkid to get the UUID's and include them in /etc/fstab i.e. something like:
    UUID=c2ba7d33-1a1f /data ext4 data=ordered,relatime 0 0

The second option is more powerful as it works for a much larger range of file-systems and devices where e2label only works for EXT filesytems.

You can display blkid UUID in slightly more userfriendly format with lsblk --fs

# lsblk --fs
NAME                    FSTYPE      LABEL UUID                                   MOUNTPOINT
├─vda1                  ext3              b82742bc-32d3-47bb-b542-1cfa25b92dd1   /boot
├─vda2                  swap              c2ba7d33-1a1f-4c73-b7d3-31eae965c136   [SWAP]
└─vda3                  LVM2_member       H6C5Kf-jEiA-VrxJ-XnNH-T9Zd-lUDE-NbC72E
  ├─myvg-rootvol (dm-0) ext4              b948ff9c-3a66-45e8-8099-cc529a22c547   /
  └─myvg-crypto (dm-1)  crypto_LUKS       f4e7400c-aa15-44fc-b02e-1ce6ca6c04db
    └─crypto (dm-2)     ext4              3dfa7a40-80ef-4ae6-84c5-e00f55a76b3d   /crypto  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.