2010년 3월 26일 금요일

LFS LiveCD and Jhalfs Howto

LFS LiveCD and Jhalfs Howto

Part 1 - Expedient instructions

Instant linux from scratch with LiveCD and Jhalfs automated build.
Don't use the "toram" option.
boot the LiveCD (lfslivecd-x86-6.3-r2160.iso)
Optionally, you can type startxfce4 and start a terminal.
mkdir /mnt/build_dir
chmod 777 /mnt/build_dir
mount the target partition on /mnt/build_dir
swapon /dev/your_swap_partition (if you have one)
useradd -s /bin/bash -m -k /dev/null lfs
echo "lfs ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
su - jhalfs
cd jhalfs-2.3.1
make
Select EXIT
Type yes
Wow! It works! Makes LFS-6.3!

If you did the optional startxfce4 then while it is building you can:
  • click the blue globe (seamonkey) and read along in the book
  • click on the black rectangle (terminal) and look under /mnt/build_dir/jhalfs/logs and view the logs as they are created
  • look under /mnt/build_dir/jhalfs/lfs-commands/chapter{05,06,07,08} and view the commands for each step

If you didn't do the optional startxfce4, you can still:
  • press CTRL-ALT-F2
  • startxfce4
  • do the above
  • press CTRL-ALT-F1 to return to the first screen



-----------------------------------------------------------------


Non-instant linux from scratch with LiveCD and manual build.
boot the LiveCD
startxfce4
click on the blue globe (seamonkey)
follow the book instructions


------------------------------------------------------------------


Part 2 - Enduring instructions

You may choose to build a version of LFS later than 6.3. The LiveCD is still excellent for this, but more advanced instuctions than the instant ones are needed.

These are the basic ingredients:
Lfs LiveCD or LiveCD.iso
Empty partition with at least 3GB (8-12 recommended)
Linux system

First Requirement - Choose an LFS Version to build
--------------------------------------------------
${LFV} will designate 'LFS Version" in all of the remainder of this document.
Wherever you see ${LFV} written, substitute the LFS Version desired.
For example: If you are building LFS 6.5, then wherever you see ${LFV}, substitute 6.5.
Think of ${LFV} as a symbol for 6.5

Example from below:
You are building LFS 6.5
You see written: mkdir /mnt/build_dir/lfs-${LFV}-xml
Replace it with: mkdir /mnt/build_dir/lfs-6.5-xml


An extraordinary case is the LFS 'SVN' or 'trunk' version.
In that case, one possibility is to substitute the date in YYYYMMDD format which can be provided by the command:
date +%Y%m%d

For example, if 'date +%Y%m%d' prints 20100121, then wherever ${LFV} is written, replace it with 20100121.

Example from below:
You are building trunk and the date is 20100121
You see written: mkdir /mnt/build_dir/lfs-${LFV}-xml
Replace it with: mkdir /mnt/build_dir/lfs-20100121-xml


The LiveCD provides a complete development environment. Jhalfs enables you to build a base system in a few steps. The most recent LiveCD has the outdated but stable LFS-6.3. This is not a problem. It is still a good LiveCD even if you want to build a newer system. The stable LFS-6.3 has a matching BLFS-6.3 and it builds in half the time of LFS-6.5. You can also choose to use a host linux system instead of the LiveCD. You don't have to use the LiveCD to use jhalfs or vice versa. You can also build manually which you should try at least once. It is your system and your choice.

You could, apparently, build a newer LiveCD from the subversion files but there is no need to do so unless you want to.
You could also, apparently, remaster a LiveCD if you want to (instuctions viewable once the LiveCD boots).

To get the fastest startup time, you can do these instructions while booting the LiveCD.iso from disk instead of using a CD drive. If you are going to boot from the LiveCD in a CD drive, "boot: linux toram" will give much better performace if you have enough memory.

To load the CD contents to RAM with the "toram" option, the minimum required amount of RAM is 512 MB. If you have less than 768 MB of RAM, add swap when the CD boot finishes -- a good idea anyway.

The LiveCD is available at ftp://anduin.linuxfromscratch.org/LFS-LiveCD/

lfslivecd-x86-6.3-r2160.iso includes the LFS-6.3 source files.
The lfslivecd-x86-6.3-r2160 CD might also be purchased from http://www.osdisc.com or http://www.linuxcd.org.

lfslivecd-x86-6.3-r2160-nosrc.iso is the same except it doesn't include the LFS-6.3 sources so it is smaller.

lfslivecd-x86-6.3-r2160-min.iso is the smallest and it would work too. The "min" one does not have any GUI and everything must be done at a text console. This one is only a good choice if you want to "use the force" and work in the darkness. That is how things will be on a newly built lfs system before the gui is built.

If you wish to automate the build with jhalfs:
Use jhalfs-2.3.1 to build LFS-6.3 and/or BLFS-6.3.
Use jhalfs-2.3.2 or later to build LFS/BLFS versions later than 6.3.
This is because some changes made after LFS/BLS 6.3 are not fully compatible with jhalfs-2.3.1.
Mixing the "not compatibles" may cause funny things to happen.
I'll just mention that the (trunk) "SVN" version of LFS is later than 6.3 and the (trunk) "SVN" version of jhalfs is later than 2.3.2.

Jhalfs has a BREAKPOINT feature which potentially allows some of the work to be done automatically and some of the work to be done manually.


Step 1 - Preparations to boot the lfs LiveCD from disk.
------------------------------------------------------

In these instructions, a directory named ISOS will be created and the LiveCD.iso will be downloaded and found there. If you run this disk_livecd script, it does the steps L1 - L5:

L1 - Remember the starting directory
-------------------------------
start_dir=$(pwd)

L2 - Make the directory ISOS
-----------------------
mkdir /ISOS

L3 - Get the LiveCD.iso
----------------------
cd /ISOS
wget -c ftp://anduin.linuxfromscratch.org/LFS-LiveCD/lfslivecd-x86-6.3-r2160.iso

L4 - Extract LiveCD kernel and initramfs
----------------------------------------
iso_dir="/ISOS"
live_cd="lfslivecd-x86-6.3-r2160.iso"
lc_kernel="${iso_dir}/lfs-live-linux"
lc_initrd="${iso_dir}/lfs-live-initramfs.gz"
mkdir -v -p /tmp/livecd &&
mount -v -t iso9660 -o loop \
${iso_dir}/${live_cd} \
/tmp/livecd &&
cd /tmp/livecd/boot/isolinux &&
install -v -m 644 linux ${lc_kernel} &&
install -v -m 644 initramfs_data.cpio.gz ${lc_initrd} &&
cd $start_dir
umount -v /tmp/livecd

L5 - Add LFS liveCD to grub configfile
------------------------------------
title LFS liveCD
root (${grub_drive},${grub_part})
kernel ${lc_kernel} rw root=iso:/dev/${disk}${partition}:${live_cd_path} rootfstype=${fstype} ${toram}
initrd ${lc_initrd}


Step 2 - Make target partition and mount it
-------------------------------------------
TP = Target Partition = [hs][a-f][0-15] = examples: sda1, sdb2, hdd10
If the target partition is /dev/TP
mke2fs -j -I 128 /dev/TP

mkdir /mnt/build_dir
mount /dev/TP /mnt/build_dir

NOTE: The optional switch, -I 128, restricts inode size to 128. This enables an older grub to boot the partition without complaining "Error 2: Bad file or directory type". The mke2fs in recent e2fsprogs defaults to 256. If the grub understands 256-byte inodes then omit the switch, -I 128. Also omit the switch if using ext4.

Step 3 - Make dirs for book and sources and jhalfs-2.3.2
-------------------------------------------------------
mkdir /mnt/build_dir/lfs-sources
mkdir /mnt/build_dir/lfs-${LFV}-xml
mkdir /mnt/build_dir/jhalfs-2.3.2

Note: This is done because you may wish to preload these if you have previously downloaded a copy.

Step 4 - Copy or download the appropriate jhalfs version
---------------------------------------------------------
cd /mnt/build_dir/jhalfs-2.3.2

if you already have jhalfs-2.3.2
  • cp -aT path_to_jhalfs-2.3.2 .
Otherwise
  • svn co svn://linuxfromscratch.org/ALFS/jhalfs/tags/2.3.2 .

Step 5 - Copy xml files to /mnt/build_dir
-----------------------------------------
cd /mnt/build_dir/lfs-${LFV}-xml

if you already have them
  • cp -aT path_to_xml_files .
Otherwize
  • svn co svn://linuxfromscratch.org/LFS/tags/${LFV}/BOOK .
Unless you are building trunk in which case
  • svn co svn://linuxfromscratch.org/LFS/trunk/BOOK .

Step 6 - Get sources ahead of time
----------------------------------
# Copy or wget sources

# Set your path to existing sources or "" if none:
path_to_sources="/sources"

# Get sources
cd /mnt/build_dir/lfs-${LFV}-xml
if [ $? -eq 0 ]; then
sudo make wget-list BASEDIR=.
cp wget-list /mnt/build_dir/lfs-sources
cd /mnt/build_dir/lfs-sources
while read line;do
sf=${line##*/}
if [ ! -f "${sf}" ]; then
if [ -n "$path_to_sources" ]; then
if [ -f "${path_to_sources}/${sf}" ]; then
cp -iv ${path_to_sources}/${sf} .
fi
fi
fi
if [ ! -f "${sf}" ]; then
wget -c $line
fi
done < wget-list
fi


Step 7 - Change permissions of /mnt/build_dir to 777
----------------------------------------------------
chmod 777 /mnt/build_dir

Note: This is done because the build user will need access.


Step 8 - Boot the LiveCD
------------------------
If using cdrom
  • Load cdrom in the drive
  • At the prompt 'boot:' type 'linux toram'
Otherwise if booting from disk
  • From the Grub Menu, Select 'LFS liveCD'

It will ask you to choose a timezone from a scroll menu.
I choose America/New_York which represents U.S.A. Eastern Time.
It will ask you to choose a locale from a scroll menu.
I choose English, USA, ISO-8859-1.
Press ENTER to start a virtual console.

swapon /dev/your_swap_partition (if you have one)
useradd -s /bin/bash -m -k /dev/null lfs
echo "lfs ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

Step 9 - Prepare the graphical environment (optional)
----------------------------------------------------
You can start the LiveCD graphical environment with:
startxfce4

Often, it can be frustrating to get the graphical environment to start or to get acceptable resolution. Commonly, the default settings will give a resolution that is too low, meaning that everything is too huge to work with comfortably.

Changing the device driver to the generic "vesa" will work in many cases. This can be done manually or with the following sed command which edits /etc/X11/xorg.conf and under [Section "Device"], comments out the current Driver and inserts the line [Driver "vesa"].

sed -i /etc/X11/xorg.conf -e '
/Section "Device"/,/EndSection/ {
/Driver/s/^/#/
/EndSection/i\ \tDriver\t"vesa"
}'

An alternative approach is to edit /etc/X11/xorg.conf under [Section "Monitor"] and insert a proper [HorizSync h-H] line and/or a [VertRefresh v-V] line. The data for HorizSync and VertRefresh for your monitor might only be available on the original box. The HorizSync line is the more critical one.
WARNING: Using the wrong values might cause damage. Guessing is discouraged.

The printed on my box (which I saved) is Fh 31-80.
Sed could add that with:

sed -i -e '
/Section "Monitor"/,/EndSection/ {
/HorizSync/s/^/#/
/EndSection/i\ \tHorizSync\t31-80
}
' /etc/X11/xorg.conf

It happens that I can get higher resolution with Fh 31-64.
Sed could add that with:

sed -i /etc/X11/xorg.conf -e '
/Section "Monitor"/,/EndSection/ {
/HorizSync/s/^/#/
/EndSection/i\ \tHorizSync\t31-64
}'

NOTE: I have never seen sed documentation that the filename can precede the script, but I tried it and it worked for me. That makes it easier to use the UP-ARROW and edit, and repeat the command with a different range.

You don't need to get it perfect. You only get it good enough to work with. Even if you can't get the graphical environment to work, you can still build a system.

Step 10 - Exit the graphical environment test as root (optional)
----------------------------------------------------------------
If you entered the graphical environment as root, then exit it now.

Step 11 - Mount the build_dir
-----------------------------
TP = Target Partition = examples: sda1, sdb2, hdd10

mkdir /mnt/build_dir
mount /dev/TP /mnt/build_dir
chown -R jhalfs:jhalfs /mnt/build_dir/lfs-sources
chown -R jhalfs:jhalfs /mnt/build_dir/jhalfs-2.3.2

Step 12 - Change user to jhalfs
-------------------------------
You should be at the text console with the # (pound sign) prompt:
su - jhalfs

Step 13 - Start graphical environment as jhalfs (optional)
---------------------------------------------------------
You should be at the text console with the $ (dollar sign) prompt:
echo Xft.dpi: 96 >> .Xresources
startxfce4
start a terminal

Step 14 - Change directory to jhalfs-2.3.2 location
---------------------------------------------------
cd /mnt/build_dir/jhalfs-2.3.2

Step 15 - Run jhalfs 'make' to configure jhalfs
-----------------------------------------------
make
























Step 16 - Change directory to the build location
------------------------------------------------
cd /mnt/build_dir/jhalfs

Step 17 - Run jhalfs 'make' to build the system
-----------------------------------------------
make

댓글 없음:

댓글 쓰기