By. Fauzi Dwi Susanto

39
By. Fauzi Dwi Susanto Pengantar LFS (Linux From Scratch) Praktikum Sistem Operasi Tahun 2012 Teknik Informatika - D

description

By. Fauzi Dwi Susanto. Pengantar LFS (Linux From Scratch). Praktikum Sistem Operasi Tahun 2012 Teknik Informatika - D. Panduan LFS . Tentukan versi Linux Ubuntu yang dipakai . Karena versi ubuntu yang dipakai adalah versi 11.10, maka panduan LFS yang dipakai adalah : - PowerPoint PPT Presentation

Transcript of By. Fauzi Dwi Susanto

Page 1: By.  Fauzi Dwi Susanto

By. Fauzi Dwi Susanto

PengantarLFS (Linux From

Scratch)Praktikum Sistem Operasi

Tahun 2012Teknik Informatika - D

Page 2: By.  Fauzi Dwi Susanto

Tentukan versi Linux Ubuntu yang dipakai.

Karena versi ubuntu yang dipakai adalah versi 11.10, maka panduan LFS yang dipakai adalah : LFS-BOOK 7.1

Panduan LFS

Page 3: By.  Fauzi Dwi Susanto

Install Linux Ubuntu 11.10 pada VB anda Membuat partisi baru dengan ketentuan :

A. Partisi root yang diberi mount point / dan tipe file ext3 dengan kapasitas sesuai kebutuhan anda.

B. Partisi swap yang diberi mount point /swap dan tipe file swap dengan kapasitas sesuai kebutuhan anda.

Siapkan kopi dan sedikit hiburan agar tidak bosan serta ajak curhat teman disampingmu…!

Persiapan Awal

Page 4: By.  Fauzi Dwi Susanto

Setelah partisi baru telah dibuat, maka langkah selanjutnya adalah mengkopi file LFS ke sistem operasi Linux (paket-paket dan data-data LFS yang diperlukan).

Setelah dikopi, lakukan proses version-check untuk melihat versi sistem host nya, jika ada paket yang butuh diinstal dahulu maka install paket2 tersebut.

-- Merujuk LFS-BOOK 7.1 hal.xvii--

Page 5: By.  Fauzi Dwi Susanto

Masuk root dahulumke2fs -jv /dev/<xxx>

Inisialisasi partisi swapcd /tmprm -rfv e2fsprogs-1.42mkswap /dev/<yyy>

Mounting partisi baruexport LFS=/mnt/lfsmkdir -pv $LFSmount -v -t ext3 /dev/<xxx> $LFS

-- Merujuk LFS-BOOK 7.1 hal.12,13 dan 14--

Persiapan Partisi Baru (Chap.2)

Page 6: By.  Fauzi Dwi Susanto

Buat directory untuk tempat LFS anda, dan masuk sebagai rootmkdir -v $LFS/sourceschmod -v a+wt $LFS/sources

Setelah itu pindahkan paket-paket LFS anda pada directory tersebut melalui terminal atau secara manual.

-- Merujuk LFS-BOOK 7.1 hal.15-23 --

Packages and Patches (Chap.3)

Page 7: By.  Fauzi Dwi Susanto

Mengecek apakah variabel LFS sudah sesuai ketentuan dengan cara mengetikkan perintah seperti di bawah ini :

echo $LFS

Mengeset path dari variabel LFS dengan cara mengetikkan perintah seperti di bawah ini :export LFS=/mnt/lfs

Langkah selanjutnya yang dilakukan adalah membuat direktori LFS/tools dengan cara menggunakan perintah seperti di bawah ini :mkdir -v $LFS/tools

Langkah selanjutnya adalah dengan membuat simlink /tools ke host system dengan cara menggunakan perintah seperti di bawah ini :ln -sv $LFS/tools /

Persiapan Final (Chap.4)

Page 8: By.  Fauzi Dwi Susanto

Langkah selanjutnya yang dilakukan adalah menambahkan user baru untuk LFS dengan cara menggunakan perintah seperti di bawah ini :groupadd lfsuseradd -s /bin/bash -g lfs -m -k /dev/null lfs

Untuk mengganti password dilakukan dengan menggunakan perintah seperti di bawah ini :passwd lfs

Setelah itu diberikan full akses ke user baru tersebut dengan menggunakan perintah seperti di bawah ini :chown -v lfs $LFS/toolschown -v lfs $LFS/sources

Kemudian login sebagai user baru tersebut dengan menggunakan perintah seperti di bawah ini :su – lfs

Persiapan Final (Chap.4)

Page 9: By.  Fauzi Dwi Susanto

Membuat profil bash baru dengan cara menggunakan perintah di bawah ini :cat > ~/.bash_profile << "EOF"exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bashEOF

Membuat Bashrc file dengan cara menggunakan perintah di bawah ini :cat > ~/.bashrc << "EOF"set +humask 022.......................................

Membuat user profil dengan cara menggunakan perintah seperti di bawah ini :source ~/.bash_profile

Setting Environment

Page 10: By.  Fauzi Dwi Susanto

Binutils-2.22 – Instalisasi Tahap 11.Buat folder untuk build

mkdir -v ../binutils-buildcd ../binutils-build

2.Persiapkan Binutils untuk dikompilasi../binutils-2.22/configure \--target=$LFS_TGT --prefix=/tools \--disable-nls --disable-werror lalu make

3.Jika akan di build untuk x86_64, buat symlink ke tool chaincase $(uname -m) inx86_64) mkdir -v /tools/lib &&ln -sv lib /tools/lib64 ;;esac

4.Install paketmake install

Constructing a Temporary System (Chap.5)

Page 11: By.  Fauzi Dwi Susanto

GCC-4.6.2 – Instalasi tahap 1 Linux-3.2.6 API Headers Glibc-2.14.1

Constructing a Temporary System (Chap.5)

Page 12: By.  Fauzi Dwi Susanto

SPECS=`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/specs$LFS_TGT-gcc -dumpspecs | sed \ -e 's@/lib\(64\)\?/ld@/tools&@g' \ -e "/^\*cpp:$/{n;s,$, -isystem /tools/include,}" > $SPECS echo "New specs file is: $SPECS"unset SPECS

Binutils-2.22 - Pass 2 GCC-4.6.2 - Pass 2 Tcl-8.5.11 Expect-5.45 Dan seterusnya..,,,,Lakukan compile dan install paket secara

urut, jangan sampai ada yang terlewatkan.

Adjusting the Toolchain

Page 13: By.  Fauzi Dwi Susanto

Remove symbols :strip --strip-debug /tools/lib/*strip --strip-unneeded /tools/{,s}bin/*

Remove the documentationrm -rf /tools/{,share}/{info,man,doc}

-- Next slide to Chapter 6 --

Stripping

Page 14: By.  Fauzi Dwi Susanto

Creating directories onto which the file systems will be mountedmkdir -v $LFS/{dev,proc,sys}

Creating Initial Device Nodesmknod -m 600 $LFS/dev/console c 5 1mknod -m 666 $LFS/dev/null c 1 3

Mounting and Populating /devmount -v --bind /dev $LFS/dev

Mounting Virtual Kernel File Systemsmount -vt devpts devpts $LFS/dev/ptsmount -vt tmpfs shm $LFS/dev/shmmount -vt proc proc $LFS/procmount -vt sysfs sysfs $LFS/sys

Installing Basic System Software (Chap. 6)

Page 15: By.  Fauzi Dwi Susanto

Entering the Chroot Environmentchroot "$LFS" /tools/bin/env -i \ HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ /tools/bin/bash --login +h

Creating Directoriesmkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib,mnt,opt,run}mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}install -dv -m 0750 /rootinstall -dv -m 1777 /tmp /var/tmpmkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}mkdir -pv /usr/{,local/}share/{doc,info,locale,man}mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}mkdir -pv /usr/{,local/}share/man/man{1..8}for dir in /usr /usr/local; do ln -sv share/{man,doc,info} $dirdonecase $(uname -m) in x86_64) ln -sv lib /lib64 && ln -sv lib /usr/lib64 ;;esacmkdir -v /var/{log,mail,spool}ln -sv /run /var/runln -sv /run/lock /var/lockmkdir -pv /var/{opt,cache,lib/{misc,locate},local}

Installing Basic System Software (Chap. 6)

Page 16: By.  Fauzi Dwi Susanto

Creating Essential Files and Symlinksln -sv /tools/bin/{bash,cat,echo,pwd,stty} /binln -sv /tools/bin/perl /usr/binln -sv /tools/lib/libgcc_s.so{,.1} /usr/libln -sv /tools/lib/libstdc++.so{,.6} /usr/libsed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.laln -sv bash /bin/sh

Presence of /etc/mtabtouch /etc/mtab

Create the /etc/passwd --- merujuk LFS-BOOK 7.1 hal 80 --- Create the /etc/group --- merujuk LFS-BOOK 7.1

hal 81 ---

Installing Basic System Software (Chap. 6)

Page 17: By.  Fauzi Dwi Susanto

To work user name and group nameexec /tools/bin/bash --login +h

Initialize the log files and give them proper permissionstouch /var/run/utmp /var/log/{btmp,lastlog,wtmp}chgrp -v utmp /var/run/utmp /var/log/lastlogchmod -v 664 /var/run/utmp /var/log/lastlogchmod -v 600 /var/log/btmp

Next, Linux-3.2.6 API Headers Man-pages-3.35 Glibc-2.14.1

Installing Basic System Software (Chap. 6)

Page 18: By.  Fauzi Dwi Susanto

Create link to its counterpart in / tools/ $ (gcc - dumpmachine)/ binmv -v /tools/bin/{ld,ld-old}mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}mv -v /tools/bin/{ld-new,ld}ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld

A sed commandgcc -dumpspecs | sed -e 's@/tools@@g' \

-e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \ -e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \ `dirname $(gcc --print-libgcc-file-name)`/specs

Re-adjusting the Toolchain

Page 19: By.  Fauzi Dwi Susanto

Sanity checksecho 'main(){}' > dummy.ccc dummy.c -v -Wl,--verbose &> dummy.logreadelf -l a.out | grep ': /lib‘

Make sure that we're setup to use the correct startfiles dllgrep -o '/usr/lib.*/crt[1in].*succeeded' dummy.loggrep -B1 '^ /usr/include' dummy.loggrep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g‘grep "/lib.*/libc.so.6 " dummy.loggrep found dummy.log

Clean up the test filesrm -v dummy.c a.out dummy.log

Re-adjusting the Toolchain

Page 20: By.  Fauzi Dwi Susanto

Zlib-1.2.6 File-5.10 Binutils-2.22 GMP-5.0.4 MPFR-3.1.0 MPC-0.9 GCC-4.6.2 Sed-4.2.1 Bzip2-1.0.6 Ncurses-5.9 …………............…catat paket yg sudah terinstall bila perlu Vim-7.3

Next Install Paket

Page 21: By.  Fauzi Dwi Susanto

Exit from chrootlogout

Entering the Chroot Environmentchroot $LFS /tools/bin/env -i \HOME=/root TERM=$TERM PS1='\u:\w\$ ' \PATH=/bin:/usr/bin:/sbin:/usr/sbin \/tools/bin/bash –login

The binaries and libraries can be safely stripped/tools/bin/find /{,usr/}{bin,lib,sbin} -type f \

-exec /tools/bin/strip --strip-debug '{}' ';'

Stripping Again

Page 22: By.  Fauzi Dwi Susanto

When reentering the chroot environment after exiting, use the following modified chroot commandchroot "$LFS" /usr/bin/env -i \ HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin \ /bin/bash –login

Cleaning Up

Page 23: By.  Fauzi Dwi Susanto

Creating stable names for network interfacesfor NIC in /sys/class/net/* ; do INTERFACE=${NIC##*/} udevadm test --action=add $NICdone

cat /etc/udev/rules.d/70-persistent-net.rules

Creating Network Interface Configuration Filescd /etc/sysconfig/cat > ifconfig.eth0 << "EOF"ONBOOT=yesIFACE=eth0……………

Setting Up System Bootscripts (Chap. 7)

Page 24: By.  Fauzi Dwi Susanto

Creating the /etc/resolv.conf Filecat > /etc/resolv.conf << "EOF"# Begin /etc/resolv.confdomain <Your Domain Name>nameserver <IP address of your primary nameserver>nameserver <IP address of your secondary nameserver># End /etc/resolv.confEOF

Create the /etc/hostscat > /etc/hosts << "EOF"# Begin /etc/hosts (no network card version)127.0.0.1 <HOSTNAME.example.org> <HOSTNAME> localhost# End /etc/hosts (no network card version)EOF

Setting Up System Bootscripts (Chap. 7)

Page 25: By.  Fauzi Dwi Susanto

CD-ROM symlinksudevadm test /sys/block/hddsed -i -e 's/"write_cd_rules"/"write_cd_rules mode"/' \/lib/udev/rules.d/75-cd-aliases-generator.rules

Dealing with duplicate devicesudevadm info -a -p /sys/class/video4linux/video0

Creating Custom Symlinks to Devices

Page 26: By.  Fauzi Dwi Susanto

Install LFS-Bootscripts-20120229

Configuring the setclock Scriptcat > /etc/sysconfig/clock << "EOF"# Begin /etc/sysconfig/clockUTC=1# Set this to any options you might need to give to hwclock, # such as machine hardware clock type for Alphas.CLOCKPARAMS=# End /etc/sysconfig/clockEOF

Setting Up System Bootscripts (Chap. 7)

Page 27: By.  Fauzi Dwi Susanto

Configuring the Linux Consolecat > /etc/sysconfig/console << "EOF"# Begin /etc/sysconfig/consoleUNICODE="1"KEYMAP="de-latin1"KEYMAP_CORRECTIONS="euro2"LEGACY_CHARSET="iso-8859-15"FONT="LatArCyrHeb-16 -m 8859-15"# End /etc/sysconfig/consoleEOF

Setting Up System Bootscripts (Chap. 7)

Page 28: By.  Fauzi Dwi Susanto

List of all locales supported by Glibclocale –a

This results in a final locale setting of “en_GB.ISO-8859-1”LC_ALL=<locale name> locale charmapLC_ALL=<locale name> locale languageLC_ALL=<locale name> locale charmapLC_ALL=<locale name> locale int_curr_symbolLC_ALL=<locale name> locale int_prefix

Once the proper locale settings have been determined, create the / etc/ profile file : -- merujuk hal 215 –

Creating the /etc/inputrc File : -- merujuk hal 216 –

The Bash Shell Startup Files

Page 29: By.  Fauzi Dwi Susanto

Making the LFS System Bootable (Chap. 8)

Creating the /etc/fstab File

Isi file system dan type sesuai dengan partisi laptop anda.

hdparm -I /dev/sda | grep NCQ

Page 30: By.  Fauzi Dwi Susanto

Linux-3.2.6 (Kernel)make mrpropermake LANG=<host_LANG_value> LC_ALL= menuconfigmakemake modules_installcp -v arch/x86/boot/bzImage /boot/vmlinuz-3.2.6-lfs-7.1cp -v System.map /boot/System.map-3.2.6cp -v .config /boot/config-3.2.6install -d /usr/share/doc/linux-3.2.6cp -r Documentation/* /usr/share/doc/linux-3.2.6

Making the LFS System Bootable (Chap. 8)

Page 31: By.  Fauzi Dwi Susanto

Creating a GRUB boot floppy diskette as a backupcd /tmp &&grub-mkrescue --output=grub-img.iso &&xorriso -as cdrecord -v dev=/dev/cdrw blank=as_needed grub-img.iso

GRUB Naming Conventionsgrub-mkdevicemap --device-map=device.mapcat device.map

Using GRUB to Set Up the Boot Process

Page 32: By.  Fauzi Dwi Susanto

Install the GRUB files into / boot/ grub:grub-install /dev/sda

Creating the Configuration Filecat > /boot/grub/grub.cfg << "EOF"# Begin /boot/grub/grub.cfgset default=0set timeout=5insmod ext2set root=(hd0,2)menuentry "GNU/Linux, Linux 3.2.6-lfs-7.1" { linux /boot/vmlinuz-3.2.6-lfs-7.1 root=/dev/sda2 ro}EOF

Setting Up the Configuration

Page 33: By.  Fauzi Dwi Susanto

WARNING…!!!!!!!!!!!!!! Hati – hati pada saat akan tahap reboot ..!!!

Rebooting the Systemlogout

Then unmount the virtual file systemsumount -v $LFS/dev/ptsumount -v $LFS/dev/shmumount -v $LFS/devumount -v $LFS/procumount -v $LFS/sys

The End (Chap. 9)

Page 34: By.  Fauzi Dwi Susanto

Unmount the LFS file system itself :umount -v $LFS

If multiple partitions were created, unmount the other partitions before unmounting the main one, like thisumount -v $LFS/usrumount -v $LFS/homeumount -v $LFS

Now, reboot the system with :shutdown -r now

The End (Chap. 9)

Page 35: By.  Fauzi Dwi Susanto

Contoh Hasil Grub After Reboot

Page 36: By.  Fauzi Dwi Susanto
Page 37: By.  Fauzi Dwi Susanto
Page 38: By.  Fauzi Dwi Susanto

Dear Praktikan SO TIF-D : 1. Project LFS ini waktu pengumpulannya diperpanjang

sampai dengan akhir UAS2. Hasil akhir project LFS ini didemokan setelah UAS

secara kelompok ke masing-masing dosen pengampu

3. Untuk dokumentasinya adalah masing-masing anggota kelompok (individu)

4. Sebelum demo ke dosen kpp harus sudah di ttd oleh koas SO dan laporan lengkap yang sudah disusun secara urut sesuai dengan ketentuan penjilidan

5. Ketentuan dan format penjilidan akan diupload minggu depan

Mohon Diperhatikan ..!!!!

Page 39: By.  Fauzi Dwi Susanto

Terima Kasih ….

Selamat Mengerjakan !!!!