From 34a38c668e8baeee21288b14fae6cda0428e2c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 18 Mar 2015 00:33:30 +0100 Subject: [PATCH] Create filesystem if the private.img is empty --- vm-init.d/qubes-core | 8 ++++++++ vm-systemd/mount-home.sh | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/vm-init.d/qubes-core b/vm-init.d/qubes-core index a2fa325..1a01829 100755 --- a/vm-init.d/qubes-core +++ b/vm-init.d/qubes-core @@ -52,6 +52,14 @@ start() chmod 0775 /var/run/qubes if [ -e /dev/xvdb ] ; then + # check if private.img (xvdb) is empty - all zeros + private_size_512=`blockdev --getsz /dev/xvdb` + if dd if=/dev/zero bs=512 count=$private_size_512 | diff /dev/xvdb - >/dev/null; then + # the device is empty, create filesystem + echo "--> Virgin boot of the VM: creating filesystem on private.img" + mkfs.ext4 -m 0 -q /dev/xvdb || exit 1 + fi + resize2fs /dev/xvdb 2> /dev/null || echo "'resize2fs /dev/xvdb' failed" mount /rw diff --git a/vm-systemd/mount-home.sh b/vm-systemd/mount-home.sh index 3307551..a8e298b 100644 --- a/vm-systemd/mount-home.sh +++ b/vm-systemd/mount-home.sh @@ -1,5 +1,13 @@ #!/bin/sh +# check if private.img (xvdb) is empty - all zeros +private_size_512=`blockdev --getsz /dev/xvdb` +if dd if=/dev/zero bs=512 count=$private_size_512 | diff /dev/xvdb - >/dev/null; then + # the device is empty, create filesystem + echo "--> Virgin boot of the VM: creating filesystem on private.img" + mkfs.ext4 -m 0 -q /dev/xvdb || exit 1 +fi + resize2fs /dev/xvdb 2> /dev/null || echo "'resize2fs /dev/xvdb' failed" tune2fs -m 0 /dev/xvdb mount /rw