Booting from USB pen: troubleshooting and pitfalls
As grml supports booting from usb devices (harddisk installation via grml2hd as well as booting from usb pens via grml2usb) and I helped many people at debugging booting problems I think I stumbled upon every existing pitfall. 8-) There are several situations where booting might fail. So here we go with a summary of the most common pitfalls and possible solutions:
-
The Bootsplash is displayed, the kernel loads but you very soon get a:
-
When trying to boot from USB you get something like:
-
When trying to boot from USB you get something like:
-
When trying to set up the partition(s) on the USB device cfdisk reports something like:
-
The system never displays the bootsplash of the usb device at all? Checklist:
- does your system support booting from USB at all? Check settings in BIOS.
- do you use the correct USB mode in BIOS? Check BIOS again, usually you want to use USB-HDD mode. Not possible? See USB-ZIP mode.
- is "booting from USB" in the appropriate order of the booting sequence? Check the "boot"-section in your BIOS.
- is the bootable flag set on the boot-partition? Check for example with cfdisk.
- is the partition used for booting the first partition and a primary one on your device? Check with cfdisk again.
- is the partition layout ok? The first partition (the one used for booting) has to start at cylinder 1/sector 63, otherwise booting will fail on most (all?) x86 systems. Check with ‘cfdisk -P s /dev/..’ or ‘fdisk -l -u /dev/…’. Do *not* trust the output of ‘fdisk -l /dev/…’. Really.
-
syslinux does not work on your system (b0rken BIOS for example)? Possible solution: use grub instead.
-
Kernel boots but fails to find the root filesystem with something like:
-
All of the above tips don’t work? Maybe your USB pen is even larger than 1GB?
ran out of input data System halted
Reason: everything OK, except for the filesystem used on your usb device. So instead of fat16 you use for example fat32. Fix: use the appropriate filesystem (fat16 for usb pens usually).
Invalid operating system
Possible reason: the partition layout is not ok. Very probably there’s no primary partition or none has the flag ‘bootable’ set. (Read on for further details.)
No operating system found.
Possible reason: you forgot to set the boot-flag on the partition. Or you did not install an operating system at all. ;-)
FATAL ERROR: Bad primary partition 0: Partition ends in the final partial cylinder
Reason: the partition layout is not ok. Either use fdisk (requires detailed knowledge about partition setup!) or better: use a fronted of libparted, like gparted. gparted does an excellent job at setting up an appropriate partition layout for booting from USB (read on for details about the correct setup). As long as cfdisk has problems with the layout – it will exit on errors – your usb pen very probably does not have a valid partition setup for booting. Please notice that fdisk very often uses defaults which are not OK, whereas gparted uses the appropriate heads, sectors/track and cylinders settings. So if you really want to use fdisk for setting up the appropriate partition layout you might have to enter the ‘extra functionality (experts only)’ menu of fdisk.
kernel-panic: unable to mount root-fs...
Yes? Then the root= argument in your kernel commandline (specified in the bootloader, usually lilo, grub or isolinux/syslinux) is pointing to the wrong device. Solution: adjust the root=-option in your bootmanager’s configuration. Tip: use root=UUID instead of root=/dev/[hs]d…
Possible reason: Some BIOSes offer different modes for USB booting. The proper mode to boot a USB stick is USB-HDD. If that doesn’t work or is not supported by your system, you need to format your USB-Stick as USB-ZIP. To do this, the syslinux source distribution contains an utility called mkdiskimage, which you can use to re-format your USB stick in USB-ZIP format. For more information refer to the USB-webpage in the grml-wiki and Bootable USB Key in the knoppix-wiki.
I mentioned the correct partition layout several times. Reminder: a first, primary partition with fat16 (as filesystem as well as partition’s system id!) with bootable-flag set. The partition should start behind MBR at 1st cylinder and 63rd sector (see www.ata-atapi.com/hiwmbr.htm and thestarman.pcministry.com/asm/mbr/index.html for more details about MBR). So how does a correct partition look like? Output in several formats as reference:
# fdisk -l -u /dev/sda Disk /dev/sda: 1039 MB, 1039663104 bytes 255 heads, 63 sectors/track, 126 cylinders, total 2030592 sectors Units = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks Id System /dev/sda1 * 63 2024189 1012063+ 6 FAT16 # fdisk -l /dev/sda Disk /dev/sda: 1039 MB, 1039663104 bytes 255 heads, 63 sectors/track, 126 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 126 1012063+ 6 FAT16 # sfdisk -d /dev/sda # partition table of /dev/sda unit: sectors /dev/sda1 : start= 63, size= 2024127, Id= 6, bootable /dev/sda2 : start= 0, size= 0, Id= 0 /dev/sda3 : start= 0, size= 0, Id= 0 /dev/sda4 : start= 0, size= 0, Id= 0
Tip: if you have a working stick, store your partition layout using ‘sfdisk -d /dev/sda > sfdisk.sda’ for later restore (via ‘sfdisk /dev/sda < sfdisk.sda’). This is also very useful for cloning a working setup to other devices (though you might have to adjust cylinder/units later on). And of course you can use it as backup if you ran [sc]fdisk-commands on the wrong device. ;-)