Skip to content

Instantly share code, notes, and snippets.

@tamoot
Last active Apr 13, 2020
Embed
What would you like to do?
format_and_mount.sh
#!/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