This project provides steps and scripts to build your own linux system in virtual machine envionment. The instruction we follow is Linux From Scratch verion 11.3 (https://www.linuxfromscratch.org/index.html)
Host OS: RockyLinux 8 or other Linux distributions
Virtual Machine Environment: QEMU
- Install RockyLiunx 8 OS in Virtual Disk 1(sda) by default Linux partition settings
- prepare LFS partition
lsblk
## sdb 8:16 0 70G 0 disk
fdisk /dev/sdb
## create three partitions sdb1(512M), sdb2(1G), sdb3(68.5G) by command (ref: https://linux.die.net/man/8/gdisk). Note that sdb2 needs to change type "Linux swap / Solaris"(hex code=82)
## sdb1: /boot partition
## sdb2: swap
## sdb3: / partition
lsblk
## sdb1 8:16 0 512M 0 part
## sdb2 8:16 0 1G 0 part
## sdb3 8:16 0 68.5G 0 part
- format partitions
mkfs -v -t ext4 /dev/sdb1
mkswap /dev/sdb2
mkfs -v -t ext4 /dev/sdb3
./run.sh
cd pkg_compile_cross_toolchain_script && ./install_all.sh
cd pkg_cross_compiling_temporary_tools_script && ./lfs_user_install_all.sh
cd pkg_chroot_tools && cat README ## following README
- Install sshd
cd /opt
./chroot_install_openssh.sh
vi /etc/ssh/sshd_config
## Set root login config
## === modify this line ===
PermitRootLogin yes
-
Install wget
-
Install netstat
-
Install Gnome
- Observe infrastructure from QEMU Environment
- Modify ifconfig.eth0
- Infra after modification
- ping google.com again
- press
c
- type
cd (hd
and press tab, and you will see disks and partitions recognized by grub - setup root path in /boot/grub/grub.cfg file, in this case, root path is (hd0, msdos1)
set root=(hd0, msdos1)
- Disk2 partitions were SOMETIMES recognized as /dev/sdc1, /dev/sdc2, and /dev/sdc3, but we expect /dev/sdb1~3, so if we configure grub.cfg like /dev/sdbX, it will casue this error.
- It is highly recommanded to specify partitions by PARTUUID, command below shows partition PARTUUID information.
blkid
# /dev/sdb3: UUID="17b539e0-9a73-482c-ba8b-70e3353ba187" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="b4d939e3-03"
- specify root=PARTUUID=XXXX
vi /boot/grub/grub.cfg
# set default=0
# set timeout=5
#
# insmod ext2
# set root=(hd0,msdos1)
#
# menuentry "GNU/Linux, Linux 6.1.11-lfs-11.3" {
# linux /vmlinuz-6.1.11-lfs-11.3 root=PARTUUID=b4d939e3-03 ro
# }
- LFS boots successfully