Andy 4 years ago
parent 3a04f2adaf
commit 587c7bae95
Signed by: arno
GPG Key ID: 9076D5E6B31AE99C

@ -18,7 +18,7 @@ mkdir -p mnt
MNTDIR=$(pwd)/mnt
LOOP=$(/sbin/losetup -f --show -o $OFFSET $ROOTIMG)
LOOP=$(/sbin/losetup -b 4096 -f --show -o $OFFSET $ROOTIMG)
if [ x$LOOP = x ] ; then
echo "Cannot setup loopback device for the $ROOTIMG file -- perhaps a permissions problem?"

@ -50,10 +50,13 @@ echo "-> Preparing instalation of ${DIST} template..."
if [ -f "${IMG}" ]; then
echo "-> Image file already exists, assuming *update*..."
if [ "0$TEMPLATE_ROOT_WITH_PARTITIONS" -eq 1 ]; then
IMG_LOOP=$(/sbin/losetup -P -f --show "$IMG")
IMG_LOOP=$(/sbin/losetup -b 4096 -P -f --show "$IMG")
# BUG: losetup's partscan (-P) does nothing when trying 4096 sectors formatted images on a 512 sectors backing device.
# Hence it needs an additional partprobe run.
/sbin/partprobe $IMG_LOOP
IMG_DEV=${IMG_LOOP}p3
else
IMG_LOOP=$(/sbin/losetup -f --show "$IMG")
IMG_LOOP=$(/sbin/losetup -b 4096 -f --show "$IMG")
IMG_DEV=${IMG_LOOP}
fi
else
@ -62,8 +65,12 @@ else
if [ "0$TEMPLATE_ROOT_WITH_PARTITIONS" -eq 1 ]; then
echo "-> Creating partition table"
# have static UUIDs to make partition table reproducible
sfdisk "$IMG" <<EOF || exit 1
IMG_LOOP=$(/sbin/losetup -b 4096 -P -f --show "$IMG")
# When a 4096 sectors formatted image gets created with the sfdisk, the partitions are automatically visible
# to the system. Hence no need to run additional partprobe.
# Have static UUIDs to make partition table reproducible
sfdisk "$IMG_LOOP" <<EOF || exit 1
label: gpt
label-id: f4796a2a-e377-45bd-b539-d6d49e569055
@ -72,17 +79,21 @@ size=2MiB, type=21686148-6449-6E6F-744E-656564454649, uuid=1e6c9db4-1e91-46c4-84
type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=693244e6-3e07-47bf-ad79-acade4293fe7, name="Root filesystem"
EOF
IMG_LOOP=$(/sbin/losetup -P -f --show "$IMG")
IMG_DEV=${IMG_LOOP}p3
else
IMG_LOOP=$(/sbin/losetup -f --show "$IMG")
IMG_LOOP=$(/sbin/losetup -b 4096 -f --show "$IMG")
IMG_DEV=${IMG_LOOP}
fi
# make sure the IMG_DEV is present
c=0; while [ ! -b $IMG_DEV ]; do sleep 1; c=$((c+1)); [ $c -ge 5 ] && break; done; unset c
echo "-> Creating filesystem..."
/sbin/mkfs.ext4 -q -F "${IMG_DEV}" || exit 1
fi
# make sure the IMG_DEV is present
c=0; while [ ! -b $IMG_DEV ]; do sleep 1; c=$((c+1)); [ $c -ge 5 ] && break; done; unset c
mount "${IMG_DEV}" "${INSTALLDIR}" || exit 1
trap "umount_kill $(readlink -m ${INSTALLDIR})" EXIT
"${SCRIPTSDIR}/01_install_core.sh"

@ -72,12 +72,17 @@ fi
echo "--> Mounting $IMG"
mkdir -p mnt
if [ "0$TEMPLATE_ROOT_WITH_PARTITIONS" -eq 1 ]; then
IMG_LOOP=$(/sbin/losetup -P -f --show "$IMG")
IMG_LOOP=$(/sbin/losetup -b 4096 -P -f --show "$IMG")
# BUG: losetup's partscan (-P) does nothing when trying 4096 sectors formatted images on a 512 sectors backing device.
# Hence it needs an additional partprobe run.
/sbin/partprobe $IMG_LOOP
IMG_DEV=${IMG_LOOP}p3
else
IMG_LOOP=$(/sbin/losetup -f --show "$IMG")
IMG_LOOP=$(/sbin/losetup -b 4096 -f --show "$IMG")
IMG_DEV=${IMG_LOOP}
fi
# make sure the IMG_DEV is present
c=0; while [ ! -b $IMG_DEV ]; do sleep 1; c=$((c+1)); [ $c -ge 5 ] && break; done; unset c
mount "$IMG_DEV" mnt || exit 1
export INSTALLDIR=mnt

Loading…
Cancel
Save