From 921aaa895e18fcbe4971fb217ea2f24cff8581de Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Wed, 4 May 2016 14:56:17 +0100 Subject: [PATCH] reread partition table and be more careful if no partitions Signed-off-by: Justin Cormack --- alpine/packages/automount/etc/init.d/automount | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/alpine/packages/automount/etc/init.d/automount b/alpine/packages/automount/etc/init.d/automount index 04ce2c44e..17b812d7f 100755 --- a/alpine/packages/automount/etc/init.d/automount +++ b/alpine/packages/automount/etc/init.d/automount @@ -19,11 +19,18 @@ start() if fdisk -l ${DRIVE} | grep -q "doesn't contain a valid partition table" then ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE} + blockdev --rereadpt ${DRIVE} 2> /dev/null 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} - resize2fs ${DATA} + if [ -z "$DATA" ] + then + ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE} + blockdev --rereadpt ${DRIVE} 2> /dev/null + else + mount ${DATA} /var && swapon ${SWAP} || ( ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE}; blockdev --rereadpt ${DRIVE} 2> /dev/null ) + resize2fs ${DATA} 2> /dev/null + fi # boot2docker compat, has /var and /tmp on partition [ -d /var/var/lib/boot2docker/ ] && mount --bind /var/var /var fi