LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 01-22-2022, 04:31 AM   #1
atinker
LQ Newbie
 
Registered: Jan 2022
Posts: 2

Rep: Reputation: 0
How to install LILO on file/disk image?


Hi,

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

Code:
boot=/dev/loop18
map=/mnt/custom-os/boot/map
install=/mnt/custom-os/boot/boot.b
prompt
timeout=100
lba32

image=/mnt/custom-os/boot/bzImage
    label=linux
    root=/dev/sda2
    read-only
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?
 
Old 01-22-2022, 11:08 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Why old LILO and not Grub?
 
Old 01-23-2022, 03:18 PM   #3
atinker
LQ Newbie
 
Registered: Jan 2022
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sundialsvcs View Post
Why old LILO and not Grub?
I'm trying to create an image that's as small as possible, and LILO would save me about 10 MB.
 
Old 01-23-2022, 03:56 PM   #4
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
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:

https://tldp.org/HOWTO/LILO-2.

Last edited by jailbait; 01-23-2022 at 04:00 PM.
 
1 members found this post helpful.
Old 01-24-2022, 04:47 AM   #5
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,490

Rep: Reputation: Disabled
Another method would be syslinux/isolinux possibly.
 
1 members found this post helpful.
Old 01-24-2022, 07:28 AM   #6
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
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
 
Old 01-24-2022, 06:10 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

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

For example: https://www.varesano.net/converting-...-lilo-to-grub/ ... the Internet is chock-full of HOWTOs on this topic.

Last edited by sundialsvcs; 01-24-2022 at 06:15 PM.
 
Old 01-25-2022, 12:54 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by fatmac View Post
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.
 
Old 01-25-2022, 10:46 AM   #9
enorbet
Senior Member
 
Registered: Jun 2003
Location: Virginia
Distribution: Slackware = Main OpSys
Posts: 4,784

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


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Slackpkg_current kernel + 5.x kernel + win10 in LILO, Bonus change Lilo boot bitmap image Scribtor Slackware 33 11-12-2019 10:17 AM
[SOLVED] Slackware 14.1 32bit system tarball/stage3 image/chroot image/bootstrap image vinipsmaker Slackware 20 05-14-2014 01:41 AM
[SOLVED] Lilo install mbr to other disk as root disk. whizje Linux - Software 3 06-07-2012 08:16 AM
[SOLVED] Edit lilo.conf, run /sbin/lilo, but lilo won't take changes lukameen Slackware 2 02-10-2012 12:10 PM
Lilo lost, Install disk failing to restore Lilo on dual boot? Dobie Linux - Newbie 2 05-05-2004 05:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:04 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration