1 AUTHOR: Alexander E. Patrakov <patrakov at ums.usu.ru>, Sylvie Migneault <alisou at alixe.org>
5 LICENSE: GNU Free Documentation License Version 1.2
7 SYNOPSIS: lfscd-remastering-HOWTO, for LFS LiveCD version 6.2-x
9 DESCRIPTION: This is a guide that will show you how to remaster LFS liveCD-x86-6.2-x
11 PREREQUISITES: LFS LiveCD 6.2-x.
13 For LFS LiveCD 6.1-x, see the old "lfscd-remastering-howto-6.1.txt" hint by
14 Sylvie Migneault. For LFS LiveCD 6.1.1-x, the old hint should work if one
15 globally replaces LFS_CD with lfslivecd-VERSION, e.g. lfslivecd-x86-6.1.1-3
21 * Any Linux system with loop device, CD-ROM and ISO9660 filesystem support.
22 * 3 GB of free hard disk space on one partition.
24 This hint uses the $WORK environment variable as a name of a directory on that
26 export WORK=/mnt/lfslivecd
28 The LiveCD uses the ISO9660 filesystem with Linux-specific transparent
29 decompression extension. On that filesystem, there are the following files:
34 The boot directory contains the Linux kernel, the initramfs image and the
35 bootloader. The actual root filesystem (ext2) is in the root.ext2 file.
37 In order to remaster the CD, you have to install the following packages:
43 Download from http://www.kernel.org/pub/linux/utils/fs/zisofs/
44 Build with ./configure --prefix=/usr && make && make install
49 Look at the root.ext2 file size:
50 ls -l /media/cdrom/root.ext2
52 If it is approximately 1.5 GB, the kernel uncompresses the CD for you. In
53 this case, you can copy the file to your hard disk as usual:
54 cp /media/cdrom/root.ext2 $WORK/root.ext2
56 If it is only 500 MB, you have to rebuild your kernel with ZISOFS support, or
57 uncompress this file manually:
58 mkzftree -u -F /media/cdrom/root.ext2 $WORK/root.ext2
60 In either case, you end up with a $WORK/root.ext2 file that is 1.5 GB in size.
62 This may or may not be sufficient for your remastered CD (or DVD) filesystem.
63 If you want, you can resize the file with the resize2fs program from e2fsprogs
64 version >= 1.39. Earlier versions of e2fsprogs cannot resize filesystem images
67 Mounting the filesystem image is achieved with a loop device:
70 mount -o loop $WORK/root.ext2 $WORK/root
72 It is a good idea to create and bind-mount a temporary directory, in order to
73 preserve as many zeroed sectors as possible:
75 mkdir $WORK/build $WORK/root/build
76 mount --bind $WORK/build $WORK/root/build
78 Mount other directories necessary for chrooting:
79 mount -t proc proc $WORK/root/proc
80 mount -t sysfs sysfs $WORK/root/sys
81 mount -t devpts devpts $WORK/root/dev/pts
82 mount -t tmpfs tmpfs $WORK/root/dev/shm
84 Note: contrary to the instructions in the LFS book, tmpfs is not mounted on
85 $WORK/root/dev. This is because all the necessary devices are already created
88 Chroot to the filesystem:
91 In the chroot, change the current directory to /build, and install any
92 additional packages you want. Modify other files as necessary.
94 Get the initramfs files as a zip archive from
95 http://wiki.linuxfromscratch.org/livecd/browser/tags/6.2-3/packages/initramfs
97 Unzip the archive. Remove the "include $(ROOT)/scripts/functions" line from the
98 Makefile. Generate the initramfs image for your CD:
99 make compile-stage2 VERSION="x86-6.2-custom"
101 (you can replace the "x86-6.2-custom" with your own string). This produces the
102 initramfs_data.cpio.gz file in the current directory. If this directory is not
103 "/build", copy it to /build:
104 cp initramfs_data.cpio.gz /build
106 Exit from the chroot and clean up the mounts:
108 umount $WORK/root/dev/shm
109 umount $WORK/root/dev/pts
110 umount $WORK/root/sys
111 umount $WORK/root/proc
112 umount $WORK/root/build
113 rmdir $WORK/root/build
115 Clean up bash history:
116 rm $WORK/root/root/.bash_history
118 You may also want to remove other history files.
120 If you, by mistake, created and removed some files, the sectors previously
121 occupied by those files begin to contain non-zero data. Such sectors are
122 useless, but they don't compress well. Zero them out:
123 dd if=/dev/zero of=$WORK/root/zeroes
125 This command will print a message that the disk is full. This is not an error.
126 Then, remove the file that fills the filesystem:
129 Now you can unmount the root.ext2 file:
133 The "sync" command is needed due to a bug in the loop driver in some kernels
134 that leads to a filesystem with errors otherwise.
136 Now make the directory structure for your LiveCD:
139 Copy the boot directory from the original LiveCD:
140 cp -r /media/cdrom/boot $WORK/iso
142 Replace the stock initramfs image with your own:
143 cp $WORK/build/initramfs_data.cpio.gz \
144 $WORK/iso/boot/isolinux/iniramfs_data_cpio.gz
146 (the underscore before "cpio" in the previous command is not a typo).
148 Recompress the root.ext2 file:
149 mkzftree -F $WORK/root.ext2 $WORK/iso/root.ext2
151 Recreate the CD image:
152 cd $WORK/iso ; mkisofs -z -R -l --allow-leading-dots -D -o \
153 ../lfslivecd-x86-6.2-custom.iso -b boot/isolinux/isolinux.bin \
154 -c boot/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \
155 -V "lfslivecd-x86-6.2-custom" ./
157 Burn and test. Have a fun.
161 The team of "Linux From Scratch" and all users.
162 Sylvie Migneault <alisou at alixe.org> for the initial hint.
163 All users wich contribute at the OpenSource project. :-)
168 * Initial hint by Sylvie Migneault.
171 * Updated to LFS LiveCD based on device mapper (6.2-pre4 and later)