Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to install LILO to my a disk image I've created. I've managed to install GRUB this way and boot the system up, but I can't seem to get it right with LILO.
First of all, I've created my disk image like this:
Code:
# 100 MB
SECTORS=204800
SECTOR_SIZE=512
dd if=/dev/zero of=fs.img seek=$((SECTORS - 1)) bs=$SECTOR_SIZE count=1
fdisk -u fs.img <<EOF
o
n
p
1
+30M
n
p
2
a
1
w
EOF
LODEV=$(losetup --find --show -P fs.img)
mkfs.ext4 ${LODEV}p1
mkfs.ext4 ${LODEV}p2
mount ${LODEV}p2 /mnt/custom-os
mkdir /mnt/custom-os/boot
mount ${LODEV}p1 /mnt/custom-os/boot
I then copy my compiled kernel and libs to the mounted partition. Now it's time to install LILO, so I create a lilo.conf with the following content (the loop device is /dev/loop18 in this example):
Now that everything's set up, I want to install LILO. I use the -t flag for a dry run:
Code:
$ lilo -t -v3 -C lilo.conf
LILO version 24.2 (test mode)
* Copyright (C) 1992-1998 Werner Almesberger (until v20)
* Copyright (C) 1999-2007 John Coffman (until v22)
* Copyright (C) 2009-2015 Joachim Wiedorn (since v23)
This program comes with ABSOLUTELY NO WARRANTY. This is free software
distributed under the BSD License (3-clause). Details can be found in
the file COPYING, which is distributed with this software.
Running Linux kernel 5.4.0-96-generic on x86_64
device-mapper major = 253
raid_setup returns offset = 00000000 ndisk = 0
BIOS VolumeID Device
Reading boot sector from /dev/loop18
Fatal: Sorry, don't know how to handle device 0x0712
No matter what I try, I always end up with the error Sorry, don't know how to handle device <number>. I've tried specifying the disk head, sectors and cylinders using the output from fdisk -l -u=cylinders fs.img after reading about the error in the LILO README, but that still gives me the exact same error.
As I said, I've done this without any problems using GRUB. What am I doing wrong that prevents me from installing LILO to the image?
Its been over 15 years since I worked with LILO but here goes anyway. One of the restrictions with LILO is that it uses the BIOS for the initial disk read. The boot code must be within range of the fairly restricted BIOS read range. Therefore the /boot directory must be located within the first partition and to make sure that the BIOS can reach /boot you should make the first partition fairly small. Also since my LILO days secure boot has reared its ugly head. I solve all of the secure boot problems by disabling secure boot in my BIOS. That will probably also work for your problems with LILO being confused about what partitions exist and where they are. Also unlike GRUB you have to reinstall LILO whenever you move your boot code on your hard drive.
Here is a link to some documentation that is more up to date than my memory:
Short answer - I do not think that LILO can be made to work with a loop mounted image. It will only work on real hardware.
Longer answer - This is list of what I tried manually.
Code:
dd if=/dev/zero of=fs.img bs=512 count=204800
fdisk fs.img # I just created one partition. fdisk automatically leaves an area for a DOS partition table
losetup --find --show -P fs.img # returned /dev/loop0
mkfs.ext4 /dev/loop0p1
mount /dev/loop0p1 /mnt/hd
mkdir /mnt/hd/boot
cp /boot/sda14/* /mnt/hd/boot # copied Slackware installer boot files (kernel and initrd)
mkdir /mnt/hd/etc
cp /etc/lilo.conf /mnt/hd/etc/ # copied a lilo.conf file then edited to suit
# The following commands are sufficient to reinstall LILO on a device mounted on /mnt/hd
mkdir /mnt/hd/dev
mkdir /mnt/hd/proc
mkdir /mnt/hd/sys
mount -o bind /dev /mnt/hd/dev
mount -o bind /proc /mnt/hd/proc
mount -o bind /sys /mnt/hd/sys
lilo -r /mnt/hd -t
This then threw an error
Quote:
Fatal: geo_query_dev HDIO_GETGEO (dev 0x10300): Inappropriate ioctl for device
I interpret that as LILO not being able to fully access the device.
It might be possible to build the image, dump it onto a real device (e.g. USB key), run LILO on that and then recover the resulting image on the USB key. I would strongly recommend looking into using LILO with persistent device naming
Reading this thread, my unequivocal recommendation is simply: "find a way to switch this thing to Grub." I don't think much about LILO anymore – to me, it has simply been superseded, this of course being "the way of all things software." Your objective is "to start-up this computer," and there is a much better way to do that now.
Another method would be syslinux/isolinux possibly.
This.
Installed size on my computer ~4MB, however most of these files are not required. If you know what you're doing I'm sure you could wittle that down to less than 100k.
A case can be made that for simple bootloading, especially on a Legacy MBR system which this must be or we would be considering elilo, Grub2 is overly complex and arcane for such a simple job. Really it comes down to personal familiarity and preference. That said in this case where a simple means to boot from an image is involved, which optionally could add whatever bootloader one desires after, syslinux/isolinux is demonstrably the most universal, smallest and least complex choice. Given those factors seem to matter in this specific case, it really must be explored. There is good reason lilo is rarely if ever chosen for image tasks and it isn't because it's old. It's about it's strict requirements that syslinux does not suffer from especially in an image environment.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.