site  contact  subhomenews

BootFlash hack

January 30, 2011 — BarryK
Forum member jinx100 reported a problem with file 'ldlinux.sys' possibly deleted when installing Puppy to Flash drive:

http://murga-linux.com/puppy/viewtopic.php?t=63719&start=165

jinx100 devised a hack for /usr/sbin/bootflash to fix this problem.

I have accepted this hack as-is, just accepting that it is a reasonable hack. I am uncertain about why this hack makes any difference, but will accept it for now.

Here is my modification to /usr/sbin/bootflash, hack inserted line 268, dated "110130":

if [ "$RADIO_HDD" = "true" ];then #hard drive.

#weird code here...
dd if=/dev/zero of=/dev/$USBDRV bs=512 count=1
sync
#fdisk cannot be used to create a partition table, it won't boot, use makebootfat...
makebootfat --output /dev/$USBDRV --syslinux3 --boot ldlinux.bss --mbr mbr.bin --copy ldlinux.sys tempdir
#...but drive broken, fix as follows...

#update: have patched 'makebootfat', no longer need this...
##optional...
##maybe should use 'parted'. with fdisk, to change heads/sectors, have to create a broken partition...
##fdisk weird, delete partition, change to 255 heads, 63 sectors/track, create a (wrong) partition...
#echo -e 'd\nx\nh\n255\ns\n63\nr\nn\np\n1\n\n\nw' | fdisk /dev/$USBDRV
#sync
##delete wrong partition, create correct partition...
#echo -e 'd\nn\np\n1\n\n\nw' | fdisk /dev/$USBDRV
#sync

#also optional...
dd if=/dev/zero of=/dev/${USBDRV}1 bs=512 count=1 #zeroise first 512 bytes of partition. some apps need this.

DRVSIZEB=`fdisk -l /dev/${USBDRV} | grep '^Disk /dev/' | cut -f 5 -d ' '` #in bytes.
DRVSIZEK=`expr $DRVSIZEB \/ 1024`
DRVSIZEM=`expr $DRVSIZEK \/ 1024`
sync
if [ $DRVSIZEM -gt 1024 ];then #1GB
#set partition-id to fat32 (0b=fat32, oc=fat32-lba)...
echo -e 't\n0b\nw' | fdisk /dev/$USBDRV
mkdosfs -F 32 /dev/${USBDRV}1 #FAT32. -n puppysave
else
#set partition-id to fat16 (06=fat16, 0e=fat16-lba)...
echo -e 't\n06\nw' | fdisk /dev/$USBDRV
mkdosfs -F 16 /dev/${USBDRV}1 #FAT16. -n puppysave
fi
sync

#110130 fix for ldlinux.sys wiped...
makebootfat --output /dev/$USBDRV --syslinux3 --boot ldlinux.bss --mbr mbr.bin --copy ldlinux.sys tempdir
sync

syslinux /dev/${USBDRV}1
#um, it may still need to have the boot flag set...
[ "`fdisk -l /dev/$USBDRV | grep '/dev/.* \\* '`" = "" ] && echo -e 'a\n1\nw' | fdisk /dev/$USBDRV
#one big fat partition, pup_save will be in it too...
PUPSAVEPART="${USBDRV}1"
PUPBOOTPART="${USBDRV}1"
else

Comments

The partition layout the bootflash makes
Username: shinobar
Please be aware: The track size of BootFlash is shorter than normal. In other word, there is small space for extended boot code. Usually they have 63 sectors before the first partition. http://www.murga-linux.com/puppy/viewtopic.php?t=51697&start=139


Tags: woof