summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2019-06-03 18:54:59 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2019-06-03 18:54:59 -0400
commitc710c8429d0c1dde5324d7fdbe2c5e1485bd8450 (patch)
treeeed407603084eda9eb927ff1d3f7a83ad0353c72
parent6ac1954e5b735d86d0624e408848365883efe1d7 (diff)
downloadmongo-c710c8429d0c1dde5324d7fdbe2c5e1485bd8450.tar.gz
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)
-rwxr-xr-xbuildscripts/mount_drives.sh15
1 files 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