aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'create_image.sh')
-rwxr-xr-xcreate_image.sh20
1 files changed, 10 insertions, 10 deletions
diff --git a/create_image.sh b/create_image.sh
index e403df9..61ab9e7 100755
--- a/create_image.sh
+++ b/create_image.sh
@@ -4,7 +4,7 @@ IMAGE_BASENAME="${1}"
IMAGE_NAME="${IMAGE_BASENAME}.image"
IMAGE_OUT="${IMAGE_BASENAME}.vdi"
BOOT_MEGABYTES=64
-SWAP_MEGABYTES=512
+SWAP_MEGABYTES=128
IMAGE_MEGABYTES="${2}"
IMAGE_BYTES=$(( ${IMAGE_MEGABYTES} * 1024 * 1024 ))
TIMEZONE="Europe/London"
@@ -33,7 +33,7 @@ umount -d rootfs/dev &>> ${LOG_FILE}
umount -d rootfs/proc &>> ${LOG_FILE}
umount -d rootfs/boot &>> ${LOG_FILE}
umount -d rootfs &>> ${LOG_FILE}
-#losetup -d ${LOOP_DEV_ROOT}
+losetup -d ${LOOP_DEV_ROOT}
}
cleanup_mounts
@@ -43,10 +43,10 @@ echo -e "\x55\xaa" | dd bs=1 count=2 seek=510 of=${IMAGE_NAME} conv=notrunc &>>
LOOP_DEV_IMAGE=`losetup -f`
losetup ${LOOP_DEV_IMAGE} ${IMAGE_NAME} &>> ${LOG_FILE}
-sfdisk ${LOOP_DEV_IMAGE} -uM &>> ${LOG_FILE} << EOF
+sfdisk ${LOOP_DEV_IMAGE} -H64 -S32 &>> ${LOG_FILE} << EOF
1,${BOOT_MEGABYTES},83,*
-,${SWAP_MEGABYTES},82,-
-,,83,-
+$(( 1+ ${BOOT_MEGABYTES} )),${SWAP_MEGABYTES},82,-
+$(( 1+ ${BOOT_MEGABYTES} + ${SWAP_MEGABYTES} )),,83,-
EOF
sleep 2
losetup -d ${LOOP_DEV_IMAGE}
@@ -55,19 +55,19 @@ losetup -d ${LOOP_DEV_IMAGE}
echo "Creating filesystems"
LOOP_DEV_BOOT=`losetup -f`
-losetup -o 512 ${LOOP_DEV_BOOT} ${IMAGE_NAME}
+losetup -o $(( 512 * 2048 )) ${LOOP_DEV_BOOT} ${IMAGE_NAME}
mkfs -t ext2 ${LOOP_DEV_BOOT} &>> ${LOG_FILE}
sleep 2
losetup -d ${LOOP_DEV_BOOT}
LOOP_DEV_ROOT=`losetup -f`
-losetup -o $(( 512 + ( ${BOOT_MEGABYTES} * 1024 * 1024 ) + ( ${SWAP_MEGABYTES} * 1024 * 1024 ) )) ${LOOP_DEV_ROOT} ${IMAGE_NAME}
+losetup -o $(( ( 512 * 2048 ) + ( ${BOOT_MEGABYTES} * 1024 * 1024 ) + ( ${SWAP_MEGABYTES} * 1024 * 1024 ) )) ${LOOP_DEV_ROOT} ${IMAGE_NAME}
mkfs -t ext3 ${LOOP_DEV_ROOT} &>> ${LOG_FILE}
#sleep 2
#losetup -d ${LOOP_DEV_ROOT}
LOOP_DEV_SWAP=`losetup -f`
-losetup -o $(( 512 + ( ${BOOT_MEGABYTES} * 1024 * 1024 ) )) ${LOOP_DEV_SWAP} ${IMAGE_NAME}
+losetup -o $(( ( 512 * 2048 ) + ( ${BOOT_MEGABYTES} * 1024 * 1024 ) )) ${LOOP_DEV_SWAP} ${IMAGE_NAME}
mkswap ${LOOP_DEV_SWAP} &>> ${LOG_FILE}
sleep 2
losetup -d ${LOOP_DEV_SWAP}
@@ -76,10 +76,10 @@ echo "Mounting fileystems"
echo "Mount root"
mkdir -p rootfs
-mount -o loop,offset=$(( 512 + ( ${BOOT_MEGABYTES} * 1024 * 1024 ) + ( ${SWAP_MEGABYTES} * 1024 * 1024 ) )) ${IMAGE_NAME} rootfs
+mount -o loop,offset=$(( ( 512 * 2048 ) + ( ${BOOT_MEGABYTES} * 1024 * 1024 ) + ( ${SWAP_MEGABYTES} * 1024 * 1024 ) )) ${IMAGE_NAME} rootfs
echo "Mount boot"
mkdir -p rootfs/boot
-mount -o loop,offset=512 ${IMAGE_NAME} rootfs/boot
+mount -o loop,offset=$(( 512 * 2048 )) ${IMAGE_NAME} rootfs/boot
cd rootfs
# Setup Gentoo