I have an external USB hard drive with one big VFAT partition. In order to run Linux occasionally on a Windows system, I'd like to maintain a Debian Linux installation in one big file (say debianroot.img) on the VFAT partition of the external hard drive.

I create the installation from an existing Linux system. I know how to create a loopback device for the debianroot.img, create and mount an ext3 filesystem there, and I can install Debian in the target location using debootstrap (for example). It's only the boot process that I'm unfamiliar with.

My bios supports booting from a USB device, so it should work to write a boot manager to the MBR of the external hard drive and start from there. But I'm not sure which boot manager is best suited (grub?), if the standard Debian kernels have enough options, if/how I configure the initial ramdisk device (initrd), and how I get the boot files properly on the external hard drive.

At first glance, the loopback root filesystem HOWTO seems to contain very useful information, but it looks outdated (1999) and it is not very specific to Debian.

3 Answers 3


Regarding the bootmanager: when using FAT as filesystem then syslinux would be one approach. Especially when booting from USB you might consider using grub for booting, as you'll be flexible with the grub shell (providing a nice tab-completion). To install grub you'd be running something like:

mount /dev/sdX /mnt/
grub-install --recheck --no-floppy --root-directory=/mnt /dev/sdX

and adjust /boot/grub/menu.lst accordingly.

Your bootloader has to load kernel and initrd. So those files have to be outside your debianroot.img (unless you're using the ISO approach and grub2 with its loopback option, see http://michael-prokop.at/blog/2009/05/25/boot-an-iso-via-grub2/) and need to be referenced/configured in your bootloader (being syslinux.cfg for syslinux, menu.lst for grub1 and grub.cfg for grub2). The following is an example menu.lst file used for the grml live system (http://grml.org/) generated by grml2usb (http://grml.org/grml2usb/):

# misc options:
timeout 30
foreground  = 000000
background  = FFCC33

title grml  - Default boot (using 1024x768 framebuffer)
kernel (hd0,0)/boot/release/grml/linux26 apm=power-off vga=791 quiet boot=live nomce live-media-path=/live/grml/ 
initrd (hd0,0)/boot/release/grml/initrd.gz

The initrd file has to locate the debianroot.img on your devices and loopback mount it then. Then it should change your root file system via e.g. pivot_root (see http://linux.die.net/man/8/pivot_root) to inside the mounted loopback file. You can find more details regarding the initrd process in Documentation/initrd.txt of the linux kernel sources: http://lxr.linux.no/linux/Documentation/initrd.txt

If you'd like to know how common live systems do this kind of stuff check out debian-live (http://debian-live.alioth.debian.org/) or grml-live (http://grml.org/grml-live/) in combination with live-initramfs (which does all the initrd/initramfs magic and is used in most Debian based live systems; http://packages.debian.org/sid/live-initramfs).

A different approach to your debianroot.img approach would be talking an existing Debian based Linux Live system providing so called "root persistency" (for example the official Debian-live project provides this as well as grml 2009.05 does).


If you want to keep the filesystem as VFAT, use syslinux.


You've got a few problems to solve:

1) Boot from the USB drive.

2) Get the bootloader to load the kernel and initrd.

3) Setup the system so it can pivot to a '/' partition.

Number 1 is pretty easy, you get the BIOS to boot USB devices, then do something like grub-install to get the MBR changed. Notice 2 and 3 are different steps. People often have a separate small /boot partition that grub can read where grub can find the kernel, initrd, and such. You're limited to the types of devices and setups grub can understand. I'm not positive, but I'm pretty sure you're not going to be able to get grub to mount a loopback filesystem to get at /boot.

You might be better off with repartitioning the drive and creating an ext2/3 partition for /boot. You would still have to solve the problem of getting setting up the initrd and kernel to get the loopback filesystem mounted to pivot to '/' but that sounds possible.

  • I was thinking to place kernel and initrd as additional files on the VFAT partition, so outside of the loopback filesystem. Could this work? I'd rather not repartition the drive. May 31, 2009 at 18:40
  • You're out of my depth for grub. Repartitioning doesn't have to be destructive, gparted on sysrescuecd has done a great job on NTFS, FAT/VFAT, and various Linux filesystems.
    – kbyrd
    May 31, 2009 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .