This paper is participating in the30 years of Linux”Topic essay activity

I am very glad to participate in this essay, and take this opportunity to pay tribute to the Linux open source project!

This time to share a Linux system to make the article, Linux modular, simplification is worth our learning, come on!

Production environment

Vmware VM software

Vm 1: Install system Ubuntu20

Vm 2: A virtual disk of 2 GB

Production steps

The process for creating a system is as follows: After creating a minimum OS for virtual machine 1, mount 2 gb virtual disks to virtual machine 2.

Log in to VIRTUAL machine 1 and mount the 2G virtual disk to the/MNT directory

Go to the/MNT directory and grub-install generates the configuration file and structure

–root-directory Specifies the virtual disk device

cd /mnt
grub-install --root-directory=/mnt /dev/sda
Copy the code

After this command is executed, the boot directory and grub subdirectory are generated

Copy the kernel file from the local system to the/MNT /boot directory

CD/MNT /boot cp /boot/vmlinuz-5.11.0-27-generic vmlinuz cp /boot/initrd.img-5.11.0-27-generic initrd.imgCopy the code

Create the grup. CFG boot configuration file

vim /mnt/boot/grub/grub.cfg
Copy the code

Configure the content

default=0
timeout=10
menuentry 'mini ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-02c4dcdd-de2c-43bf-9757-3043aa5735c6' {
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_msdos
        insmod ext2
        set root='hd0,msdos5'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos5 --hint-efi=hd0,msdos5 --hint-baremetal=ahci0,msdos5 d220d03a-f1bd-4d4f-87a0-e15cf9d13418 
        else
          search --no-floppy --fs-uuid --set=root d220d03a-f1bd-4d4f-87a0-e15cf9d13418 
        fi
        linux   /boot/vmlinuz root=UUID=d220d03a-f1bd-4d4f-87a0-e15cf9d13418 ro locale=en_US quiet enforcing=0
        initrd  /boot/initrd.img
}
Copy the code

Note: The UUID of each disk is different. You can run the ls -l /dev/disk/by-uuid/ command to view the UUID

Create a Linux directory structure

cd /mnt
mkdir -pv {bin,dev,etc,lib,lib64,proc,sys}
Copy the code

Copy basic commands

cp /bin/bash /mnt/bin
cp /bin/ls /mnt/bin
cp /bin/echo /mnt/bin
cp /bin/sh /mnt/bin
cp /bin/dash /mnt/bin
Copy the code

Copy depends on dynamic libraries

Create the /lib/x86_64-linux-gnu directory

mkdir /mnt/lib/x86_64-linux-gnu
Copy the code

Library files that bash depends on

cp /lib/x86_64-linux-gnu/libtinfo.so.6 /mnt/lib/x86_64-linux-gnu
cp /lib/x86_64-linux-gnu/libdl.so.2 /mnt/lib/x86_64-linux-gnu
cp /lib/x86_64-linux-gnu/libc.so.6 /mnt/lib/x86_64-linux-gnu
cp /lib64/ld-linux-x86-64.so.2 /lib64
Copy the code

Other dependent library files

cp /usr/lib/x86_64-linux-gnu/libc.so /mnt/lib/x86_64-linux-gnu
cp /usr/lib/x86_64-linux-gnu/libc.so.6 /mnt/lib/x86_64-linux-gnu
cp /usr/lib/x86_64-linux-gnu/libdl.so /mnt/lib/x86_64-linux-gnu
cp /usr/lib/x86_64-linux-gnu/libdl.so.2 /mnt/lib/x86_64-linux-gnu
cp /usr/lib/x86_64-linux-gnu/libselinux.so.1 /mnt/lib/x86_64-linux-gnu
cp /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0 /mnt/lib/x86_64-linux-gnu/
cp /usr/lib/x86_64-linux-gnu/libpthread.so.0 /mnt/lib/x86_64-linux-gnu/
Copy the code

Creating the welcome script

vim /mnt/init
Copy the code

The new content

#! /bin/bash echo -e "\t Welcome to \033[31mMy Mini Ubuntu Linux\033[0m"Copy the code

Setting Execution Permission

chmod +x /mnt/init
Copy the code

Run the chroot command to check whether the virtual environment is normal

chroot /mnt
Copy the code

Finally, sync writes to the disk

sync
Copy the code

After the above steps, the minimum system has been made.

System startup

On the vmware VM 2 configuration page, select 2G virtual disk

After boot, grub page

Accessing the Linux System