2019-07-11 15:23:32 -07:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -x
|
|
|
|
|
|
|
|
mount_point=/mnt/extra-disk
|
|
|
|
disk=sdb
|
|
|
|
if ! lsblk | grep -q ${disk} ; then
|
|
|
|
echo "${disk} does not exist"
|
|
|
|
else
|
2019-10-25 10:11:32 -07:00
|
|
|
sudo mount /dev/"$disk" "$mount_point" || true
|
2019-07-11 15:23:32 -07:00
|
|
|
if mount | grep -q ${disk} ; then
|
2019-10-24 20:14:26 -07:00
|
|
|
echo "${disk} is mounted"
|
2019-07-11 15:23:32 -07:00
|
|
|
else
|
|
|
|
sudo mkfs.ext4 -F /dev/"$disk"
|
|
|
|
sudo mkdir -p "$mount_point"
|
|
|
|
sudo mount /dev/"$disk" "$mount_point"
|
|
|
|
sudo chmod a+w "$mount_point"
|
|
|
|
if ! mount | grep -q ${mount_point} ; then
|
|
|
|
echo "${disk} failed to mount!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|