Raspberry Pi (Raspberry Pi) build Linux system from scratch (Pilfs) (iii)

Source: Internet
Author: User
Tags install openssl openssl library

Nine. System Configuration

1. Installing lfs-bootscripts-20150222

The package contains a set of start and stop scripts when the LFS system starts and shuts down.

CD/sourcestar-jxf Lfs-bootscripts-20150222.tar.  bz2CD lfs-bootscripts-20150222 makeinstallCD/sourcesrm-rf lfs-bootscripts-20150222   

2. Configure the system host name

echo "LFS" >/etc/hostname

3. Create a /etc/hosts file

Cat >/etc/hosts << "EOF" # begin/etc/hosts (network card version) 127.0.0.1end/etc/hosts (network card V ersion)EOF 

4. Configure Sysvinit

During kernel initialization, the first running program defaults to Sysvinit, which reads the /etc/inittab file

Cat >/etc/inittab << "EOF" # begin/etc/Inittabid:3: Initdefault: Si::SYSINIT:/ETC/RC.D/INIT.D/RC Sl0:0: WAIT:/ETC/RC.D/INIT.D/RC 0L1: S1:WAIT:/ETC/RC.D/INIT.D/RC 1L2:2: WAIT:/ETC/RC.D/INIT.D/RC 2L3:3: WAIT:/ETC/RC.D/INIT.D/RC 3L4:4: WAIT:/ETC/RC.D/INIT.D/RC 4L5:5:WAIT:/ETC/RC.D/INIT.D/RC 5l6:6 :WAIT:/ETC/RC.D/INIT.D/RC 6ca:12345:ctrlaltdel:/sbin/shutdown-t1-a-R nowsu:s016 : Once:/sbin/sulogin1:2345:respawn:/sbin/agetty-- Noclear tty1 96002:2345:respawn:/sbin/agetty tty2 96,003:2,345 :respawn:/sbin/agetty tty3 96004:2345:respawn:/sbin/ Agetty tty4 96005:2345:respawn:/sbin/agetty tty5 96,006:2,345 :respawn:/sbin/agetty tty6 9600# end/etc/inittabeof             
View Code

5. Installing pilfs-bootscripts-20160219

Package contains a collection of scripts, as well as some fixes for the Raspberry Pi hardware

CD/sourcestar-jxf Pilfs-bootscripts-20160219.tar.  XZcd pilfs-bootscripts-20160219 makeinstall-networkfix install-swapfix install-fake-hwclock Install-switch-cpu-governorCD/sourcesrm-rf pilfs-bootscripts-20160219     

6. System Locale

Cat >/etc/locale.conf << "EOF"
Lang=zh_cn. GB18030
Eof

7. Create a/ETC/INPUTRC file

    inputrcThe purpose of the file is to tell the system what keyboard layout to handle the keyboard

Cat >/etc/inputrc << "EOF" # begin/etc/inputrc# Modified by Chris Lynn <[email protected]net># allow theCommandPromptTo wrap to the next lineSet horizontal-scroll-Modeoff#Enable 8bit InputSet Meta-flagOnSet Input-metaon# TurnsOff8th bit StrippingSet Convert-metaoff# Keep the 8th bitForDisplaySet Output-metaon# None,Visible or audibleSetBell-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#ForLinux 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/inputrceof    
View Code

8. Create a/etc/shells file

    shellsFile is a list file of all available shells for the current system

Cat >/etc/shells << "EOF" # begin/etc/shells/bin/sh/bin/end/etc/shellseof   

9. Other optional configurations are also included in the LFS official documentation, which can be added as needed

10. Enable the LFS system to boot

1. Create a/etc/fstab file

Place the partition of the host system in the/home directory, and the host system will have to be cleared after the first boot of the LFS system

cat > /etc/fstab << "EOF" # Begin /etc/fstab
# file system  mount-point  type     options             dump  fsck
#                                                              order

/DEV/MMCBLK0P1/Boot vfat defaults 0 0/dev/mmcblk0p2/home ext4 defaults,noatime 0 1/DEV/MMCBL K0P3 swap swap Pri=1 0 0
/DEV/MMCBLK0P4/EXT4 Defaults,noatime 0 2PROC/PROC proc Nosuid,noexec,nodev 0 0sysfs/sys sysfs nosuid,noexec,nod EV 0 0devpts/dev/pts devpts gid=5,mode=620 0 0tmpfs/run TMPFS defaults 0 0 devtmpfs/dev Devtmpfs mode=0755,nosuid 0 0
# end/etc/fstab EOF

2. Kernel and Boot program

When you may be able to compile your own Linux kernel as part of building LFS, it is strongly recommended that you ensure that the system first correctly guides the kernel of the Raspberry Pi distribution.

There is no grub on the Raspberry Pi, we are instead relying on the Raspberry Pi distribution bootloader to boot.

Exit chroot, edit /boot/cmdline.txt , willroot=/dev/mmcblk0p2 改为 root=/dev/mmcblk0p4

10. Finally

1. Create a /etc/lfs-release file

Cat >/etc/lsb-release << "EOF"distrib_id= "Pi Linux from Scratch"distrib_release= " lfs-book-svn-20161221 "distrib_codename=" Kevin "distrib_description=" Pi Linux from Scratch "  EOF

2. Installation Configuration DHCPCD

CD/sourcestar-jxf dhcpcd-6.11.5.tar.XZCDDhcpcd-6.11.5./configure--libexecdir=/lib/dhcpcd \--dbdir=/var/lib/dhcpcd &&makemake InstallCD/SOURCESRM-RF dhcpcd-6.11.5

# Wired Network configuration
cat > /etc/sysconfig/ifconfig.eth0 << "EOF"
onboot= "No"
Iface= "Eth0"
Service= "DHCPCD"
Dhcp_start= "-b-q"
dhcp_stop= "-K"
Eof

# Wireless Network Configuration
cat > /etc/sysconfig/ifconfig.wlan0 << "EOF"
onboot= "Yes"
Iface= "Wlan0"
Service= "WPA"

# Additional arguments to Wpa_supplicant
Wpa_args= ""

wpa_service= "DHCPCD"
dhcp_start= "-b-q"
dhcp_stop= "-K"
Eof

# WiFi Configuration
cat > /etc/sysconfig/wpa_supplicant-wlan0.conf << "EOF"
network={
ssid="WiFi-name1"
psk="WiFi-password1"
priority=5
}
EOF


3. Installing OpenSSH

#OpenSSH relies on the OpenSSL library to install OpenSSL first
CD/sourcestar-zxf openssl-1.0.2j.tar.GZCDopenssl-1.0.2j./config--prefix=/usr \--openssldir=/ETC/SSL \--libdir=lib \shared\zlib-dynamic &&make depend &&makemake MANDIR=/usr/share/man mansuffix=SSL Install &&install-dv-m755/usr/share/doc/openssl-1.0.2j &&CP-VFR Doc/*/usr/share/doc/openssl-1.0.2jCD/SOURCESRM-RF openssl-1.0.2j
# Install OpenSSHCD/sourcestar-zxf openssh-7.4p1.tar.GZCDOpenssh-7.4p1install-v-m700-d/var/lib/sshd &&chown-v Root: Sys/var/lib/sshd &&groupadd-g50sshd &&useradd-c ' sshd privsep '\- D/VAR/LIB/SSHD \- G sshd\- S/bin/false \- u50sshd./configure--prefix=/usr \--sysconfdir=/ETC/SSH \--with-md5-passwords\--with-privsep-Path=/var/lib/sshd &&makemake Install &&install-v-m755 contrib/ssh-Copy-id/usr/bin &&install-v-m644 contrib/ssh-Copy-id.1/usr/share/man/man1 &&install-v-m755-d/usr/share/doc/openssh-7.4p1 &&install-v-m644 Install LICENCE Overview readme*/usr/share/doc/openssh-7.4p1cd/sources
RM-RF openssh-7.4P1


# The SSH service is turned on when the system starts
CD/sources
TAR-JXF Blfs-bootscripts-20160902.tar.xz
CD blfs-bootscripts-20160902
make install-sshd
Cd/sources
RM-RF blfs-bootscripts-20160902

4. Rebooting the system

$LFS/dev/$LFS/$LFS/run$LFS/$LFS/$lfsshutdown-r now 

Eleven. How to make Pilfs into a TF card image

1. Need a PC with Linux system

2. Copy the contents of the boot partition and the Pilfs partition on the TF card to the Bootfiles and Lfsfiles folders on the PC

3. Format and re-partition the TF card with gparted:

/DEV/SDB1 50M FAT32 boot partition

/DEV/SDB2 2G EXT4 Pilfs partition

4. Use the Parted-l command to view and get the start location of the boot partition (Bootstart) and the end position of the Pilfs partition (Lfsend)

5. Copy the contents of the Bootfiles and Lfsfiles folders to the re-partitioned boot and pilfs partitions, respectively

6. Use the DD command to mirror the TF card:

DD If=/dev/sdb of=mylfs.img bs=1m count=2098

Where BS is the value of Bootstart, and count is the value of Lfsend

Raspberry Pi (Raspberry Pi) build Linux system from scratch (Pilfs) (iii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.