summaryrefslogtreecommitdiffstats
path: root/book/building_iso.html
diff options
context:
space:
mode:
authorWilliam Harrington <kb0iic@berzerkula.org>2014-11-27 16:29:31 -0600
committerWilliam Harrington <kb0iic@berzerkula.org>2014-11-27 16:29:31 -0600
commit7df987a652b93d55dd8eca363706d3bacc469b55 (patch)
tree17f84ce0fee76a3a0476b714eae09486ab2470e6 /book/building_iso.html
Initial commit message for lfs live howto.HEADmaster
Diffstat (limited to 'book/building_iso.html')
-rw-r--r--book/building_iso.html95
1 files changed, 95 insertions, 0 deletions
diff --git a/book/building_iso.html b/book/building_iso.html
new file mode 100644
index 0000000..ed16be1
--- /dev/null
+++ b/book/building_iso.html
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>8.1. Building the ISO live system</title><link rel="stylesheet" href="stylesheets/lfs.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><link rel="stylesheet" href="stylesheets/lfs-print.css" type="text/css" media="print" /></head><body class="lfs" id="lfs-0.3"><div class="navheader"><h4>LFS live howto - Version 0.3</h4><h3>Chapter 8. Building the ISO live system</h3><ul><li class="prev"><a accesskey="p" href="ch08.html" title="Building the ISO live system">Prev</a><p>Building the ISO live system</p></li><li class="next"><a accesskey="n" href="ch09.html" title="Making the ISO live system bootable">Next</a><p>Making the ISO live system bootable</p></li><li class="up"><a accesskey="u" href="ch08.html" title="Chapter 8. Building the ISO live system">Up</a></li><li class="home"><a accesskey="h" href="index.html" title="LFS live howto - Version 0.3">Home</a></li></ul></div><div class="sect1" lang="en" xml:lang="en"><h1 class="sect1"><a id="building_iso" name="building_iso"></a>8.1. Building the ISO live system</h1><p>As we want to put a whole system on little space, we will squash some directories to have some more free space on the cd or dvd.
+ </p><p>
+ Before squashing, we have some work to do
+ </p><p>Issue the following: </p><pre class="userinput"><kbd class="command">cd $LFSMOUNT</kbd></pre><p>As the system won't be writable, we have to provide a directory that will be mounted on tmpfs and will, therefore, be writable to ensure a successful boot.</p><pre class="userinput"><kbd class="command">mkdir -v ro rw dev</kbd></pre><p>Make sure you have support for loopback device in your kernel:</p><pre class="userinput"><kbd class="command">ls -l /dev | grep loop</kbd></pre><p>You should see a few /dev/loopX, where X is a number from 0 to 7. If this is not the case, and the loopback is supported as a kernel module, try to modprobe the module and retry again:</p><pre class="userinput"><kbd class="command">modprobe loop
+ls -l /dev | grep loop</kbd></pre><p>Create some essential files in the dev directory</p><pre class="userinput"><kbd class="command">mknod -m 600 dev/console c 5 1
+mknod -m 666 dev/null c 1 3
+cp -av /dev/loop[0-7] dev/
+mknod dev/ram0 b 1 0</kbd></pre><p>Copy the /etc directory</p><pre class="userinput"><kbd class="command">cp -av /etc .</kbd></pre><p>Modify some files in it</p><pre class="userinput"><kbd class="command">echo "" &gt; etc/mtab
+cat &gt; etc/fstab &lt;&lt; "EOF"
+# Begin /etc/fstab
+
+# file system mount-point type options dump fsck
+# order
+
+proc /proc proc defaults 0 0
+sysfs /sys sysfs defaults 0 0
+devpts /dev/pts devpts gid=4,mode=620 0 0
+tmpfs /run tmpfs defaults 0 0
+usbfs /proc/bus/usb usbfs devgid=14,devmode=0660 0 0
+
+# End /etc/fstab
+EOF</kbd></pre><p>While booting, we will have to copy some directories in shared memory, and mount a root filesystem on it. This has to be done in the first bootscript.</p><div class="sect2" lang="en" xml:lang="en"><h2 class="sect2">8.1.1. Creating bootscript</h2><p>issue the following to create a new bootscript:</p><pre class="userinput"><kbd class="command">cd etc/rc.d/init.d
+cat &gt; mountrootfs &lt;&lt; "EOF"
+#!/bin/sh
+
+# Set up variables
+
+dir_rw=/rw
+dir_ro=/ro
+
+# Source functions
+
+source /etc/rc.d/init.d/functions
+
+case "$1" in
+ start)
+
+# Mount temporary files on $dir_rw
+
+ echo "Mounting tmpfs on $dir_rw..."
+ mount -t tmpfs tmpfs $dir_rw
+ evaluate_retval
+ sleep 1
+
+# Create essential dirs in dir_rw
+
+ mkdir $dir_rw/{dev,etc,home,media,mnt}
+ mkdir $dir_rw/{opt,root,srv,tmp,usr,var}
+
+# If you have some other dirs in $LFSMOUNT/ like sources
+# Add them to that list, eg: mkdir -v $dir_rw/sources
+
+mount -n -t squashfs root.sqsh ro -o loop
+mount -n -t aufs -o dirs=$dir_rw/etc=rw:$dir_ro/etc=ro aufs etc
+mount -n -t aufs -o dirs=$dir_rw/usr=rw:$dir_ro/usr=ro aufs usr
+mount -n -t aufs -o dirs=$dir_rw/tmp=rw:$dir_ro/tmp=ro aufs tmp
+mount -n -t aufs -o dirs=$dir_rw/var=rw:$dir_ro/var=ro aufs var
+mount -n -t aufs -o dirs=$dir_rw/dev=rw:$dir_ro/dev=ro aufs dev
+mount -n -t aufs -o dirs=$dir_rw/home=rw:$dir_ro/home=ro aufs home
+mount -n -t aufs -o dirs=$dir_rw/media=rw:$dir_ro/media=ro aufs media
+mount -n -t aufs -o dirs=$dir_rw/mnt=rw:$dir_ro/mnt=ro aufs mnt
+mount -n -t aufs -o dirs=$dir_rw/opt=rw:$dir_ro/opt=ro aufs opt
+mount -n -t aufs -o dirs=$dir_rw/root=rw:$dir_ro/root=ro aufs root
+mount -n -t aufs -o dirs=$dir_rw/srv=rw:$dir_ro/srv=ro aufs srv
+chmod 1777 /tmp
+
+ ;;
+ *)
+ echo "Usage: $0 {start}"
+ exit 1
+ ;;
+esac
+EOF
+chmod 0754 mountrootfs</kbd></pre><p>Inspect the contents of etc/rc.d/rcS.d</p><pre class="userinput"><kbd class="command">ls -l ../rcS.d</kbd></pre><p>You should see a list beginning with S00mountvirtfs, S02consolelog, ...</p><p>Now, issue:</p><pre class="userinput"><kbd class="command">cd ../rcS.d
+mv -v S00mountvirtfs S01mountvirtfs
+ln -sv ../init.d/mountrootfs S00mountrootfs
+</kbd></pre><p>The live system can not be checked with fsck so remove these bootscripts</p><pre class="userinput"><kbd class="command">rm S30checkfs
+rm S40mountfs
+rm S45cleanfs
+</kbd></pre></div><div class="sect2" lang="en" xml:lang="en"><h2 class="sect2">8.1.2. About the var directory</h2><p>As we are just copying our system, we will need the var directory while booting. We have to remove pid and sockets file from it.</p><pre class="userinput"><kbd class="command">cd $LFSMOUNT
+cp -av /var .
+cd var
+rm log/*.log
+for FILE in `find . -type f -name '*pid'`
+ do rm $FILE
+done
+for FILE in `find . -type s`
+ do rm $FILE
+done
+rm -rf tmp/*
+cd $LFSMOUNT</kbd></pre></div><div class="sect2" lang="en" xml:lang="en"><h2 class="sect2">8.1.3. Squashing directories</h2><p>Create tmp, root and other directories, then squash all. When squashing, you might not want to add some file or directory. Add files to the -e option of mksquashfs if you wish.</p><pre class="userinput"><kbd class="command">mkdir -pv home media mnt opt proc root run srv sys tmp usr ro/{dev,etc,home,media,mnt,opt,root,srv,tmp,usr,var}
+mksquashfs dev etc /home /media mnt /opt /root /srv tmp /usr var root.sqsh -keep-as-directory -info
+rm -r var/*
+</kbd></pre><p>Copy dirs that won't be squashed:</p><pre class="userinput"><kbd class="command">cp -av /bin /boot /lib /sbin .</kbd></pre><p>Copy our previous created initrd.gz to /boot of the media.</p><pre class="userinput"><kbd class="command">cp &lt;PATH-TO-INITRD&gt;/initrd.gz $LFSMOUNT/boot</kbd></pre><p></p></div></div><div class="navfooter"><ul><li class="prev"><a accesskey="p" href="ch08.html" title="Building the ISO live system">Prev</a><p>Building the ISO live system</p></li><li class="next"><a accesskey="n" href="ch09.html" title="Making the ISO live system bootable">Next</a><p>Making the ISO live system bootable</p></li><li class="up"><a accesskey="u" href="ch08.html" title="Chapter 8. Building the ISO live system">Up</a></li><li class="home"><a accesskey="h" href="index.html" title="LFS live howto - Version 0.3">Home</a></li></ul></div></body></html>