GRUB tips and tricks
Spicing up a great utility for more IT fun
Short URL: http://fsmsh.com/1232
- 2006-01-27
- Server side | Intermediate
-
Write a full post in response to this!
GRUB with disk images
One cool trick is to use GRUB and memdisk to boot floppy disk images. Using the memdisk kernel from the syslinux package, you can load disk images and execute them in a non-emulated environment. How might this be useful? Let’s say you have an organization with several different models of desktops and laptops. You could create a CD-R/W or a bootable USB flash memory key with all of the different BIOS upgrades or hardware tests. Rather than carry around a book of floppies, you can simply copy the floppy image and boot from the CD-R/W or USB flash memory key. Using this method, you can also add Memtest86+’s floppy image to your bootable CD-R/W or USB flash memory key and have it at your disposal. Here is an example of a menu.lst snippit using memdisk to boot into Memtest86+:
title MemTest86+ Ver 1.60
kernel /boot/kernels/memdisk
initrd /boot/images/memtestp.bin
There is nothing special about the filenames. The only important thing is that the path and name referenced matches with the actual files. Check out Sidebar 1 for more examples of disk images.
GRUB with DSLinux
So how can you boot a full GNU/Linux desktop off a USB flash memory key with GRUB? First, download the DSL ISO9660 image, and either burn it to a CD, or mount it via loopback:
# mkdir dsl-test # mount -t iso9660 -o loop dsl-image.iso dsl-test
Next, copy the KNOPPIX file, kernel, and initial ramdisk:
# cp dsl-test/KNOPPIX/KNOPPIX /media/usb/boot/images/dsl # cp dsl-test/boot/isolinux/linux24 /media/usb/boot/kernels/dsl-linux24 # cp dsl-test/boot/isolinux/minirt24.gz /media/usb/boot/images/dsl-minirt24.gz # sync # umount dsl-test && rmdir dsl-test
This assumes that your USB flash memory key is mounted at /media/usb. Next, edit the /media/usb/boot/grub/menu.lst file and make sure it looks like the entry in Sidebar 1. You might have noticed that the root line at the top of the menu.lst file says (hd0,0) even though we used (hd2,0) earlier. When you boot from the USB flash memory key, the key itself becomes hd0, even before the primary master hard drive. Once you have the menu.lst file edited, go ahead and reboot. Make sure that your BIOS is set to USB-HDD, USB-ZIP, or USB-FLOPPY. You might need to experiment to see which one works. Once you get to the menu, select the option for DSL. If you get a GRUB error and are unable to successfully boot into a kernel, press the ‘c’ key to open a GRUB prompt. You can try commands like find to help locate files to boot from.
GRUB splash images
Another cool function with GRUB is putting a splash image on the boot menu screen. By default, GRUB will make the menu screen a plain black-and-white menu. There are menu options to change the black and white colors, but why stop there? Grab your favorite picture, or head to one of the URLs listed below which have splash images created for you. If you are creating your own, it will need to be in XPM format, a maximum color palate of 14 colors, and 640x480 resolution size. The GIMP can help transform your graphic to these specifications. As an alternative, you can use the ImageMagick suite of programs. The application convert can help with this conversion process. You can run it as follows:
$ convert -resize 640x480 -colors 14 mycoolpicture.jpg mybootsplash.xpm $ gzip mybootsplash.xpm
In this case, the file mycoolpicture.jpg will be resized to 640x480, reduced to 14 colors, and saved in the XPM graphical format. The second step compresses the XPM file using the gzip compression method. GRUB can display the gzipped-xpm splash images well.
If you don’t want to create your own splash image, check out some of the following web sites which have them available for download:
- GNU GRUB Public Splashimage Archive
- GRUB Splash
- Once you have the XPM or gzipped-xpm file, you need to add a line at the top of GRUB’s menu.lst to instruct GRUB to load the specified boot splash image. The line should read as follows:
splashimage=/boot/grub/debsplash.xpm.gz
In my case, I’m using the Debian boot splash image as my background.
GRUB on CD-R/W media
I’ve also mentioned several times about installing GRUB to use for a bootable CD-R/W disk. When generating the ISO image, you will use some special settings of mkisofs. The command to build a bootable GRUB CD-R/W looks like:
$ mkdir -p iso/boot/grub
$ cp stage2_eltorito iso/boot/grub
$ mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \
-boot-load-size 4 -boot-info-table -o grub.iso iso
The key is to copy the stage2_eltorito file into the /boot/grub directory of the CD image tree, and run mkisofs with the options specified above. As mentioned earlier, you can also burn a menu.lst file along with kernels and disk images and put them all on the CD. In the menu.lst, you will need to use (cd) as the device, rather than (hd0). Splash images work well, too.
Conclusion
Congratulations! Now you have a bootable USB flash memory key, with DSL and memtest86+, and even a nice boot splash image. You even have the knowledge to add extra images, like your favorite BIOS update disk image, and others. For more information, check out some of the links in the resources section below.
Resources
Write a full post in response to this!
Similar articles
Do you like this post?
Vote for it!
Copyright information
This article is made available under the "Attribution-NonCommercial-NoDerivs" Creative Commons License 3.0 available from http://creativecommons.org/licenses/by-nc-nd/3.0/.
Biography
Jeremy Turner: Jeremy Turner enjoys freelance writing when given the opportunity. He often plays system administrator, hardware technician, programmer, web designer, and all-around nice guy. You contact him by visiting his web site.
Best voted contents
-
The Jargon of Freedom: 60 Words and Phrases with Context
Terry Hancock, 2010-07-24 -
Defending the Free Commons: Another 30 Words in Context
Terry Hancock, 2010-07-14 -
MediaWiki and Script Translation for the Morevna Project
Terry Hancock, 2010-07-07 -
The Bizarre Cathedral - 75
Ryan Cartwright, 2010-07-13
Buzz authors
Free Software news
- http://tinyurl.com/23w3w9y miniature file #gameanswers #PARIS #Freesoftware
- Snort 2.8.6.1 and Snort 2.9 Beta released http://bit.ly/snort2861 #Sniffer #IDS #FreeSoftware #OpenSource #Software http://bit.ly/czjIlw
- Snort 2.8.6.1 and Snort 2.9 Beta released http://bit.ly/snort2861 #Sniffer #IDS #FreeSoftware #OpenSource #Software
- #cricketworldcup2011 #umineko agreeable site #FREESOFTWARE http://tinyurl.com/258fmff
- RT @wtebbens: #FTA scholarships, starts new courses, new books, community portal, launches Certificate http://ur1.ca/0vfuh #fta #freesoftware #oer #cc
Similar entries
Other sites
- The Top 10 Everything (Dave). The good, the bad and the ugly.
- Free Software news (Dave & Bridget). All about free software -- free as in freedom!
- Book Reviews: Illiterarty (Bridget). Book reviews, blogs, and short stories.
Hot topics - last 60 days
-
Storyboards for a film with Flickr, OpenClipart, Inkscape, Gimp, and ImageMagick
Terry Hancock, 2010-06-09 -
Finding Free Music for a Free Film with Jamendo, VLC, and K3B
Terry Hancock, 2010-07-13 -
Backup up your GoogleMail locally with getmail
Ryan Cartwright, 2010-06-19 -
Creating an Animatic Using Audacity and Kino
Terry Hancock, 2010-06-01 -
MediaWiki and Script Translation for the Morevna Project
Terry Hancock, 2010-07-07
Hot topics - last 21 days
-
Finding Free Music for a Free Film with Jamendo, VLC, and K3B
Terry Hancock, 2010-07-13 -
10 years on: free software wins, but you have nowhere to install it
Tony Mobily, 2010-07-29 -
The mobile banking has been entering an accelerative period
johny875, 2010-07-24 -
The Bizarre Cathedral - 75
Ryan Cartwright, 2010-07-13
Odiogo
Free Software Magazine uses Apollo, project management and CRM for its everyday activities!






Comments from the old system
Submitted by admin on Thu, 2006-03-30 14:43.
Vote!From: pierre laplante (SUBSCRIBER!)
Url:
Date: 2006-01-29
Subject: files
Do you have a places where we can find all the files. So it would be easier to test.
thanks
From: Matt
Url:
Date: 2006-01-30
Subject: Typo
4th sentance, 1st paragraph. "short-sided" => "short-sighted"
From: Dave Guard (SUBSCRIBER!)
Url: www.freesoftwaremagazine.com
Date: 2006-01-31
Subject: Typo - fixed.
Thanks for spotting that. Somehow, everyone in the editing process missed it. It must be because it doesn't look like a typo.
Thanks again and thanks for reading.
From: Stuart Guthrie
Url: http://www.polonious.com.au
Date: 2006-02-09
Subject: Can you boot from a disk.iso?
Is there a way to boot from a disk version of an iso? ie to cut-out the step where you burn a CD. This would be most handy..
Booting from iso
Submitted by Jeremy Turner on Tue, 2006-04-25 13:08.
Vote!Hi Stuart,
No, I was not able to find a way to boot directly from an iso image. But it was also not the intended goal. Since grub works independently of the kernel and disk image, I can copy the compressed-cloop file (usually KNOPPIX or such), along with the kernel and minirt file, save it to my flash drive, and it would work great. Some distributions, like DamnSmallLinux rarely ever change kernels (DSL 2.3 still uses 2.4.26), I don't even need to copy over those files.
Although not much, copying the entire iso would take up a little more space. Not only are there extra files on the iso image, but there's the properties of the iso image files (Joliet and RockRidge extension information) that would all need to be saved on my flash drive. This is probably not much, but I'm working with a 256 MB drive.
So the short answer is no. But let me know if you come across a way to do it!
The short answer is yes :).
Submitted by Anonymous visitor on Wed, 2006-10-04 07:35.
Vote!The short answer is yes :). I just spent the past two days to find out how.
use grub for dos (http://grub.blogeden.cn/post/23308/2412 - it's in chinese though)
If you just want to do something like in linux live cd, i.e., the iso file is used to host the systems files, it's easy and straightforward to use iso.
If you want to boot from a iso file on a harddisk, do something in menu.lst like
title Boot from iso on a harddisk
map (hdX,Y)/your.iso (hdZ)
map --rehook
chainloader (hdZ)+1
rootnoverify (hdZ)
boot
The iso file must be in one chunk - contig from sysinternal http://www.sysinternals.com/Utilities/Contig.html may come handy. It's a good idea to use fat32 to host the iso file.
Also check out
http://www.911cd.net/forums//index.phpshowtopic=15617&st=20&p=101928&#entry101928
and
http://www.911cd.net/forums//index.php?showtopic=18045
It appears the short answer is not yet but soon!
Submitted by Anonymous visitor on Mon, 2007-02-26 18:41.
Vote!http://sarovar.org/forum/forum.php?thread_id=1767&forum_id=1099
It appears the short answer is not yet but maybe soon!
Submitted by Anonymous visitor on Thu, 2007-03-29 09:25.
Vote!I'm not sure if grub4dos will work with linux iso images. As it is said in the URL you posted, the work of grub4dos in this item may be followed in the same way it is at ISOEMU (by Gandalf).
I've taked a look at:
http://www.supinfo-projects.com/en/2005/vd_boot_multi_os/2/
I've donloaded ISOEMU
http://sysoft.zdwx.com/isoemu/bin/isoemu_109_eng.zip
... and even when I read the following at the README, I tried. Not too hard because of this:
Known Limitation
=================
* Support FAT32/NTFS partition only;
* Works on x86's RealMode only(so this app cannot be used to boot Windows PE,
OR, WinNT based OS), `cause it hooks INT13h;
* Support 8.3 file format only;
so.... will it work with linux? I think not at the moment.
http://en.wikipedia.org/wiki/Protected_mode
boot from iso image
Submitted by Anonymous visitor on Fri, 2006-08-25 19:43.
Vote!I'm searching for a way to boot from iso images...
I found the avlgo to boot iso, but this don't work very well, don't support linux live cd and the compression type is incompatible for linux boot cds testeds...
Sidebar 1: Contents of menu.lst
Submitted by Jan Macek on Thu, 2006-04-13 20:38.
Vote!knoppix_dir=/boot/imagesinstead ofknoppix_dir=imagesfor correct DSL booting. Really nicely written and useful article.very nice article...!
Submitted by Anonymous visitor on Fri, 2006-08-25 18:06.
Vote!very nice article...!
awesome :) Thanks
Submitted by Anonymous visitor on Mon, 2006-09-25 12:58.
Vote!Works perfectly and so easy & simple. Thank you.
Freeze :(
Submitted by Anonymous visitor on Tue, 2006-10-17 13:15.
Vote!Boot simply freezes on my machine juste before grub is loaded (or just when it loads ?). BIOS says it has found the USB mbr and will boot on it, then nothing. I must switch off my computer.
Have searched for reasons but found nothing. If someone has hints...
Grub install
Submitted by Anonymous visitor on Thu, 2006-11-16 23:30.
Vote!When installing grub you were able to find your boot device by:
# grub
grub> find /boot/grub/stage1
(hd0,1)
(hd2,0)
Mine only shows shows my main hard disk. I am using Fedora Core 5 I have been trying to install Grub directly to the devices but it gives me a wierd error about my BIOS. My drive is a 2G noname brand. Any tips?
run as root
Submitted by Anonymous visitor on Wed, 2007-01-17 21:00.
Vote!Be sure to run the grub command as root.
On Ubuntu if I run as user it will only list hd0,0 but if I do 'sudo grub' it finds all disks.
Few corrections
Submitted by Anonymous visitor on Mon, 2007-01-08 22:50.
Vote!First, the latest version of grub I've got on FC6 actually looks for grub.conf NOT menu.lst. So you might have to rename that file.
Second, the error mentioned above is huge...the path for knoppix_dir is absolute, not relative, so it has to be /boot/images as mentioned.
Third, for the last poster on the Grub install...I've noticed that sometimes grub doesn't find the drive. I think if you do a bad search it can get confused. Quit and restart doing the commands in order. I also think that tabbing can confuse it. Took me a few tries but it worked.
Anyway, thanks for the article, it really helped!
IT FREEZES, PLEASE HELP
Submitted by Anonymous visitor on Wed, 2007-02-14 16:17.
Vote!I can load GRUB, but when i choose DSL, it starts loading, then it says "cheking for USB devices" and freezes. I am using a centrino Toshiba laptop with 4 USB ports. Can anyone give some hints? Thanks.
Relativity
Submitted by Anonymous visitor on Tue, 2007-03-06 09:53.
Vote!How could the resulting USB stick work on any computer, if the disk location is hard-coded into menu.lst?
It isnt hardcoded into
Submitted by Ixian (not verified) on Thu, 2007-05-10 09:47.
Vote!It isnt hardcoded into menu.lst.
it uses hd0,0 which is what the USB stick becomes when you boot from it.
hello there i'm trying to
Submitted by Anonymous visitor (not verified) on Fri, 2007-11-30 01:37.
Vote!hello there i'm trying to boot *.iso files from my bootdirectory
however its not accepted when edit
chainloader (hd0,1)/knoppix.iso
into grub.conf, it says it doest know the file system, but iso966- is in /grub.
it says version 0.97, is this too old ?this came with my gentoo install cd
can anyone give us their grub.conf with some working isos in it ?
thanx,
qedqubit
Could not find kernel image
Submitted by amsterdamharu on Fri, 2008-10-03 11:12.
Vote!Are you sure after running the setup it works? All I get when booting is "could not find kernel image linux". Grub is not even starting at all because I cannot use any of the grub commands.
Found many sites that say you have to format the drive and use grub-install. Trying that on a fedora 9 machine does not seem to work either: (fedora mounted the usb as TRIP and hd1 is the what I get when using find in grub (hd1,0)
# grub-install --root-directory=/media/TRIP hd1
/dev/sdb1 does not have any corresponding BIOS drive
Hope anyone can help me out here.
Are you sure grub installs this way?
Submitted by amsterdamharu on Fri, 2008-10-03 11:18.
Vote!I am using fedora 9 and all I get when rebooting is:
"Could not find kernel image: linux"
Grub has not started I think because I cannot use any of the grub commands, the only thing is typing a location for the kernel image and even that won't help
/boot/kernels/dsl-linux24
Could it be that the usb is not hd0,0? There is one hd in my computer and one cd so tried hd1,0 and hd2,0 but no luck.
Support of ext2/3 partitions and legacy BIOS
Submitted by dankexie on Thu, 2010-05-27 21:33.
Vote!Known Limitation
=================
* Support FAT32/NTFS partition only;
* Works on x86's RealMode only(so this app cannot be used to boot Windows PE,
OR, WinNT based OS), `cause it hooks INT13h;
* Support 8.3 file format only;
=================
In GRUB 0.97, you can use any file system it supports (FAT, ext2/3, etc). If GRUB doesn't boot up because BIOS doesn't recognize the USB drive correctly, there is a script to fix GRUB to run on these legacy BIOS:
http://bootloader.wikidot.com/linux:boot:usb-grub
http://bootloader.wikidot.com/linux:boot:usb