jump to navigation

Howto: Syslinux and Grub on one USB drive 16 September, 2008

Posted by aronzak in Grub, Linux, Live Usb.
Tags: , , , , ,

Intro: This is probably the coolest thing that I have done with USB bootloaders up until this point.Syslinux is an extremely useful tool that can easily and safely be installed to a usb flash drive. It can then be used to boot any version of linux, or even floppy disk images on the drive. But is is limited in that it cannot boot up operating systems on another drive. It can chainload to a working bootloader, but what if it is broken and needs to be fixed. Of course, you can start up a Linux distribution on the usb stick to fix it.

Grub is an extremely versatile tool that is used to boot up almost any operating system other than Windows. It can also be used to modify some files, or install another version of itseld to another hard disk. This is extremely useful if you have a broken grub installation.

Well, you can run boot grub from syslinux. And it’s really easy.

Step one: Stick syslinux on a drive. See this guide for easy installation of Puppy Linux.

Step two: Download a file called grub.exe. It can be found here.

Step three: This is a windows executable file (.exe) that can be run from dos. But the most impressive thing: It’s actually a linux kernel. Plonk it on the root of the drive.

Step four: Start up the usb stick and type “grub.exe’. Then, you’ve got grub. That’s it.

The rest is optional.

– Stick grub.exe in boot/grub and create a syslinux.cfg entry called grub looking like this:

LABEL grub
KERNEL /boot/grub/grub.exe

– Create your own menu.lst.

– Use a hex editor (eg. “khexedit”) and search for “timeout” or “default”. You’ll find the section that is the pretend ‘menu.lst’. You can edit as such.

– Download a useful grub tool chest called SuperGrub Disk (SGD) from here. Extract the .tar.gz onto your usb stick (should be in a folder called boot). NB. This does not work out of the box. SGD uses a customised version of grub that has a command setgrubdevice to set a variable called $grub_device. This is then used in ($grub_device). If you use Grub.exe, it does not understand this, but does not need it, as it already sets root to the correct device. You can use kate (KDE Advanced Text Editor) to remove all references of ($grub_device) (Use find and replace to replace it with nothing). Better is probably the following solution.

Edit: By accident I installed grub onto the device. Interestingly, syslinux still works fine. Syslinux has its main part in the partition of a drive, not the whole drive. Thus, grub can chain to syslinux using “root (hd(x),0) rather than “root (hd(x)”. Syslinux can also chain back to grub itself, (using chain.c32) or start grub.ex.