Luke Vear wrote:
> Hey guys,
>  
> I have successfully made an LFS 6.2 and BLFS 6.2.0 and now i was 
> wondering if there is a way to turn this into a live cd. I have herd 
> of Linux-Live and there are .txt's on the LFS website, but they 
> changed all of my dir's and files into CAPS, so it wouldn't boot. If 
> there is a tutorial or some scripts that can turn my BLFS system into 
> a live cd, PLEASE can you post the links on here.

Unfortunately, currently there are no working hints on this.

Below is the description of the procedure that is used for the official 
LiveCD 6.3 r2130. It may or may not work with LFS-6.2. You (not even 
myself!) will be the first to perform it manually (read: I didn't check 
what is written below), and there are no guarantees that it works at 
all. Since the guide below doesn't touch upon hardware detection at all, 
this CD will work on your computer only. If this disclaimer doesn't stop 
you from following the instructions, please send the more detailed 
version when you fill in the gaps and correct the typos below - and I 
will send the version with proper hardware detection and other things 
that make the CD work everywhere.

You will need to install some additional packages: cpio (see BLFS), 
device-mapper (ftp://sources.redhat.com/pub/dm/), zisofs-tools 
(http://www.kernel.org/pub/linux/utils/fs/zisofs/), eject 
(http://www.ibiblio.org/pub/Linux/utils/disk-management/). All non-BLFS 
packages are built with "./configure --prefix=/usr && make && make 
install", except "eject", which needs "autoreconf --force --install 
--verbose" before this.

Your kernel needs to support loop devices, device-mapper snapshot 
target, ext2 filesystem, and transparent ISO compression:

CONFIG_BLK_DEV_LOOP=y
CONFIG_MD=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_SNAPSHOT=y
CONFIG_EXT2_FS=y or m
CONFIG_ISO9660_FS=y or m
CONFIG_ZISOFS=y

For a good start, use 
http://wiki.linuxfromscratch.org/livecd/browser/trunk/packages/linux/config.x86?rev=2130&format=raw
 
(but this applies to a patched kernel, so please "make oldconfig")

We won't turn your existing system into a LiveCD. Instead, we'll use a 
copy that can be easily thrown away if anything goes wrong.

First, create a root.ext2 file containing an empty ext2 filesystem. The 
size of this file for the official LFS LiveCD is 1.5 GB, but your system 
may be bigger (replace 1536 with a bigger number below then).

mkdir /mnt/work
dd if=/dev/null of=/mnt/work/root.ext2 bs=1M seek=1536
mke2fs /mnt/work/root.ext2

Then we'll loop-mount it.

mkdir /mnt/work/image
mount -o loop /mnt/work/root.ext2 /mnt/work/image

Then, copy your system into /mnt/work/image, excluding /dev, /proc, /sys 
and /home. Create these empty directories, though.

The Official LFS LiveCD cheats a bit and doesn't mount tmpfs on /dev 
(udev works on ext2). This means that some devices have to be created 
manually:

MP=/mnt/work/image
mknod -m 600 $MP/dev/console c 5 1
mknod -m 666 $MP/dev/null c 1 3
mknod -m 666 $MP/dev/zero c 1 5
mknod -m 666 $MP/dev/ptmx c 5 2
mknod -m 666 $MP/dev/tty c 5 0
mknod -m 444 $MP/dev/random c 1 8
mknod -m 444 $MP/dev/urandom c 1 9
ln -s /proc/self/fd $MP/dev/fd
ln -s /proc/self/fd/0 $MP/dev/stdin
ln -s /proc/self/fd/1 $MP/dev/stdout
ln -s /proc/self/fd/2 $MP/dev/stderr
ln -s /proc/kcore $MP/dev/core

After this, run "chroot /mnt/work/image" to enter the copy of your system.

Add the following line to /etc/inittab:

sd:06:once:/usr/bin/shutdown-helper

Save this script as /usr/bin/shutdown-helper, replace the string 
"@LINKER@" with "ld-linux.so.2", chmod it to 0755: 
http://wiki.linuxfromscratch.org/livecd/browser/trunk/scripts/shutdown-helper.in?rev=2130&format=raw

Since on the CD the tmpfs is mounted on /dev/shm by the initramfs, it 
has to be removed from /etc/fstab.

Reinstall LFS-Bootscripts with this patch: 
http://wiki.linuxfromscratch.org/livecd/browser/trunk/packages/lfs-bootscripts/lfs-bootscripts-livecd-1.patch?rev=2030&format=raw
 
(use "make install-livecd" instead of "make install", and be sure to 
remove old bootscripts, including "reboot" and "shutdown")

Download the following files:

http://wiki.linuxfromscratch.org/livecd/browser/trunk/packages/initramfs/create-initramfs.in?rev=2130&format=raw
http://wiki.linuxfromscratch.org/livecd/browser/trunk/packages/initramfs/fakecd.iso.head?rev=2130&format=raw
http://wiki.linuxfromscratch.org/livecd/browser/trunk/packages/initramfs/init.in?rev=2130&format=raw

Edit all *.in files by replacing "@LINKER@" with "ld-linux.so.2". Store 
"init.in" and "fakecd.iso.head" in /usr/share/initramfs, and 
"create-initramfs" in /usr/bin (with 0755 permissions).

For your kernel version (assuming 2.6.22.5 below), run:

create-initramfs "my-unofficial" "2.6.22.5" initramfs_data.cpio.gz

Sorry if "no such file" errors appear - this script is designed to work 
only with fully modular kernels, which are not currently supported by 
LFS. You may thus need to adjust the list of directories to look for 
modules in this script.

This will produce the initramfs_data.cpio.gz file that looks for the CD 
with the label "lfslivecd-my-unofficial". If you change the 
"my-unofficial" string, be sure to also change it in the "mkisofs" 
command below.

This initramfs is designed to find the CD by its label, set up the 
device mapper so that the /dev/mapper/lfs-cd device contains the same 
bytes as root.ext2 (but with the possibility to write into it), and 
mount /dev/mapper/lfs-cd as a root device.

Now exit the chroot, copy the initramfs_data.cpio.gz file and the kernel 
image out of the chroot. Unmount the root.ext2 file:

umount /mnt/work/image

Now, create the /mnt/work/iso/boot/isolinux directory and put the kernel 
image (renamed to "linux") and this initramfs_data.cpio.gz file there. 
Also, create the isolinux.cfg file there with the following contents:

default linux
prompt 1
timeout 600

label linux
  kernel linux
  append initrd=initramfs_data_cpio.gz

Note that the underscore before the "cpio" is not a typo. It refers to a 
non-rock-ridge name of this file.

Download syslinux from 
http://www.kernel.org/pub/linux/utils/boot/syslinux/ , extract the 
tarball, find the isolinux.bin file there, put it into the 
/mnt/work/iso/boot/isolinux directory.

Then, compress the root.ext2 file:

mkzftree -F /mnt/work/root.ext2 /mnt/work/iso/root.ext2

As a result, you'll have:

/mnt/work/iso/root.ext2 (compressed root fs image)
/mnt/work/iso/boot/isolinux/linux (the kernel)
/mnt/work/iso/boot/isolinux/initramfs_data.cpio.gz (the initramfs)
/mnt/work/iso/boot/isolinux/isolinux.cfg (boot loader configuration)
/mnt/work/iso/boot/isolinux/isolinux.bin (isolinux boot loader)

Then create the iso image of your own LiveCD:

cd /mnt/work/iso
mkisofs -z -R -l --allow-leading-dots -D -o ../lfslivecd-my-unofficial.iso \
    -b boot/isolinux/isolinux.bin \
    -c boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \
    -V "lfslivecd-my-unofficial" ./

Then burn and test the iso.

-- 
Alexander E. Patrakov
-- 
http://linuxfromscratch.org/mailman/listinfo/livecd
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to