@ -53,8 +53,8 @@ if [ `cat /sys/class/block/$ROOT_DEV/ro` = 1 ] ; then
die "volatile.img smaller than 1GB, cannot continue"
die "volatile.img smaller than 1GB, cannot continue"
fi
fi
/sbin/sfdisk -q --unit S /dev/xvdc >/dev/null <<EOF
/sbin/sfdisk -q --unit S /dev/xvdc >/dev/null <<EOF
1,$SWAP_SIZE ,S
xvdc 1: type = 82 ,start= 2048,size= $SWAP_SIZE
,,L
xvdc2: type = 83
EOF
EOF
if [ $? -ne 0 ] ; then
if [ $? -ne 0 ] ; then
echo "Qubes: failed to setup partitions on volatile device"
echo "Qubes: failed to setup partitions on volatile device"
@ -72,7 +72,8 @@ else
echo "Qubes: Doing R/W setup for TemplateVM..."
echo "Qubes: Doing R/W setup for TemplateVM..."
while ! [ -e /dev/xvdc ] ; do sleep 0.1; done
while ! [ -e /dev/xvdc ] ; do sleep 0.1; done
/sbin/sfdisk -q --unit S /dev/xvdc >/dev/null <<EOF
/sbin/sfdisk -q --unit S /dev/xvdc >/dev/null <<EOF
1,$SWAP_SIZE ,S
xvdc1: type = 82,start= 2048,size= $SWAP_SIZE
xvdc3: type = 83
EOF
EOF
if [ $? -ne 0 ] ; then
if [ $? -ne 0 ] ; then
die "Qubes: failed to setup partitions on volatile device"
die "Qubes: failed to setup partitions on volatile device"
@ -86,7 +87,7 @@ fi
/sbin/modprobe ext4
/sbin/modprobe ext4
mkdir -p /sysroot
mkdir -p /sysroot
mount /dev/mapper/dmroot /sysroot -o ro
mount /dev/mapper/dmroot /sysroot -o rw
NEWROOT = /sysroot
NEWROOT = /sysroot
kver = "`uname -r`"
kver = "`uname -r`"
@ -99,18 +100,14 @@ if ! [ -d "$NEWROOT/lib/modules/$kver/kernel" ]; then
if /sbin/modprobe overlay; then
if /sbin/modprobe overlay; then
# if overlayfs is supported, use that to provide fully writable /lib/modules
# if overlayfs is supported, use that to provide fully writable /lib/modules
if ! [ -d " $NEWROOT /lib/.modules_work " ] ; then
if ! [ -d " $NEWROOT /lib/.modules_work " ] ; then
mount " $NEWROOT " -o remount,rw
mkdir -p " $NEWROOT /lib/.modules_work "
mkdir -p " $NEWROOT /lib/.modules_work "
mount " $NEWROOT " -o remount,ro
fi
fi
mount -t overlay none $NEWROOT /lib/modules -o lowerdir = /tmp/modules,upperdir= $NEWROOT /lib/modules,workdir= $NEWROOT /lib/.modules_work
mount -t overlay none $NEWROOT /lib/modules -o lowerdir = /tmp/modules,upperdir= $NEWROOT /lib/modules,workdir= $NEWROOT /lib/.modules_work
else
else
# otherwise mount only `uname -r` subdirectory, to leave the rest of
# otherwise mount only `uname -r` subdirectory, to leave the rest of
# /lib/modules writable
# /lib/modules writable
if ! [ -d " $NEWROOT /lib/modules/ $kver " ] ; then
if ! [ -d " $NEWROOT /lib/modules/ $kver " ] ; then
mount " $NEWROOT " -o remount,rw
mkdir -p " $NEWROOT /lib/modules/ $kver "
mkdir -p " $NEWROOT /lib/modules/ $kver "
mount " $NEWROOT " -o remount,ro
fi
fi
mount --bind " /tmp/modules/ $kver " " $NEWROOT /lib/modules/ $kver "
mount --bind " /tmp/modules/ $kver " " $NEWROOT /lib/modules/ $kver "
fi
fi
@ -119,5 +116,6 @@ if ! [ -d "$NEWROOT/lib/modules/$kver/kernel" ]; then
fi
fi
umount /dev /sys /proc
umount /dev /sys /proc
mount " $NEWROOT " -o remount,ro
exec /sbin/switch_root $NEWROOT /sbin/init
exec /sbin/switch_root $NEWROOT /sbin/init