Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions config/samples/raid-disks/eks-daemonset-raid-disks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,21 @@ spec:

mountpoint=/mnt/disks/raid0
mkdir -p "${mountpoint}"
echo "Mounting '${device}' at '${mountpoint}'"
mount -o discard,defaults "${device}" "${mountpoint}"
chmod a+w "${mountpoint}"

echo "Checking if device '${device}' is already mounted at '${mountpoint}'"
device_real=$(readlink -f "$device")
if mountpoint -q "$mountpoint"; then
mounted_device=$(findmnt -nro SOURCE --target "$mountpoint" | xargs readlink -f)

if [ "$mounted_device" != "$device_real" ]; then
echo "error: '${mountpoint}' is already mounted to '${mounted_device}', unable to mount '${device}'."
exit 1
else
echo "'${device}' is already mounted to '${mountpoint}'. Skipping mount"
fi
else
echo "Mounting '${device}' at '${mountpoint}'"
mount -o discard,defaults "${device}" "${mountpoint}"
chmod a+w "${mountpoint}"
fi
rm -rf /mnt/disks/raid0/*
20 changes: 17 additions & 3 deletions config/samples/raid-disks/gke-daemonset-raid-disks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,21 @@ spec:

mountpoint=/mnt/disks/raid0
mkdir -p "${mountpoint}"
echo "Mounting '${device}' at '${mountpoint}'"
mount -o discard,defaults "${device}" "${mountpoint}"
chmod a+w "${mountpoint}"

echo "Checking if device '${device}' is already mounted at '${mountpoint}'"
device_real=$(readlink -f "$device")
if mountpoint -q "$mountpoint"; then
mounted_device=$(findmnt -nro SOURCE --target "$mountpoint" | xargs readlink -f)

if [ "$mounted_device" != "$device_real" ]; then
echo "error: '${mountpoint}' is already mounted to '${mounted_device}', unable to mount '${device}'."
exit 1
else
echo "'${device}' is already mounted to '${mountpoint}'. Skipping mount"
fi
else
echo "Mounting '${device}' at '${mountpoint}'"
mount -o discard,defaults "${device}" "${mountpoint}"
chmod a+w "${mountpoint}"
end
rm -rf /mnt/disks/raid0/*