Bootable USB using GRUB and Puppy 5.2

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
rdog
Posts: 25
Joined: Mon 18 Oct 2010, 20:47
Location: Quesnel, BC, Canada

Bootable USB using GRUB and Puppy 5.2

#1 Post by rdog »

There are a number of ways to create a bootable USB key for Puppy 5.2. I will document a way that works for me.

If you have trouble using GParted on your USB (exits immediately)
start by wiping the partition table (assuming your USB is sdc) at a
console prompt type (back up any files you wish to keep from the
USB first):
dd if=/dev/zero of=/dev/sdc bs=512 count=1

You can wipe your entire key (if you wish) with the command
dd if=/dev/zero of=/dev/sdc
Provided your key is seen as sdc. Careful with this command it will wipe any
drive that is recognized as sdc. You can cancel out of this dd process part
way through by hitting CTRL and C together. Canceling out does not mean
any damage done so far is reversed or undone however.

Using GParted access the USB device. You will first need to create
a partition table (if you wiped it as shown above),
Device menu -> Create Partition Table, click Apply. A
MS-DOS partition table is the one you want (it is the default).

Partition the USB key as fat32 (so Windows can also see it). Click Apply.
Right click on the new partition and select Manage Flags from the shortcut
menu. Select (check) boot so the partition is marked as bootable. Quit
GParted.

Then create a /boot directory and a /puppy52usb directory at the root of the
partition.

Then create a /boot/grub directory on the USB key.

Then copy the files stage1, stage2, and fat_stage1_5, and put them
into the /boot/grub directory on the USB flash memory key. These files
are located in /usr/lib/grub/i386-pc in a puppy installation.

cp /usr/lib/grub/i386-pc/stage1 /mnt/sdc1/boot/grub
cp /usr/lib/grub/i386-pc/stage2 /mnt/sdc1/boot/grub
cp /usr/lib/grub/i386-pc/fat_stage1_5 /mnt/sdc1/boot/grub

Copy the puppy boot files over to /puppy52usb/ on the USB key. These
files include initrd.gz, lupu_520.sfs, vmlinuz and any puppy save files
or SFS (squash file system) files you wish to prime the USB with.

After the files are copied over, it's time to install GRUB to the
Master Boot Record (MBR) of the USB flash memory key.

# grub
grub> find /puppy52usb/vmlinuz
(hd2,0)

This indicates what drive to use for the following commands. Ensure we don't
have this same folder file structure on any other disk or we may be confused.

grub> root (hd2,0)

# Make sure you use the drive indication not including the partition
# for the following setup command or it will fail.

grub> setup (hd2)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/fat_stage1_5" exists... yes
Running "embed /boot/grub/fat_stage1_5 (hd2)"... 15 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd2) (hd2)1+15 p (hd2,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.
grub> quit

Edit (create) the /boot/grub/menu.lst file to look something like this.
# GRUB configuration file '/boot/grub/menu.lst'.
#
# Start GRUB global section
default 0
timeout 5
color light-gray/blue black/light-gray
# End GRUB global section
# Linux bootable partition config begins
title Puppy Linux 5.2 (usb as hd0,0)
root (hd0,0)
kernel /puppy52usb/vmlinuz pmedia=usbflash psubdir=puppy52usb
initrd /puppy52usb/initrd.gz
# Linux bootable partition config ends
# Linux bootable partition config begins
title Puppy Linux 5.2 pfix=ram (no pupsave file loaded, usb as hd0,0)
root (hd0,0)
kernel /puppy52usb/vmlinuz pmedia=usbflash pfix=ram psubdir=puppy52usb
initrd /puppy52usb/initrd.gz
# Linux bootable partition config ends
#title Install GRUB to floppy disk (on /dev/fd0)
#pause Insert a formatted floppy disk and press enter.
#root (hd0,0)
#setup (fd0)
#pause Press enter to continue.
#title Install GRUB to Linux partition (on /dev/sda1)
#root (hd0,0)
#setup (hd0,0)
#pause Press enter to continue.
title - ===============================================================
root (hd0)
title - For help press 'c', then type: 'help'
root (hd0)
title - For usage examples press c then type: 'cat /boot/grub/usage.txt'
root (hd0)
title - For robs notes press c then type: 'cat /boot/grub/robsnotes.txt'
root (hd0)
title - The interactive grub prompt supports TAB commandline completion
root (hd0)
title - ===============================================================
root (hd0)
The contents of the /boot/grub/robsnotes.txt file looks like this...
This file is some of my notes concerning boot problems specifically
with regards to the USB.

The usage.txt file has more general information
type: 'cat /boot/grub/usage.txt' to see that file.

When setting up the grub boot the indicated drives and partitions
are not the same as when actually booting from the USB key.

For example the drive sdc was indicated as (hd2) and the partition
sdc1 was indicated as (hd2,0) when we installed grub. But When actually
booting from the USB, the BIOS remaps it to be (hd0) as if it was
the first hard disk. I alter the menu.lst text file to use (hd0,0)
as the boot partition and it works. After booting the drives are
switched around and then the hard disk in grub is once again assigned
(hd0) and the USB (hd2).

This may not be true for all computers. So if you are unable to
boot this puppy USB it could be you need to edit the entry to use
(hd2) again. One way to know what you have to use is to press c this
will put you into the Grub interactive mode. Then type find
/puppy52usb/vmlinuz (or a file you know should be on the USB).
Grub will indicate which drive it finds the file on (one reason
why I changed the puppy folder to say puppy52usb).

Press the [Esc] key to return to the GRUB menu. Then press e to
edit the entry for booting puppy. Highlight the (hd0,0) line and press
e again. Change the line to be (hd2,0) or whatever drive it should be
and then press b to boot.

Hope this helps. Rtaylor.
If the /boot/grub/usage.txt file does not exist it looks like this..
=======================================================================
This is an example of how to use the GRUB edit function.

Highlight the menu entry you want to edit, then press 'e', then
highlight the line you want to edit and press 'e'. Add what
you want to the line 'hdd=scsi' etc. and press enter, then
'b' to boot.

Examples of the difference between Linux and GRUB device names.

Linux IDE: GRUB IDE: Linux SCSI: GRUB SCSI:
/dev/hda1 (hd0,0) /dev/sda1 (hd0,0)
/dev/hda2 (hd0,1) /dev/sda2 (hd0,1)
/dev/hda3 (hd0,2) /dev/sda1 (hd0,2)
/dev/hda4 (hd0,3) /dev/sda2 (hd0,3)
/dev/hdb1 (hd1,0) /dev/sdb1 (hd1,0)
/dev/hdb2 (hd1,1) /dev/sdb2 (hd1,1)
/dev/hdb3 (hd1,2) /dev/sdb1 (hd1,2)
/dev/hdb4 (hd1,3) /dev/sdb2 (hd1,3)

These are some examples of how to use GRUB from the command prompt.

Press the 'c' key for the command prompt.

If you want to boot a Linux system on a partition, using it's kernel
/boot/vmlinuz etc., do this.

grub> root (hd0,1)
grub> kernel /boot/vmlinuz root=/dev/hda2 ro
grub> boot

You could do this to find what partition the kernel is on.
For example, show me what partitions have a /boot/vmlinuz.

grub> find /boot/vmlinuz
(hd0,1)
(hd0,2)

If you want to boot a Dos/Win partition, do this.

For example, boot partition on /dev/hda1.

grub> rootnoverify (hd0,0)
grub> makeactive
grub> chainloader +1
grub> boot

If you want to boot a FreeBSD partition using /boot/loader.

For example, boot freebsd partition on /dev/hda4.

grub> root (hd0,3,a)
grub> kernel /boot/loader
grub> boot

If that doesn't work, try this instead.

grub> rootnoverify (hd0,3,a)
grub> chainloader +1
grub> boot
==============================================================

Press the [Esc] key to return to the GRUB menu.
That's it for the instructions now for the novel (story) part of the document. I have 5 machines to test boot keys on and I have a variety of keys ranging from 128 Megabytes to over 4 Gigabytes.

When I first started with Puppy I used the Puppy Universal Installer and some of my smaller keys. The installation and operation of the USB keys seemed to go very well and I was able to boot the keys on several of my PCs with little difficulty.

As I grew in my Puppy knowledge and learned to create and use sfs files for my applications (saving on pupsave file space) my needs for more space on the USB keys grew. I started using more of my keys and ran into some difficulties.

I have one key in particular that is actually 4.17 Gb in size which I could never manage to make bootable. I tried everything I could using the "Puppy Universal Installer", "Using the BootFLASH install Puppy to USB" and using dd to put different MBRs over to the USB.

Then I have another key which is actually 3.79 GB in size which I managed to get to be bootable on one PC using the "Puppy Universal Installer" but which would not boot on several other PCs.

I searched for tools and howtos in Google and tried and failed at a number of efforts. Often I would end up with the key no longer able to be accessed by GParted. GParted would just immediately exit when trying to read the partition table.

Finally I managed to put together this method (documented above) by extracting details from a few different howtos I found. The exciting part is now my 4.17 GB key will boot properly (never booted before) and my 3.79 GB key boots on every PC I've tried it on.

I have gone on to develop a similar howto for creating a DOS bootable USB key using Puppy 5.2 and Grub. Here is a link to that post:
http://www.murga-linux.com/puppy/viewtopic.php?t=64631

User avatar
WB7ODYFred
Posts: 169
Joined: Sun 14 Dec 2008, 02:15
Location: Oregon & Washington

Adding a PNG file that shows using ROX Filer to copy files

#2 Post by WB7ODYFred »

Hello Adding a PNG picture that has me using the ROX Filer to copy files to USB Flash Disk Drive. It clears up where to find the source files.
Thanks for this excellant tutorial that makes good sense!
I can confirm that a 128MByte Flash Disk Drive is just a little bit small for Lupu 5.20 Puppy Linux.. One needs a minimum 256Mbyte Flash drive for Lupu 5.20 installation.

I booted from Lupu 5.20 CD rom. I clicked on the sr0 icon on the desktop and clicked on the sdb1 icon for the USB Flash disk drive.
cp /mnt/sr0/vmlinux /mnt/sdb1/puppy52usb
cp /mnt/sr0/initrd.gz /mnt/sdb1/puppy52usb
cp /mnt/sr0/lupu_520.sfs /mnt/sdb1/puppy52usb

Are any of the other files listed in /mnt/sr0 needed to be copied onto the USB Flash drive like: logo.16 boot.msg help.msg help2.msg ??
Attachments
copy_boot_files_to_usb_drive.png
Use ROX Filer to copy files graphically to USb Flash Disk or use the command line from the Menu --> Utility --> Urxvt Terminal Emulator.
cp /mnt/sr0/initrd.gz /mnt/sdb1/puppy52usb
(136.87 KiB) Downloaded 641 times

User avatar
WB7ODYFred
Posts: 169
Joined: Sun 14 Dec 2008, 02:15
Location: Oregon & Washington

Additional Help files in making a bootable USB Flash Disk.

#3 Post by WB7ODYFred »

refer to this post that has links to read up on Grub Usage on the web.
http://www.murga-linux.com/puppy/viewto ... 821#442821

Command line useage
Menu --> Utility --> Urxvt terminal Emulator

fdisk -l /dev/sdb Fdisk command can edit the partition from the command line the same as Gparted can do from a graphical screen. You can start gparted from the command line as below.

gparted /dev/sdb Working with Gparted to partition the USB Flash Disk device. Set the type to "FAT32" or "FAT16" for smaller flash disks. Edit the label name. Set the "Boot" flag.

df /dev/sdb1 how much disk free space exists on the sdb1 device.

mount The command by itself will list what devices are already mounted.

mount /dev/sdb1 /mnt/sdb1
mount /dev/sr0 /mnt/sr0
ls /mnt/sdb1 list the files in the root directory on the sdb1
df /mnt/sdb1 check the sdb1 disk free space
mkdir /mnt/sdb1/boot
mkdir /mnt/sdb1/boot/grub
mkdir /mnt/sdb1/puppy52usb
ls /mnt/sr0 list the files in the root directory on the CDROM
ls /usr/lib/grub/i386-pc listed the file in the mounted grub directory
[ 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> find /puppy52usb/vmlinuz
(hd1,0)

grub> root (hd1,0)

grub> setup (hd1)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/fat_stage1_5" exists... yes
Running "embed /boot/grub/fat_stage1_5 (hd1)"... 16 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd1) (hd1)1+16 p (hd1,0)/boot/grub/stage2
/boot/grub/menu.lst"... succeeded
Done.

grub>
when finished using the USB Flash disk drive (sdb1) and the CDROM (sr0) unmount them from the filesystem with the "umount" command.
umount /mnt/sdb1
umount /mnt/sr0

Hope this documentation is complete, not confusing, and helpful to you.
I welcome your posts to make it better. Fred Finster
Attachments
menu.lst.tar.gz
Sample files for Lupu 5.20 menu.lst, usage.txt robsnotes.txt
(1.8 KiB) Downloaded 497 times

User avatar
edoc
Posts: 4729
Joined: Sun 07 Aug 2005, 20:16
Location: Southeast Georgia, USA
Contact:

#4 Post by edoc »

Fred -

We should take this to a new thread - but I am using this because I did not see the usual links for E-mail associated with your avatar.

I am trying to access an Alinco DR-135TP from my old Panasonic CF-29 laptop - which has a serial port - now cabled to the rig.

I opened the Urxvt Terminal Emulator and power-cycled the rig - which should bring up ...
TASCO RADIO MODEM
AX.25 Level 2 Version 2.0
Release 9/15/99 2Chip ver 2.00
Checksum $CF
cmd:
... but nothing happens.

It has been years since I used a terminal emulator for BBS's and Packet so I have completely forgotten everything.

What, please, is the command to query the serial port?

I am guessing there may be a BIOS or cable problem causing the initial communications failure.

Thanks! & 73, doc KD4E
[b]Thanks! David[/b]
[i]Home page: [/i][url]http://nevils-station.com[/url]
[i]Don't google[/i] [b]Search![/b] [url]http://duckduckgo.com[/url]
TahrPup64 & Lighthouse64-b602 & JL64-603

Post Reply