online notes grub1 to usb device
Status: Assistant
Joined: 21 Sep 2008
Posts: 358
Location: Australia
Reply Quote
I have a camera storage SD card that fits into an usb adaptor that bios accepts as boot drive---If I do things corrrectly. Works the same as an USB stick

This method to install may also work for netbook users who have no optical drive.
Assume all commands are root so run su (or sudo su) please
Convert SD to linux format etc
use fdisk to delete the partition and create a fresh one thats linux
now add bootable flag
and then write the changes to disk and quit
:: Code ::

fdisk /dev/sdb

-----d 1 n p 1 default-start default-full-end a w q
next format it
:: Code ::

mkfs.ext2 /dev/sdb1

Try to avoid re-inserting or your dev will change to sdc1 etc
Download a small distro and mount it
I chose 165 megs
Macpup_528.iso version 1
:: Code ::

mkdir /tmp/iso
mount -o loop Macpup_528.iso /tmp/iso

copy iso files to usb device
umount downloaded iso
no boot folder needed
:: Code ::

cd /
mkdir -p /z/grub
mount /dev/sdb1 /z
cp /tmp/iso/vmlinuz.gz /z
cp /tmp/iso/initrd.gz /z
cp /tmp/iso/macpup_528.sfs /z
umount /tmp/iso

The squashfile needs to be in the same folder as the kernel and intrd.
grub legacy stuff
lets create one file the grub menu as its a bit different

nano /z/grub/menu.lst (or whatever text editor you use instead of nano)
:: Quote ::

timeout 10
default 0
color light-blue/black light-cyan/blue

title Macpup 528
kernel /vmlinuz root=/dev/ram0 pmedia=usbflash
initrd /initrd.gz

title Macpup 528 - RAM
kernel /vmlinuz root=/dev/ram0 pfix=ram pmedia=usbflash
initrd /initrd.gz

pmedia may mean puppy-media and the help file called help2.msg sitting in the iso says
:: Quote ::

Type of media booting from. Choose one of these:
usbflash usbhd usbcd ataflash atahd atacd atazip scsihd scsicd cd

Because my hd is grub2, which I am not touching lets use an unpacked debian binary for

alternative download is

Use your file manager to peek inside it ....or xarchiver.
We need data folder unpacked to where we can use it.
populate some grub legacy files from data folder to usb
:: Code ::

mount /dev/sdb1 /z
cp data/usr/lib/grub/i386-pc/*  /z/grub

Now lets try to install bootloader
----try at own risk----make sure you are either doing this in a vm or have the correct sd LETTER please

Pay attention to the format grub-legacy sees for the target partition. My hd is ext3 and the usb is I am safe.
if below command does not work, change to execute permission

chmod +x data/usr/sbin/grub

:: Code ::

cd data/usr/sbin
./grub  (note its dot / grub)
GNU GRUB  version 0.97  (640K lower / 3072K upper memory)
       [ Minimal BASH-like line editing is supported.   For
         the   first   word,  TAB  lists  possible  command
         completions.  Anywhere else TAB lists the possible
         completions of a device/filename. ]
grub> root (hd1,0)
 Filesystem type is ext2fs, partition type 0x83
grub> setup (hd1)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd1)"...  17 sectors are embedded.
 Running "install /grub/stage1 (hd1) (hd1)1+17 p (hd1,0)/grub/stage2 /grub/menu.lst"... succeeded
grub> quit

Now double check the grub is in mbr for your usb device
:: Code ::

dd if=/dev/sdb bs=512 count=1 | strings
1+0 records in
1+0 records out
512 bytes (512 B) copied, 2.525e-05 s, 20.3 MB/s
Hard Disk

reboot to test usb device

< Edited by aus9 :: Jul 28, 12, 16:00 >

Back to top
Status: Assistant
Joined: 21 Sep 2008
Posts: 358
Location: Australia
Reply Quote
persistence is available thru options at shutdown (maybe reboot)
so save changes.

these go into a squashfile

I have put sd card back into camera.

Above post works for usb stick as well.

Back to top
Display posts from previous:   

All times are GMT - 8 Hours