7the_last

The Last

你最近有快照嗎? 沒有, 那麼趕緊來一張吧, 那麼多軟件重新編譯一次也是很費時間的。

  • 編譯完最後一個vim,LFS 的編譯已經進入了尾聲,不要着急,剩下的也就是幾條命令的事,認真點,很快的

現在先logou出去。
這之後的登錄就不用先前的chroot了我把兩個命令列到一起,大家對比一下

這是之前的

chroot "$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

這是現在將要用到的

chroot "$LFS" /usr/bin/env -i              \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin     \
    /bin/bash --login

而後是刪除tools文件夾, 不過避免出現問題, 我沒有刪而是

mv tools tools-bak

想刪想留都可以

而後安裝LFS-Bootscript
進入sources目錄, 解壓什麼的,大家都懂

make install

就行了

因爲我是在虛擬機中編譯的,書上的好多模塊的安裝跳過了,大家有需求自己看吧

IP

cd /etc/sysconfig/
cat > ifconfig.eth0 << "EOF"
ONBOOT=yes
IFACE=eth0
SERVICE=ipv4-static
IP=192.168.1.2
GATEWAY=192.168.1.1
PREFIX=24
BROADCAST=192.168.1.255
EOF

這是書上的配置文件
不能照搬啊,要根據實際情況改
子網掩碼就是PREFIX,24 代表的就是255.255.255.0
換成2進制就是24位

而後是DNS

cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf

nameserver 8.8.8.8 
nameserver 8.8.4.4

# End /etc/resolv.conf
EOF

這樣就可以了

主機名

echo lfs > /etc/hostname

我的就叫lfs

hosts

cat > /etc/hosts << "EOF"
# Begin /etc/hosts (network card version)

127.0.0.1 localhost

# End /etc/hosts (network card version)
EOF

就這樣就可以了

init

cat > /etc/inittab << "EOF"
# Begin /etc/inittab

id:3:initdefault:

si::sysinit:/etc/rc.d/init.d/rc S

l0:0:wait:/etc/rc.d/init.d/rc 0
l1:S1:wait:/etc/rc.d/init.d/rc 1
l2:2:wait:/etc/rc.d/init.d/rc 2
l3:3:wait:/etc/rc.d/init.d/rc 3
l4:4:wait:/etc/rc.d/init.d/rc 4
l5:5:wait:/etc/rc.d/init.d/rc 5
l6:6:wait:/etc/rc.d/init.d/rc 6

ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

su:S016:once:/sbin/sulogin

1:2345:respawn:/sbin/agetty --noclear tty1 9600
2:2345:respawn:/sbin/agetty tty2 9600
3:2345:respawn:/sbin/agetty tty3 9600
4:2345:respawn:/sbin/agetty tty4 9600
5:2345:respawn:/sbin/agetty tty5 9600
6:2345:respawn:/sbin/agetty tty6 9600

# End /etc/inittab
EOF

照寫就可以

修改rc.site文件

它在/etc/sysconfig/rc.site
要把其中的SYSKLOGD_PARMS參數設置爲空
也就是像下面這樣

# Optional sysklogd parameters
SYSKLOGD_PARMS=

已經有vim了, 修改一下這個文件還是很簡單的

設置語言

cat > /etc/profile << "EOF"
# Begin /etc/profile

export LANG=en_US.UTF-8

# End /etc/profile
EOF

設置特殊字符支持

cat > /etc/inputrc << "EOF"
# Begin /etc/inputrc
# Modified by Chris Lynn <[email protected]>

# Allow the command prompt to wrap to the next line
set horizontal-scroll-mode Off

# Enable 8bit input
set meta-flag On
set input-meta On

# Turns off 8th bit stripping
set convert-meta Off

# Keep the 8th bit for display
set output-meta On

# none, visible or audible
set bell-style none

# All of the following map the escape sequence of the value
# contained in the 1st argument to the readline specific functions
"\eOd": backward-word
"\eOc": forward-word

# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

# for xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for Konsole
"\e[H": beginning-of-line
"\e[F": end-of-line

# End /etc/inputrc
EOF
cat > /etc/shells << "EOF"
# Begin /etc/shells

/bin/sh
/bin/bash

# End /etc/shells
EOF

而後是fstab文件

cat > /etc/fstab << "EOF"
# Begin /etc/fstab

# file system  mount-point  type     options             dump  fsck
#                                                              order

/dev/sdc1     /             ext4     defaults            1     1
proc           /proc        proc     nosuid,noexec,nodev 0     0
sysfs          /sys         sysfs    nosuid,noexec,nodev 0     0
devpts         /dev/pts     devpts   gid=5,mode=620      0     0
tmpfs          /run         tmpfs    defaults            0     0
devtmpfs       /dev         devtmpfs mode=0755,nosuid    0     0

# End /etc/fstab
EOF

設置掛載點
我的電腦上是sdc1

最後編譯內核

make mrproper
make defconfig

make LANG=en_US LC_ALL= menuconfig

就進入配置界面
有東西要修改的

Device Drivers  --->
  Generic Driver Options  --->
    [ ] Support for uevent helper [CONFIG_UEVENT_HELPER]
    [*] Maintain a devtmpfs filesystem to mount at /dev [CONFIG_DEVTMPFS]

認真找一找, 放心,絕對有

make
make modules_install

cp -v arch/x86_64/boot/bzImage /boot/vmlinuz-3.19-lfs-7.7

cp -v System.map /boot/System.map-3.19
cp -v .config /boot/config-3.19
install -d /usr/share/doc/linux-3.19
cp -r Documentation/* /usr/share/doc/linux-3.19

我的是64位系統所以是x86_64

install -v -m755 -d /etc/modprobe.d
cat > /etc/modprobe.d/usb.conf << "EOF"
# Begin /etc/modprobe.d/usb.conf

install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true
install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true

# End /etc/modprobe.d/usb.conf
EOF

而後是grub的安裝

grub-install /dev/sdc

cat > /boot/grub/grub.cfg << "EOF"
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5

insmod ext2
set root=(hd0,2)

menuentry "GNU/Linux, Linux 3.19-lfs-7.7" {
        linux   /boot/vmlinuz-3.19-lfs-7.7 root=/dev/sda2 ro
}
EOF
echo 7.7 > /etc/lfs-release
cat > /etc/lsb-release << "EOF"
DISTRIB_ID="Linux From Scratch"
DISTRIB_RELEASE="7.7"
DISTRIB_CODENAME="<your name here>"
DISTRIB_DESCRIPTION="Linux From Scratch"
EOF

其實寫到這裏,大家不要一味着追求速度,頭腦清醒些,引導安裝不是開玩笑,
很可能把主系統的引導覆蓋了,本系統也未能成功,
這纔是讓人難過的事,我的主系統用的是Ubuntu-server
用過Ubuntu的都知道,修復引導之後登錄進系統首先要做的是
update-grub2現在logout出去, 把ubuntu的引導更新一下,
也是完全沒問題的, 不過永遠不要忘記兩個字–快照, 小心駛得萬年船啊。

回顧LFS的安裝, 新的東西確實不少, 不過只要有一定的基礎,
接受起來蠻快的,還有一點便是堅持, 我這次編譯LFS用了
差不多兩星期, 失敗了3次,雖然歸根到底是我不認真的問題,
但我想提醒大家一句,好好看LFS-BOOK, 命令輸過之後要記得檢查,
否則錯誤都不知是哪出現的問題。

加油吧, 努力就會成功的,而前方只是個LFS而已。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章