Files
linuxkit/alpine/etc/init.d/automount
Justin Cormack 4cc739f07f use first partition if several
Signed-off-by: Justin Cormack <justin.cormack@unikernel.com>
2015-12-16 14:49:58 +00:00

25 lines
572 B
Plaintext
Executable File

#!/sbin/openrc-run
depend()
{
after dev
before docker
}
start()
{
ebegin "Configuring host block device"
DEV="$(ls /dev/[xv]da | head -1 | sed s@/dev/@@)"
DRIVE="/dev/${DEV}"
if fdisk -l ${DRIVE} | grep -q "doesn't contain a valid partition table"
then
ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE}
else
SWAP=$(fdisk -l ${DRIVE} | grep 'Linux swap' | head -1 | awk '{print $1}')
DATA=$(fdisk -l ${DRIVE} | grep 'Linux$' | head -1 | awk '{print $1}')
mount ${DATA} /var && swapon ${SWAP} || ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE}
fi
}