This is a script to make a new binary2.img that include a persistent home partition.
ROOT_SIZE is computed to be at the end of a cylinder.

PS : Sorry for my previous email (Ctrl-Enter ans thunderbird send it ;))

ROOT_SIZE="$(du -ms binary.img | cut -f1)"
ROOT_SIZE="$(expr ${ROOT_SIZE} + ${ROOT_SIZE} \* 5 / 100)"
 ROOT_SIZE_CYL=$(( ${ROOT_SIZE} / (255 * 63 * 512 / 1000000) +1))

dd if=/dev/zero of=${DISK_IMAGE} bs=1024k count=0 seek=${DISK_SIZE}

FREE_LO2="$(losetup -f)"
echo "******* Creating root partition"
Losetup ${FREE_LO2} ${DISK_IMAGE} 0
parted -s ${FREE_LO2} mklabel msdos
parted -s ${FREE_LO2} mkpart primary fat32 0.0 ${ROOT_SIZE_CYL}cyl
parted -s ${FREE_LO2} set 1 lba off
echo "******* Creating home partition"
parted -s ${FREE_LO2} mkpart primary fat32 ${ROOT_SIZE_CYL}cyl 100%
parted -s ${FREE_LO2} set 2 lba off
parted -s ${FREE_LO2} toggle 1 boot
echo "******* RĂ©tablissement du MBR"
FREE_LO="$(losetup -f)"
Losetup ${FREE_LO} binary.img 0
sudo dd if=${FREE_LO} of=${FREE_LO2} bs=446 count=1
losetup -d ${FREE_LO}
losetup -d ${FREE_LO2}

echo "******* Copying root image"
Losetup ${FREE_LO2} ${DISK_IMAGE} 1
Losetup ${FREE_LO} binary.img 1
dd if=${FREE_LO} of=${FREE_LO2} bs=1024k
losetup -d ${FREE_LO}
losetup -d ${FREE_LO2}

echo "******* Formatting home partition"
Losetup ${FREE_LO2} ${DISK_IMAGE} 2
mkfs.vfat -F 32 -n home-rw ${FREE_LO2}
losetup -d ${FREE_LO2}

echo "******* Disk summary :"
Losetup ${FREE_LO2} ${DISK_IMAGE} 0
parted ${FREE_LO2} print
parted ${FREE_LO2} u cyl print
losetup -d ${FREE_LO2}

To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact

Reply via email to