One-Partition-HINT: Upgrade

Alexander Kloss Klossa at Stud-Mailer.Uni-Marburg.DE
Thu Jan 18 23:34:32 PST 2001


For the guy who made up my Hint to make it manpage-compliant: that's
looking ugly! So I upgraded my version and added the tasklist for using
the initrd feature (next version will have a full explanation of the 2nd
possibility...).

Please someone with proper CVS knowledge: load this up (CVS under Win NT
is a nightmare!).

Have fun!

LX
-------------- next part --------------
TITLE:		One Partition HINT
LFS VERSION:	2.4.3*
AUTHOR:		Alex Kloss (LX) <l.x. at gmx.de>

SYNOPSIS:
	Install LinuxFromScratch using only 1 bootable Linux-
	partition on which is your actual distribution.

HINT:

________________________________________________________________________________

The following text describes the changes you have to make to the normal LFS 
installing procedere when using only 1 bootable partition. It's not complete
without the LFS Book. It is just a description of the things you ought to do
in a different way than declared in the LFS book.
________________________________________________________________________________

*: The Version 2.4.3 of LFS is not really necessary. You can perform the 
   following tricks with any recent LFS Version known to me. The only thing 
   that really depends on the LFS version are the Chapter Names and Numbers.
________________________________________________________________________________

When you come to the part of the LFS Book which is called:

Part II, Paragraph 4
====================

Preparing a new partition

You don't want to create a new partition! That's why you're trying to use this 
hint! Anyway, a size of about 750MB is sufficient for LFS. But instead of using 
fdisk, you simply do (as superuser)

	dd if=/dev/zero of=/tmp/lfs.disk bs=1024 count=768000
________________________________________________________________________________

Command explanations

dd: 

data dump utility - a small utility to read from an input file/device and dump 
the data into an output file.

if=/dev/zero: 

defining /dev/zero as Input file. We don't need nor want any input. The Zero 
device contains as much "0" as we want to read from it.

of=/tmp/lfs.disk: 

we dump about 750MB full of nothing into the Output File called "lfs.disk" in 
the directory /tmp. It's not necessary to call it like that. You can even put 
it into any directory you got read/write-rights for. But if you call it other-
wise, you'll better remind to change this filename within the later 
instructions.

bs=1024: 

Blocksize is set to 1k Bytes.

count=768000: 

750 x 1024 = 768000. And that often, dd dumps blocks of 1024 zeros into our 
output file. If you want any other size, you have to change the count value.
________________________________________________________________________________

Creating a ext2 file system on the new partition

We don't have a new partition. But we have our file "lfs.disk" (or whatever you 
called it. So instead of creating the file system on a partition, we're using 
the command on our file:

	yes "y" | mke2fs /tmp/lfs.disk

________________________________________________________________________________

Command explanations

yes "y" |: 

we're using the "yes" utility to answer yes to the question of mke2fs, wether 
really to make an file system on a file that's not a block device (which is what
we intend to do).

mke2fs /tmp/lfs.disk: 

creating an ext2 file system into the file lfs.disk instead of an block device 
(like e.g. /dev/hda1).
________________________________________________________________________________

Mounting the new partition

We don't have a partition to mount. But we've got a file. Mounting a file goes
via the so-called "loop device". Now it is vitally important to check your 
actual kernel configuration for having the "CONFIG_BLK_DEV_LOOP" (Block Devices
-> Loop Device in "make [x|menu]config"). You can also do this through the 
command

	cat /usr/src/linux/.config | grep CONFIG_BLK_DEV_LOOP

If it says something like "CONFIG_BLK_DEV_LOOP=m" or "CONFIG_BLK_DEV_LOOP=y", 
then everything is fine and you can skip the next few steps. If it says some-
thing like "# CONFIG_BLK_DEV_LOOP is not set" then you have to compile a module
enabling the usage of loop devices for your kernel. That's

	sed s/\#\ CONFIG_BLK_DEV_LOOP\ is\ not\ set/CONFIG_BLK_DEV_LOOP=m/ \
        /usr/src/linux/.config > conf && mv conf /usr/src/linux/.config &&
        cd /usr/src/linux && make modules modules_install && insmod loop

Now that you've enabled the usage of loop devices in your kernel, you can get 
on mounting the lfs.disk file:

	mount /tmp/lfs.disk /mnt/lfs -o loop
        
________________________________________________________________________________

Command explanations

cat /usr/src/linux/.config: 

writes the kernel configuration to the standard output.

| grep CONFIG_BLK_DEV_LOOP: 

searches the output for the loop-device-option.

sed...: 

replaces the "is not set" instruction with the instruction for making a module
to use the loop device. For further explanation, please read the LFS book.

insmod loop: 

loading the module for mounting loop devices

mount lfs.disk /mnt/lfs -o loop: 

mounting the disk image file to the directory /mnt/lfs using the loop device 
driver (-o loop).
________________________________________________________________________________

The following steps are quite the same. The only differences starts again when 
you want to make this drive bootable:

Part II, Chapter 8
==================

Making the LFS System bootable.

Make your kernel and /etc/lilo.conf in the chroot'ed environment as described 
in the LFS book. Don't try to start lilo now! Stop here!

The only bootable partition you've got is the one your current distro is 
running on. The next steps depend on what you want (and here are different
opinions):

1. You can install only LFS on the partition, deleting the distro. That's what
I did and what I'll do again in this cases. It's the easy way. I don't see why
anyone could want to keep the distro. Using the other Hints, you can easily
expand your LFS to whatever you want to do with it. BUT:

2. A friendly reader of the mailinglist reminded me that there are people with
reasons for keeping the running distribution on their harddisk (without giving
some, though...) Anyway, as a tolerant guy I'm working on a way to boot-up LFS 
without being written to a partition. 

Another reason for the 2. possibility could be the wish for a bootable LFS 
System on a CD-R - very useful for turning Systems without Linux installed to 
LFS-running, friendly machines. Let's wait anxiously for a complete ALFS..

Before you chose, let me remind, that the 2. possibility requires more work and
causes a loss of speed to any disk-input/output-Operations due to the usage of 
the loop-device.
________________________________________________________________________________

WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING!
________________________________________________________________________________

I'm not certain about these steps yet. I'll try them if I find the time. I'd be 
glad if I get help from anyone. So these are no instructions, but basically my 
ideas what has to happen next...
________________________________________________________________________________

WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING-WARNING!
________________________________________________________________________________

You've chosen the 1. possibility?

Mount the main partition to "/mnt" in the chroot'ed environment suggesting your 
main partition is /dev/hda1, otherwise fill in what is necessary:

	mount /dev/hda1 /mnt

You'll have to get the main partition entirely clean from everything that is not
/tmp/lfs.disk.

	for dirname in `ls /mnt | sed s/tmp//`; do rm -r $dirname; done &&
	for filename in `ls /mnt/tmp | sed s/lfs.disk//`; do rm $filename; done

Now it's clean for copying the LFS system. Everything but the /mnt directory,
to which the device that we are filling with LFS is mounted and the directory
/proc, in which are dynamic files written by the kernel.

	for dirname in `ls / | sed s/mnt// | sed s/proc//`; do 
	cp -a $dirname /mnt; done

Now the LFS is on your primary partition logout of the chroot'ed environment 
into the new system. Now you can perform lilo and this stuff.
________________________________________________________________________________

Hints:

It is possible that you have to change into single user system not to hang up 
the other ttyS running on your distro's files. If your system hangs up because 
I forgot these, boot up with a bootdisk (if you don't have one and obeyed blind:
bad luck! And now get one) into single user mode and then perform the lilo step.
________________________________________________________________________________

You've chosen the 2. possibility? 

This part isn't written yet! Tasks to do:

- Make a lfs.initrd file (like the lfs.disk file, but only about 32MB maximum)
  with only the files necessary for bootup! For that you can keep a static bash
  and some of the real necessary tools.
  (Source: /usr/src/linux/Documentation/initrd.txt)

- Design bootscripts in this initrd so the /dev/hda1/tmp/lfs.disk is somehow
  mounted to /. This script has to mount /dev/hda1 to some unused directory and
  then perform the steps to mount the lfs.disk as loop device.

- Install lilo for usage with this lfs.initrd file.

Then you can get back to the book.

Good luck!
________________________________________________________________________________

Alex (LX) - hope to meet you at irc.linuxfromscratch.org


More information about the lfs-dev mailing list