It seems that booting systems is giving me a headache again.

I had to flash the firmware of my Infoway Note N8320 notebook which is an MSI Aesthetics PR200 disguised in a nice clothing. Of course, it had a firmware update that required being applied only from a regular DOS floppy. But the size of a floppy isn't enough to hold the new firmware.

To cut a long story short, it was quite painful to get things going, but here are the distilled situation:

#!/bin/sh

#
# Collection of information from:
#
# http://feeding.cloud.geek.nz/2009/08/grub-on-bootable-usb-rescue-stick.html
# http://www.mayrhofer.eu.org/Default.aspx?pageid=45
# http://en.gentoo-wiki.com/wiki/FreeDOS_Flash_Drive
# http://www.gnu.org/software/grub/manual/grub.html#Installation-under-UNIX
# http://www.omninerd.com/articles/Installing_GRUB_on_a_Hard_Disk_Image_File
#

# needed: syslinux, parted, grub
SIZE=32

# Create the basic disk image
dd if=/dev/zero of=disk.img bs=1M count=$SIZE
parted --script disk.img mktable msdos
parted --script disk.img mkpart primary fat16 0 ${SIZE}MB
parted --script disk.img mkfs 1 fat16
parted --script disk.img set 1 boot on

# Mount it
SECTORS=\((fdisk -l -u disk.img 2>&1| tail -1 | perl -ne 'prýÊ{úkz––çBf×·V÷C\)1" if (m/\s+(\d+)\s+/);')
    mount -t vfat -o loop,offset=$((SECTORS * 512)) disk.img /mnt

# Copy the bootloader
# Copy a FreeDOS image and treat it as a ramdisk (it will be the "A:" drive)
mkdir -p /mnt/grub
cp /usr/lib/grub/x86_64-pc/* /mnt/grub
cp /usr/lib/syslinux/memdisk /mnt
wget -O /mnt/odin1440.img http://odin.fdos.org/odin2005/odin1440.img

# Set up grub (grub legacy)
cat <<EOF0 > /mnt/grub/menu.lst
default=0
timeout=10
root=(hd0,0)
title FreeDOS
kernel /memdisk
initrd /odin1440.img
EOF0

grub --device-map=/dev/null --batch <<EOF1
device (hd0) /tmp/disk.img
root (hd0,0)
setup (hd0)
quit
EOF1

# Copy extra contents (e.g., the firmware) to the disk here (the "C:" drive)
touch /mnt/example.txt

# Finish it
umount /mnt
blog comments powered by Disqus