From c710c8429d0c1dde5324d7fdbe2c5e1485bd8450 Mon Sep 17 00:00:00 2001 From: Max Hirschhorn Date: Mon, 3 Jun 2019 18:54:59 -0400 Subject: SERVER-41393 Identify devices by their UUID in /etc/fstab. This ensures they are automatically mounted following a machine reboot. (cherry picked from commit 79091ef290d1c0d73f663787c7982cc4fef2959e) --- buildscripts/mount_drives.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/buildscripts/mount_drives.sh b/buildscripts/mount_drives.sh index a861bac6352..0070d9b0abc 100755 --- a/buildscripts/mount_drives.sh +++ b/buildscripts/mount_drives.sh @@ -147,15 +147,24 @@ function mount_drive { /sbin/mdadm --detail --scan > /etc/mdadm.conf /sbin/blockdev --setra 32 $device_name else - device_name=$devices + device_name="/dev/$device_names" fi # Mount the $root_dir drive(s) /sbin/mkfs.$fs_type $mount_options -f $device_name - echo "$device_name /$root_dir auto noatime 0 0" | tee -a /etc/fstab + # We add an entry for the device to /etc/fstab so it is automatically mounted following a + # machine reboot. The device is not guaranteed to be assigned the same name across restarts so + # we use its UUID in order to identify it. + # + # We also specify type=$fs_type in the /etc/fstab entry because specifying type=auto on + # Amazon Linux AMI 2018.03 leads to the drive not being mounted automatically following a + # machine reboot. + device_uuid=$(blkid -o value -s UUID "$device_name") + echo "Adding entry to /etc/fstab for device '$device_name' with UUID '$device_uuid'" + echo "UUID=$device_uuid /$root_dir $fs_type noatime 0 0" | tee -a /etc/fstab mkdir /$root_dir || true chmod 777 /$root_dir - mount -t $fs_type $device_name /$root_dir + mount -t $fs_type "UUID=$device_uuid" /$root_dir for sub_dir in $sub_dirs do mkdir -p /$root_dir/$sub_dir -- cgit v1.2.1