How to boot puppy from a USB flash drive with Grub

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
bodiless
Posts: 5
Joined: Fri 12 Dec 2008, 20:40

How to boot puppy from a USB flash drive with Grub

#1 Post by bodiless »

Introduction
Recently I wanted to use Puppy 4.0 together with the openoffice suite on my new Thinkpad x61s. This laptop doesn't have a cd drive so I needed to install puppy on a usb flash drive. However, among the different option found in the universal installer my BIOS would only recognize the comboformat option. This option creates one small 124MB partition and one larger with the remaining space. The problem was, that the approx. 200MB openoffice.sfs file would not fit on the 124MB partition and resizing the two partitions with gparted did not help either. The solution that worked for me was to first make the usb bootable with grub, then add the necessary puppy and sfs files and finally instruct grub how to boot puppy.

So this how to is meant to help people who need to use and have already used the comboformat option but want the additional functionality of extra sfs files.

I wrote this how to summarizing in fact this threat and this blog entry on how to create a bootable usb flash drive.

1. Prerequisite
You will need a USB flash drive (I used a 1GB drive), a computer running linux with grub and some knowledge of the Linux command line. The technique is not considered for complete "newbies" since the tools used are not without risk for other partitions and OSes that you may have on your PC if you are not understanding what you are doing.

Therefore be careful, be sure you understand what you're doing, and use at your own risk.

2. Using the ComboFoarmat option of the Universal Installer and resizing with gparted

If you have already used the comboformat option the df -h command will give you this output:

Code: Select all

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb2             816M  840K  816M   1% /media/disk
/dev/sdb4             125M  117M  8.0M  94% /media/disk-1
The sdb4 partition is where the puppy and the sfs files go. As said above, I tried to increase the sdb4 partition from 124 to 500MB with gparted. Gparted exited with an error and as you can see below, the only difference was that some space disappeared and most importantly, the sdb4 partition remained almost full.

Code: Select all

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb2             197M  432K  196M   1% /media/disk-1
/dev/sdb4             125M  117M  8.0M  94% /media/disk
3. Repartition the drive, format it to FAT16 and install Grub
To do this you need a computer running linux with GRUB. I guess the same could be achieved with the older boot manager lilo but I have never used lilo so don't know very much about it.

First we must find how the USB drive is identified. So, right after plugging the drive in a linux computer I run "dmesg".

Code: Select all

dmesg | tail
[ 5251.002101]  sdb: sdb2 sdb4
[ 5251.032106] sd 4:0:0:0: [sdb] Attached SCSI removable disk
So the drive was identified as sdb. Next I used fdisk to delete the two partitions that were created with the comboformat installer and create one large with the total of 1GB.

Code: Select all

fdisk /dev/sdb
This command will start fdisk on the drive

The following commands were used:

Code: Select all

p (to see the the 2 partitions and partition numbers)
d (to delete one partition)
2 (to delete partition /dev/sdb2)
d (to delete the other partition)
n (to create a new partition)
p (to create a primary partition)
1 (to be the first partition)
enter (for default first cylinder value)
enter (for default last cylinder value)
t (to change partition id)
6 (to make it a FAT16)
w (to write the new changes to disk)
p (to see the new partition just created)
The new partition on the drive should look now like this:

Code: Select all

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         954      976880    6  FAT16
Next I went ahead to make the file system with "mkfs". I am not sure why this was necessary but I guess it has something to do with the new partition table and the MBR of the drive which obviously have been destroyed with my previous attempts to format it.

Code: Select all

mkfs.vfat /dev/sdb1
Then I installed Grub on it.

Code: Select all

grub-install /dev/sdb
This command didn't work for me so i tried:

Code: Select all

grub-install --recheck /dev/sdb
This went ok. The output was:

Code: Select all

(hd0)	/dev/sda
(hd1)	/dev/sdb
Write down the output as we will need it later when configuring grub.

After installing grub we need to copy some files. I created a /media/usb directory, mounted the drive, created a boot directory (named /boot) in the drive and copied over the necessary grub files.

Code: Select all

mkdir /media/usb/
mount /dev/sdb1 /media/usb/
mkdir -p /media/usb/boot/
cp -r /boot/grub/ /media/usb/boot/
Remember from above that our drive was identified by grub as "(hd1) /dev/sdb"? We use this to make the drive bootable with:

Code: Select all

grub
grub>root (hd1,0)
grub>setup (hd1)
quit
Now the drive should be bootable!

4. Install puppy on the drive
All you need is to copy the files included in the iso to the flash drive. I downloaded the puppy iso file and mounted it under /mnt/iso/:

Code: Select all

mount -o loop puppy-4.1.2-k2.6.25.16-seamonkey.iso /mnt/iso/
Then I copied the puppy files into the boot directory of the drive:

Code: Select all

cp -r /mnt/iso/* /media/usb/boot/
Finally I downloaded the openoffice-2.4.1.sfs file, renamed it to openoffice-2.4.1_400.sfs (same extension as the pup_400.sfs from the iso) and placed it into the flash drive (outside of the /boot directory).

Code: Select all

cp openoffice-2.4.1_400.sfs /media/usb/
5. Instruct grub where to find puppy

Last step was to edit the menu.lst file which is found in the /boot/grub directory of the flash drive.

I made it look like this:

Code: Select all

default		0
timeout		5
color cyan/blue white/blue
title		Puppy Linux 400, kernel 2.6.21.7
root		(hd0,0)
kernel		/boot/vmlinuz root=(hd0,0) ro quiet
initrd		/boot/initrd.gz
That's it. I rebooted and happy puppy!
6. Troubleshooting
I tried the above with two different flash drives. With one of them, after passing the grub screen I was dropped out to a console with the following error:

Code: Select all

pup_400.sfs not found. Dropping out to initial-ramdisk console...
/bin/sh: can't access tty1 job control turned off
If you get this type:

Code: Select all

. /init
(be careful, that's dot, space, slash, init). After this it booted ok.
Last edited by bodiless on Tue 26 Jan 2010, 13:52, edited 1 time in total.

User avatar
Evil20071
Posts: 489
Joined: Sat 07 Jun 2008, 19:50
Location: Piedmont, SC,.United States
Contact:

#2 Post by Evil20071 »

Would this also work out if I am installing puppy on an external USB hard drive?
[url=http://totalelectronics.us]TotalElectronics.us[/url]

bodiless
Posts: 5
Joined: Fri 12 Dec 2008, 20:40

#3 Post by bodiless »

To be honest I have never done it but I see no reason why it shouldn't.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#4 Post by rcrsn51 »

You can definitely set up an external USB hard drive using GRUB. But there may be a catch. In older versions, Puppy does not distinguish between an actual USB hard drive and a flash drive. So it launches using PUPMODE=13 instead of 12. This means that Puppy runs in all-in-memory mode and may ignore any available swap. I haven't checked to see if this bug has been fixed in the latest version.

Post Reply