Last active
April 13, 2020 14:03
-
-
Save tamoot/d5bf1bb6d8dadd79a4b077622396c06e to your computer and use it in GitHub Desktop.
format_and_mount.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eux | |
_STDOUT_LOG=`hostname`_format_and_mount_${1}_`date +%s`_$$.log | |
exec > >(tee -a ${_STDOUT_LOG}) | |
exec 2>&1 | |
: ================================- | |
date | |
hostnamectl | |
: ================================- | |
dmesg | tail -n 15 | |
: ================================- | |
fdisk -l /dev/vdb | |
: ================================- | |
parted /dev/vdb -s mklabel msdos mkpart primary ext4 2048 100% | |
: ================================- | |
fdisk -l /dev/vdb | |
: ================================- | |
cat /proc/partitions | |
: ================================- | |
mkfs -t ext4 /dev/vdb1 | |
: ================================- | |
blkid | |
: ================================- | |
_VDB_ID=`blkid | grep /dev/vdb1 | sed -e "s/^.*UUID=\"\(.*\)\" TYPE.*$/\1/g"` | |
: ================================- | |
mkdir -p /${1} | |
: ================================- | |
cp -ap /etc/fstab /etc/_fstab.bak.`date +%s` | |
ls -l /etc/*fstab* | |
: ================================- | |
cat <<EOF >> /etc/fstab | |
UUID=${_VDB_ID} /${1} ext4 defaults,nodelalloc,data_err=abort 1 2 | |
EOF | |
: ================================- | |
diff -u /etc/_fstab.bak* /etc/fstab | |
: ================================- | |
mount -a | |
: ================================- | |
mount | grep vdb | |
: ================================- | |
df | |
: ================================- | |
ls -ld /${1} | |
: ================================- | |
ls -l /${1} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment