Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

Maybe you know the trouble of getting either a floppy disk or even a diskdrive ready, when you have to flash some hardware in your PC. But with little effort you can use grub to boot a floppy disk image from the harddisk.

I assume grub is installed correctly.



We'll need memdisk from sys-boot/syslinux. Last time I checked syslinux depended on sys-fs/mtools, which will be very useful for us, too. (So if it does not fetch mtools automatically emerge them, too) emerge syslinux.

Now we'll create a new directory (I called it dos, use whatever you feel comfortable with) as we don't want to clutter /boot and copy the memdisk utility there:

If you placed /boot on a separate partition mount it first!

Code: Mounting /boot
mount /boot
mkdir /boot/dos
cp /usr/share/syslinux/memdisk /boot/dos/

Getting a disk image

Now we'll have to get the disk image we want to boot into this directory. If you don't know where to get one check this HOWTO or [1].

cp /path/to/your/imagefile.img /boot/dos/

Configuring mtools

As we might want to edit the disk before booting (e.g. to copy a bios flasher + bios onto it), we have to configure mtools:

Code: Configure mtools
cp /etc/mtools/mtools.conf.example /etc/mtools/mtools.conf
nano -w /etc/mtools/mtools.conf

Follow the comments in this file and setup a line like drive b: file="/boot/dos/imagefile.img"

Now you can use mdir b: to list the contents of the image. To copy files to the image you can use mcopy, to delete files use mdel, etc.

Editing grub.conf

Now we'll have to tell grub about this new bootoption, so edit /boot/grub/grub.conf to include this:

File: /boot/grub/grub.conf
title DosFlashDisk
kernel /dos/memdisk
initrd /dos/imagefile.img

You may want to password-protect that entry, as it can be dangerous if someone untrusted and skilled can boot up a less secure OS on your computer.


When you're done unmount /boot and restart to see, if the new entry in grub works.

Happy flashing.

Retrieved from ""

Last modified: Thu, 04 Sep 2008 06:25:00 +0000 Hits: 15,970