目录
.
.
.
有兴趣的同学可参考该文档将其完善
.
.
.
前奏
rambo@debian:~$ cat /etc/issue
Debian GNU/Linux 12 \n \l
rambo@debian:~$ free -h
total used free shared buff/cache available
Mem: 15Gi 718Mi 14Gi 4.7Mi 370Mi 14Gi
Swap: 975Mi 0B 975Mi
# 查看逻辑CPU的个数
rambo@debian:~$ cat /proc/cpuinfo| grep "processor"| wc -l
8
rambo@debian:~$ cat /etc/apt/sources.list
deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main
deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb-src https://mirrors.ustc.edu.cn/debian-security/ bookworm-security main
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main non-free non-free-firmware contrib
rambo@debian:~$ sudo apt -y update
rambo@debian:~$ sudo apt install -y make gcc libncurses-dev build-essential flex bison libssl-dev libelf-dev dwarves time
下载linux内核源码并编译
rambo@debian:~$ wget https://mirror.bjtu.edu.cn/kernel/linux/kernel/v6.x/linux-6.5.7.tar.gz
rambo@debian:~$ tar -zxvf linux-6.5.7.tar.gz
rambo@debian:~$ cd linux-6.5.7/
rambo@debian:~/linux-6.5.7$ make menuconfig
General setup --->
----> [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
Device Drivers --->
[*] Block devices --->
<*> RAM block device support
(65536) Default RAM disk size (kbytes)
rambo@debian:~/linux-6.5.7$ make -j10
编译成功后的内核位置:
rambo@debian:~$ ls linux-6.5.7/arch/x86_64/boot/bzImage
下载busybox的源代码
rambo@debian:~$ wget https://www.busybox.net/downloads/busybox-1.36.1.tar.bz2
rambo@debian:~$ tar -jxvf busybox-1.36.1.tar.bz2
rambo@debian:~$ cd busybox-1.36.1
rambo@debian:~/busybox-1.36.1$ make menuconfig
注:将buxybox设置成静态编译,如下项打开
Settings --->[*] Build static binary (no shared libs)
rambo@debian:~/busybox-1.36.1$ make && make install
注:编译完成后的busybox就安装在源码根目录下的_install目录了,我们进入_install目录,补充一些必要的文件或目录
rambo@debian:~/busybox-1.36.1$ cd _install/
rambo@debian:~/busybox-1.36.1$ mkdir -p etc dev mnt proc sys tmp mnt etc/init.d/
rambo@debian:~/busybox-1.36.1$ vim etc/fstab
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
rambo@debian:~/busybox-1.36.1$ vim etc/init.d/rcS
echo -e "WELCOME TO TEST_LINUX"
/bin/mount -a
echo -e "Remounting the root filesystem"
mount -o remount,rw /
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
rambo@debian:~/busybox-1.36.1$ chmod 755 etc/init.d/rcS
rambo@debian:~/busybox-1.36.1$ vim etc/inittab
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r
rambo@debian:~/busybox-1.36.1$ chmod 755 etc/inittab
rambo@debian:~/busybox-1.36.1/_install$ cd dev
rambo@debian:~/busybox-1.36.1/_install/dev$
rambo@debian:~/busybox-1.36.1/_install/dev$
sudo mknod console c 5 1
sudo mknod null c 1 3
sudo mknod tty1 c 4 1
sudo mknod ttyS0 c 4 64
rambo@debian:~/busybox-1.36.1/_install/dev$ cd ../..
制作根文件系统镜像文件
rambo@debian:~/busybox-1.36.1$ dd if=/dev/zero of=./rootfs.ext4 bs=1M count=32
rambo@debian:~/busybox-1.36.1$ sudo mkfs.ext4 rootfs.ext4
rambo@debian:~/busybox-1.36.1$ mkdir fs
rambo@debian:~/busybox-1.36.1$ sudo mount -t ext4 -o loop rootfs.ext4 ./fs
rambo@debian:~/busybox-1.36.1$ df -h | grep busybox
/dev/loop0 26M 14K 23M 1% /home/rambo/busybox-1.36.1/fs
rambo@debian:~/busybox-1.36.1$ sudo cp -rf ./_install/* ./fs
rambo@debian:~/busybox-1.36.1$ sudo umount ./fs
rambo@debian:~/busybox-1.36.1$ gzip --best -c rootfs.ext4 > rootfs.img.gz
rambo@debian:~/busybox-1.36.1$ ls -alh rootfs.img.gz
-rw-r--r-- 1 rambo rambo 1.3M Oct 13 09:15 rootfs.img.gz
rambo@debian:~/busybox-1.36.1$ cd
安装qemu
rambo@debian:~$ sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils qemu-system-ppc64 vim
rambo@debian:~$ sudo qemu-system-x86_64 \
-kernel ~/linux-6.5.7/arch/x86_64/boot/bzImage \
-initrd ~/busybox-1.36.1/rootfs.img.gz \
-append "console=ttyS0" \
-nographic -enable-kvm
sudo qemu-system-x86_64 \
-kernel ~/linux-6.5.7/arch/x86_64/boot/bzImage \
-initrd ~/initramfs.cpio.gz \
-nographic -enable-kvm \
-append "console=ttyS0"
启动不成功....
标签:busybox,non,rambo,Mini,kernel6.5,free,busybox1.36,debian,1.36
From: https://www.cnblogs.com/smlile-you-me/p/17763316.html