LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 03-12-2013, 01:39 AM   #1
waddles
Member
 
Registered: Sep 2012
Posts: 373

Rep: Reputation: 0
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?

Last edited by waddles; 03-12-2013 at 01:40 AM.
 
Old 03-12-2013, 04:04 AM   #2
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,244

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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
/dev/sda1: LABEL="RM-CM-)servM-CM-) au systM-CM-(me" UUID="9A185F24185EFF27" TYPE="ntfs" 
/dev/sda2: UUID="78D46329D462E938" TYPE="ntfs" 
/dev/sda3: UUID="56d1b80a-c999-496a-b906-a13221e7890e" TYPE="ext4" 
/dev/sda5: UUID="9e347301-ab42-41d0-a18a-b5ceae4a9aa6" TYPE="ext4" 
/dev/sda6: UUID="91468297-85c1-4151-a1e8-1d04188d002d" TYPE="swap" 
/dev/sdc: SEC_TYPE="msdos" LABEL="USBSLACK" UUID="22AB-0D75" TYPE="vfat" 
/dev/sdb1: UUID="DA6F-6836" TYPE="vfat" 
bash-4.2#
Then I can use that information to set "root" and "boot" options in lilo.conf same way. Let's suppose I want to use my USB key identified as /dev/sdb1 at this time, I could write:
Code:
root="UUID=DA6F-6836"
and/or
Code:
boot="UUID=DA6F-6836"
Please note that the double quotes are not in the same place as in blkid's output.

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).

Last edited by Didier Spaier; 03-12-2013 at 04:05 AM.
 
1 members found this post helpful.
Old 03-12-2013, 12:32 PM   #3
waddles
Member
 
Registered: Sep 2012
Posts: 373

Original Poster
Rep: Reputation: 0
Mr. Didier Spaier U just saved my bacon!! I will be trying it out this afternoon. THANKS
 
Old 03-12-2013, 01:01 PM   #4
waddles
Member
 
Registered: Sep 2012
Posts: 373

Original Poster
Rep: Reputation: 0
I have boot=/dev/sda in the global section of lilo. Will I need to use UUID for sda there?
 
Old 03-12-2013, 05:04 PM   #5
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,244

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
'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.

Last edited by Didier Spaier; 03-12-2013 at 05:07 PM.
 
Old 03-13-2013, 12:40 AM   #6
Erik_FL
Member
 
Registered: Sep 2005
Location: Boynton Beach, FL
Distribution: Slackware
Posts: 797

Rep: Reputation: 247Reputation: 247Reputation: 247
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.
  1. Boot Sector
  2. Map File
  3. Kernel file
  4. initrd file

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
     bios=0x80
boot=/dev/sdc
map=/mnt/flash/boot/map
Note that the BIOS ID is not used to access the disk when installing LILO. It is only stored for LILO to use later when booting. The above example assumes that the flash is device "/dev/sdc" when you are installing LILO. You also need to specify the location for the map file so that it is stored on the flash disk.

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
     bios=0x81
disk=/dev/sdb
     bios=0x82
disk=/dev/sdc
     bios=0x80
In the above example, I assumed that the flash disk will become the first hard disk, and the other two disks will become the second and third hard disks. How can you know the BIOS IDs for other disks besides the boot disk? Unfortunately there is no standard. Most BIOS software seems to assign BIOS IDs in the boot priority order of the hard disks. So, to make a disk have BIOS ID 0x81 you would make it the second disk listed in the boot order. We are talking about hard disks here, and not partitions. For example, "/dev/sda1" and "/dev/sda2" are both on the same disk, while "/dev/sda1" and "/dev/sdb1" are on different disks.

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.

Last edited by Erik_FL; 03-13-2013 at 12:48 AM.
 
Old 03-13-2013, 12:56 AM   #7
hieu.hap
LQ Newbie
 
Registered: Mar 2013
Posts: 3

Rep: Reputation: Disabled
up ph? bác, chúc bác d?t h*ng :d
 
Old 03-13-2013, 05:59 AM   #8
waddles
Member
 
Registered: Sep 2012
Posts: 373

Original Poster
Rep: Reputation: 0
@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
 
Old 03-13-2013, 07:04 AM   #9
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,244

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by waddles View Post
@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
I dont think that would help you, as I don't boot fro an USB device now. But instead try adding following line in the image section for your flash drive in your /etc.lilo.conf:
Code:
append="rootdelay=15"
do give enough time to the flash drive to sync before accessing to it.

You could have a look to this thread to if that still doesn't work.
 
Old 03-13-2013, 02:07 PM   #10
waddles
Member
 
Registered: Sep 2012
Posts: 373

Original Poster
Rep: Reputation: 0
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
# generated by 'liloconfig'
#
# Start LILO global section
# Append any additional kernel parameters:
append=" vt.default_utf8=0 enable_mtrr_cleanup mtrr_spare_reg_nr=1"
boot = /dev/sda

# Boot BMP Image.
# Bitmap in BMP format: 640x480x8
  bitmap = /boot/slack.bmp
# Menu colors (foreground, background, shadow, highlighted
# foreground, highlighted background, highlighted shadow):
  bmp-colors = 255,0,255,0,255,0
# Location of the option table: location x, location y, number of
# columns, lines per column (max 15), "spill" (this is how many
# entries must be in the first column before the next begins to
# be used.  We don't specify it here, as there's just one column.
  bmp-table = 60,6,1,16
# Timer location x, timer location y, foreground color,
# background color, shadow color.
  bmp-timer = 65,27,0,255

# Standard menu.
# Or, you can comment out the bitmap menu above and 
# use a boot message with the standard menu:
#message = /boot/boot_message.txt

# Wait until the timeout to boot (if commented out, boot the
# first entry immediately):
prompt
# Timeout before the first entry boots.
# This is given in tenths of a second, so 600 for every minute:
timeout = 1200
# Override dangerous defaults that rewrite the partition table:
change-rules
  reset
# Normal VGA console
vga = normal
# Ask for video mode at boot (time out to normal in 30s)
#vga = ask
# VESA framebuffer console @ 1024x768x64k
#vga=791
...
# End LILO global section
# Slackware bootable partition config begins
image = /boot/vmlinuz
  root = /dev/sda1
  label = Slackware
  read-only
# Slackware bootable partition config ends
#
# Ubuntu bootable partition config begins
image = /boot/vmlinuz
  root = "UUID=6E98-297F"
  append="rootdelay=20"
  label = Ubuntu
  read-only
# Ubuntu bootable partition config ends
#
# Mint bootable partition config begins
#image = /boot/vmlinuz
#  root = "UUID=C0D2-2F59"
#  append="rootdelay=20"
#  label = Mint
#  read-only
# Mint bootable partition config ends
Still getting the Kernel Panic when booting to the Ubunto drive.
Not using initrd.
Maybe someone can see my folly, I am unclear regarding vmlinuz use in the Ubuntu section.

Last edited by waddles; 03-13-2013 at 02:10 PM.
 
Old 03-13-2013, 03:28 PM   #11
Erik_FL
Member
 
Registered: Sep 2005
Location: Boynton Beach, FL
Distribution: Slackware
Posts: 797

Rep: Reputation: 247Reputation: 247Reputation: 247
Quote:
Originally Posted by waddles View Post
@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
Perhaps you can be a little more specific about what you are trying to do.

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?
  • The kernel or initrd files were moved or changed after you installed LILO (hang or crash)
  • LILO is loading the kernel or initrd from the wrong disk drive (usually causes hang)
  • The "root=" kernel parameter is incorrect (unable to mount root file-system)
  • The kernel driver for the root file-system device has a bug or is incorrect for the hardware
  • You have some other problem such as the wrong kernel, bad RAM or wrong kernel configuration

To install LILO to flash and boot from Linux on the flash drive, you would normally do something like this.
  • Partition the flash (fdisk or cfdisk)
    Some computers will only boot from a flash disk if it contains multiple partitions!
    Windows will only see the first partition if the flash disk (hardware) has the removable bit set!
  • Create the flash file-system with "mkfs"
  • Mount the flash file-system
  • Copy or install the Linux system files, modules, kernel image and initrd to flash
  • Use the "chroot" command to change the root to the flash file-system
  • Create or edit "lilo.conf"
  • Use the "lilo" command to install LILO to the flash
  • Exit from the shell to return to the normal root file-system
  • Un-mount the flash drive
  • Test the flash drive booting

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.
 
Old 03-13-2013, 03:46 PM   #12
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,244

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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
Of course if Ububtu's kernel is not named vmlinuz or is not in /boot, adapt accordingly.
(3) Run
Code:
lilo -t -v
And if all seems well:
Code:
lilo
PS don't be confused by the thread I linked to previously, it's not you use case.

PS2 Didn't see Erik FL's answer before posting. Slow typer I am...

PS3 corrected, thanks Erik

Last edited by Didier Spaier; 03-13-2013 at 06:00 PM. Reason: s/boot=/image =/
 
Old 03-13-2013, 04:04 PM   #13
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 158

Rep: Reputation: 21
Quote:
Originally Posted by waddles View Post
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.

<snip>
Just a comment on the bit in bold. Most hardware has an option where you can hit a key during the BIOS startup that will allow you to do a one-time change to the boot order. On my Lenovo T61p, it's <F12>. I don't know whether this causes the BIOS to renumber the drives or not, but it allows you to avoid things like opening the box while keeping th HDD as the primary boot device. I'm willing to bet if you looked up some documentation on your hardware/BIOS you'd find something similar. And if such a one-time over-ride doesn't change the BIOS numbering then you might be close to home free (at least as long as you don't have multiple USB keys plugged in or that kind of craziness).
 
Old 03-13-2013, 05:51 PM   #14
Erik_FL
Member
 
Registered: Sep 2005
Location: Boynton Beach, FL
Distribution: Slackware
Posts: 797

Rep: Reputation: 247Reputation: 247Reputation: 247
Quote:
Originally Posted by Didier Spaier View Post
(2) Edit the image stanza for Ubuntu like this:
Code:
 boot = /media/boot/vmlinuz
Of course if Ububtu's kernel is not named vmlinuz or is not in /boot, adapt accordingly.
I think that you meant this when you referred to changing the image stanza.
Code:
image = /media/boot/vmlinuz
The above will work, but will require that the sector locations for the "vmlinuz" file on the flash do not change after installing LILO. If any changes are made to the kernel on the flash disk, then LILO must be reinstalled on the hard disk.

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.
 
Old 03-13-2013, 05:58 PM   #15
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,244

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by Erik_FL View Post
I think that you meant this when you referred to changing the image stanza.
Code:
image = /media/boot/vmlinuz
Yes, thank you Erik. I know I should re-read before posting, though
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing to one drive and booting from another - lilo? fogpipe Linux - Newbie 4 03-12-2011 03:58 PM
Booting Flash Drive with a CD? Maybe? metalx1000 Linux - General 1 05-22-2007 08:51 AM
install lilo/grub on a USB flash drive? flystar06 Linux - General 3 06-14-2005 08:48 PM
Boot From USB Flash Drive in LILO? clearestchannel Linux - Newbie 1 01-01-2005 08:38 AM
lilo not booting my SATA winxp drive thrice Slackware 5 10-15-2004 02:02 AM


All times are GMT -5. The time now is 09:30 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration