Lilo booting to flash drive
I've installed Ubuntu on a flash drive and want to be able to multiboot via flash drive(s) from my Slackware lilo.
My concern is that lilo requires a /dev/sd? to boot from for a specified filesystem. I am not sure that where I've plugged in the Ubuntu flash drive will always be identified the same when I boot the system each day. The flash drives are in a hub if that makes any difference. If my belief that the flash drive will change locations at will is correct or if I change the port, how can I set up lilo to compensate? |
Instead of naming the partitions by their location in /dev, name them by UUID. The UUID will never change. To get the UUID of any plugged-in device (no need that mount it first), run "blkid" as root. Example:
Code:
bash-4.2# blkid Code:
root="UUID=DA6F-6836" Code:
boot="UUID=DA6F-6836" See "man lilo.conf" to know more. The same trick can be used in /etc/fstab (but don't use double quotes in that case). |
Mr. Didier Spaier U just saved my bacon!! I will be trying it out this afternoon. THANKS
|
I have boot=/dev/sda in the global section of lilo. Will I need to use UUID for sda there?
|
'boot' indicates to the 'lilo' program the name of the device where it should write the boot sector.
So, for 'boot' you can use any name that the system matches to the good device at time of running lilo. |
LILO really does not care about device names when booting. What it does care about is BIOS device IDs. Normally those are determined by the boot priority order set in the BIOS. To boot from flash you usually have to set that as the first boot device. If not, the BIOS will probably add it as the last boot device and you must press a function key to select it from a BIOS boot menu.
You can divide the LILO boot process into four parts, each with a possibly different disk drive.
Each of these disks is identified at installation time using a Linux device name. However, at boot time LILO identifies the disks using a BIOS ID (0x80, 0x81, 0x82, etc.). The mapping from Linux devices to BIOS IDs is done when you install LILO, not when you boot with LILO. If the BIOS IDs change after you install LILO then the boot process will fail. The boot sector is specified by the "boot=" option in the LILO configuration. This is used for storing the software initially loaded by the BIOS (or chained-to from some other boot loader). The map file contains information about the menu entries and locations (BIOS IDs and sector addresses) of files mentioned in the menu entries. The location of the map file is specified by the "map=" option in the configuration. Usually this is on the same disk with the boot sector. The default is "/boot/map". Each menu entry can specify a Linux kernel to boot. The "image=" option specifies the location of the kernel. The BIOS ID and sector locations for the kernel file are stored in the map. LILO has to be reinstalled if the BIOS ID or the sector locations change. Each menu entry can specify an inital RAM disk image. The "initrd=" option specifies the location of the RAM disk image. The BIOS ID and sector locations for the "initrd" file are stored in the map. LILO has to be reinstalled if the BIOS ID or the sector locations change. The root file-system "root=" is really a kernel parameter. LILO does not care what you specify to the kernel for the root file-system or if that changes. The root file-system is located (by the kernel) at boot time. If you specify a device name it should be the name you expect to be assigned when the kernel is actually booted. Using a UUID for the root files-system kernel parameter allows the kernel to deal with changes in disk device names, but it doesn't help LILO adjust for changes in the BIOS IDs. Most people avoid problems by making sure that all of the things I mentioned are on the first hard disk (0x80). That is usually assigned to the hard disk being booted since it is the first hard disk. When you boot from a flash drive you usually set it as the first boot device and it has BIOS ID 0x80. As long as you put LILO and all the operating systems that it boots on the flash drive there is no problem. You have to override the BIOS ID in "lilo.conf" when creating the flash disk, since the flash disk won't have BIOS ID 0x80 when you are installing LILO to the flash drive. Code:
disk=/dev/sdc All the file paths and device names (except for "root=") should be the locations of the files at the time you will be installing LILO. If you are going to boot from the flash drive and load Linux from other disks you have to tell LILO the BIOS drive IDs that will be assigned to the other disks when LILO is booting (not those assigned when LILO is installed). Code:
disk=/dev/sda When you plug in a flash disk and boot from it, the BIOS usually shifts the other BIOS IDs up, or it swaps the BIOS ID of the flash and the normal first boot disk. That also depends on how you change the boot priority in the BIOS. The first floppy disk has BIOS ID 0x00 and the second floppy disk has BIOS ID 0x01. If you want to use LILO to boot from a CD, you have to make the CD emulate a floppy or hard disk. Hard disk emulation also changes BIOS drive IDs since the emulated hard disk becomes device 0x80. If you are going to boot from multiple hard disks and expect the drive locations to change, GRUB 2 may be the best choice for a boot-loader. GRUB 2 has a "search" function that supports a number of ways to locate files including UUIDs. GRUB 2 also determines the sector locations of files at boot time, not at installation time. GRUB Legacy is a little more flexible than LILO, but it can't adjust menu entries for BIOS ID changes. For GRUB Legacy you have to edit the menu entries (at boot time) if they have the wrong disk IDs. As far as I know you can't create multiple menu entries in LILO with different BIOS IDs for loading the same kernel and initrd files. You can do that in GRUB, though it does make the menu confusing. |
up ph? bác, chúc bác d?t hÃ*ng :d
|
@Didier Spaier: could I impose upon U to show how UR lilo is set up and UR BIOS. I do get a kernel panic when just appending the UUID to /root= for the flash drive with Ubuntu and I think Erik_FL's resonse regarding the BIOS had an impact but would like to work from a known quantity if U can do that, thanks
|
Quote:
Code:
append="rootdelay=15" You could have a look to this thread to if that still doesn't work. |
Lilo booting to flash drive
Thanks again Diedier Uv helped a bunch.
Here is what my BIOS boot sequence looks like: 1st: CD/DVD:Phillips DVD+/-R/W 2nd: IDE-0:WDGWWD8000 3rd: USB RMD-FDD:PNY USB 2.0 FD I seen the warning about putting Flash Disks 1st but I want the CD 1st in case I need to use it to boot in resque mode that way I don't have to opent the box and unplug the internalhard drive. Here is my lilo.conf: Code:
# LILO configuration file Not using initrd. Maybe someone can see my folly, I am unclear regarding vmlinuz use in the Ubuntu section. |
Quote:
Where are you trying to install LILO (on your hard disk or on the flash, or both)? What are you trying to boot from each copy of LILO. For example, are you trying to use LILO on flash to boot Linux on flash? Are you trying to use LILO on the hard disk to boot Linux on flash? Are you trying to use LILO on the flash to boot Linux on the hard disk? Please post your "lilo.conf" for the flash disk and for the hard disk. What can cause a kernel panic?
To install LILO to flash and boot from Linux on the flash drive, you would normally do something like this.
In order for LILO booting from the flash to work for all possible BIOS drive IDs you must make sure that all the files are located on the flash disk, and LILO is installed to the flash disk's boot sector (MBR or one of the partitions on flash). LILO will use a default drive ID 0xFF to access all the files on the same device as the boot sector. The BIOS tells LILO the actual BIOS drive ID when it loads the boot sector, and LILO then uses that BIOS ID to load everything else. Therefore you do not have to specify any BIOS ID in "lilo.conf" as long as LILO, the boot sector, the kernel and initrd are all on the flash. You also don't have to be concerned with which BIOS ID the flash has when it is booted. Specify the flash file-system root to the kernel using a UUID for "root=". Also use the UUID in "/etc/fstab". If you want a copy of LILO on the hard disk to boot from the flash disk, then I recommend installing two copies of LILO. Install one copy of LILO on the hard disk and the other copy on the flash disk. Create a menu entry in the hard disk's "lilo.conf" using "other=" to chain to the boot sector of the flash disk. You will specify the flash disk via the device name or UUID. LILO will save the BIOS ID and boot sector number (0 for MBR) of the flash disk to the boot menu (map file) on the hard disk. The reason for installing two copies of LILO is to keep the sector map file for each copy of LILO on the same disk as the kernel and initrd files that will be loaded by LILO. It also keeps those files on the same disk with the LILO boot sector. That allows each disk to boot its operating systems no matter what BIOS ID it happens to have. The boot sector number doesn't change for the MBR (it is always 0) and for partition boot sectors it only changes if the partition is moved. Chaining between disks using "other=" is much more reliable than depending on the file locations on some other disk to remain the same. What is the purpose of the flash disk? If you are using it as a rescue disk, then it will be useful to re-install LILO on the hard disk, but not for emergency booting from the hard disk. Chaining to the hard disk requires LILO and the map file on the hard disk. If you don't chain to the hard disk then you are depending on the kernel and initrd files not being changed or moved after you create the flash disk. In either case, chances are that you won't be able to boot Linux from the hard disk using the flash disk. To create a disk for emergency booting (from the hard disk) you are better off to use GRUB Legacy or GRUB 2. GRUB won't care if the kernel or initrd files on the hard disk have been moved or updated, providing that they have the same names as before. GRUB also works correctly with soft links such as linking "vmlinuz" to a particular kernel file. LILO always uses the file that WAS linked when LILO was installed, not the file that IS linked when the system is booted. GRUB 2 adds the ability to adapt to changes in BIOS IDs by searching for disks using UUIDs or volume labels. LILO depends on the boot sector and files all being on the same disk in order to adapt to BIOS ID changes. LILO can refer to files on disks other than the boot sector, but then the BIOS IDs of those other disks can't change. |
Well, what you really want to achieve is put the boot-loader on the MBR of your hdd then allow it to boot Ubuntu on your flash drive, right?
If that is correct, your BIOS boot sequence is good enough as th BIOS looks for the boot-loader, not for the OS to boot. (in addition, very often the BIOS gives the possibility to choose the boot medium, e.g. hitting F10, F12, whatever). But as you wrote your lilo.conf, you are telling lilo to boot Ubuntu with Slakware's kernel. I guess that is not what you actually intended. So, do this: (1) Before running lilo, mount your flash drive as /media, (this is an example, any available mount point will do) (2) Edit the image stanza for Ubuntu like this: Code:
image = /media/boot/vmlinuz (3) Run Code:
lilo -t -v Code:
lilo PS2 Didn't see Erik FL's answer before posting. Slow typer I am... PS3 corrected, thanks Erik |
Quote:
|
Quote:
Code:
image = /media/boot/vmlinuz If the flash disk is the second hard disk when installing LILO, then it must be the second hard disk when using the LILO menu entry to boot from flash. Plugging the flash disk into different USB ports probably won't affect the BIOS ID. What may affect the BIOS ID is plugging in other USB hard disks along with the flash disk. |
Quote:
Code:
image = /media/boot/vmlinuz |
All times are GMT -5. The time now is 09:08 PM. |