From e95c2f2a69b6e59e3d0358201f0c13eeeca768bd Mon Sep 17 00:00:00 2001 From: jedi Date: Wed, 29 Jan 2020 13:37:36 +0100 Subject: [PATCH] wip --- entry.sh | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/entry.sh b/entry.sh index 8cbae8b..e4f73e7 100755 --- a/entry.sh +++ b/entry.sh @@ -4,24 +4,33 @@ source $(dirname $0)/utils.sh function first_stage(){ echo foo first_stage - echo creating image file - dd if=/dev/zero of=/root/disk.img bs=1M count=512 - LODEV=$(losetup --show -f /root/disk.img) - ( - echo o # Create a new empty DOS partition table - echo n # Add a new partition - echo p # Primary partition - echo 1 # Partition number - echo # First sector (Accept default: 1) - echo # Last sector (Accept default: varies) - echo w # Write changes - ) | fdisk ${LODEV} - losetup -d ${LODEV} + + if [[ ! -e /root/disk.img ]]; then + + echo creating image file + dd if=/dev/zero of=/root/disk.img bs=1M count=512 + LODEV=$(losetup --show -f /root/disk.img) + ( + echo o # Create a new empty DOS partition table + echo n # Add a new partition + echo p # Primary partition + echo 1 # Partition number + echo # First sector (Accept default: 1) + echo # Last sector (Accept default: varies) + echo w # Write changes + ) | fdisk ${LODEV} + losetup -d ${LODEV} + + fi + LODEV=$(losetup --show -fP /root/disk.img) echo using device $LODEV echo mount divice to $TARGET - mount $LODEVp1 $TARGET + echo mkfs.ext4 ${LODEV}p1 + mkfs.ext4 ${LODEV}p1 + mount ${LODEV}p1 $TARGET + echo mount ${LODEV}p1 $TARGET echo debootstrap sid $TARGET }