I'm rewriting my build chain. Previously, I could build to CD .iso files or to a USB drive, using separate procedures. I am trying now to install to a flat disk binary image, which could be loaded directly by a VM or dd-ed onto a USB drive (possibly leaving an unallocated partition at the end?).
I'm having no end of trouble. I have found many examples that seem promising, but they tend to fail around the same step.
I wrote a shell script. Part of it reads:
Code: Select all
export CYLINDERS=10
export HEADS=16
export SECTORS_PER_TRACK=63
export SECTOR_SIZE=512
#Make HDD image
dd if=/dev/zero of=build/moss-disk.bin bs=$((HEADS*SECTORS_PER_TRACK*SECTOR_SIZE)) count=$CYLINDERS
#Make partition on disk file (re-enable as necessary)
cat <<EOF | fdisk -u -C$((CYLINDERS)) -S$((SECTORS_PER_TRACK)) -H$((HEADS)) build/moss-disk.bin
o
n
p
a
1
p
w
EOF
#Mount the disk image in a loop device
# Note: the number is the start field of the about partition * SECTOR_SIZE bytes/sector
# See the previous fdisk command, which should have printed it (prints as 2048, instead of 63)
sudo losetup -o$((2048*SECTOR_SIZE)) /dev/loop0 build/moss-disk.bin
#Make a file system on it (re-enable as necessary)
# Note: the 4016 is the number of blocks (see fdisk command above, which should have printed it.
# Note: source also explains how to set up FAT32
sudo mke2fs /dev/loop0 4016
#Mount partition
sudo mount -t ext2 /dev/loop0 /mnt
#Unmount the disk image from the loop device
sudo losetup -d /dev/loop0
Code: Select all
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
Code: Select all
Disk build/moss-disk.bin: 5 MB, 5160960 bytes
16 heads, 63 sectors/track, 10 cylinders, total 10080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x7daf4112
Device Boot Start End Blocks Id System
build/moss-disk.bin1 * 2048 10079 4016 83 Linux
I don't really know what to do here. The offset is different from the usual 63, but that oughtn't to matter as I am offsetting by the correct amount? I also tried hardcoding the correct values into the shell script, but to no avail.
Thanks,