The dynamic process of the system can be divided into:
Post: Power-on and self-test
Boot Sequence (BIOS): MBR is found based on the boot order in Biso
Boot Loader (MBR): Start the bootloader bootstrapper in the MBR
Kernel (RAMDisk): Load kernel, load kernel will use RAMDisk, find file system
Rootfk:boot into the file system
Switchroot: Switching the root directory
/sbin/init: Run the first program
/etc/inittab: Starts the service at the specified level and shuts down the closed service (/ETC/RC.D/INIT.D) according to the startup level specified in Inittab
/etc/init/*.conf
Make a small Linux system based on the above content.
To prepare, add a hard disk size of 20G (two zones, dev/sdb1 mount to the BOOT,DEV/SDB2 mount to Miniroot) in the virtual machine, we will do the system directly above the hard drive, and then start directly.
1. Add a hard drive
2. Partition and format to EXT4 file system
3. Create directory, Mount Partition
4. Enter the/mnt/boot directory to copy the native kernel files and Initramfs files to the/mnt/boot directory and rename them from the new
5. Install grub using the Grub-install command
Grub-install--root-directory=/mnt/dev/sdb
--root-directory= (pointing to the top-level directory of the Boot directory)
/DEV/SDB: To install grub on that disk, note that it is not on the partition
You can see that the grub file has been generated
6. Create the Grub configuration file in the grub file grub.cfg
Default=0
Timeout=5
Title=minilinux
Root (hd0,0)
Kernel/vmlinuz ro root=/dev/sda2
Initrd/initramfs.img
Root (hd0,0): Specifies the root directory, hd0: Represents the first disk, 0: The first partition, in fact, the root switch to the boot partition, easy to find the next kernel, and Initrdisk file
Kernel: Indicates kernel file
Ro root=/dev/sdb2: Re-specify the location of the root file in read-only mode
INITRD: Indicates where the file Initrdisk file is located
7, to the/mnt/miniroot/directory to create the relevant directory
MKDIR-PV Proc Dev Lib lib64 bin Sbin home root etc/rc.d usr/{lib,bin,sbin} var tmp mnt sys
8. Copy the init and bash files on the system and the libraries you rely on to the miniroot corresponding directory
Use which to view the command directory
Use LLD to view the library file on which the command depends
9. Switch root test root is valid chroot/mnt/miniroot/If a bash prompt appears, the root is valid
10. Create/mnt/miniroot/etc/inittab configuration file,
Id:3:initdefault:
Si::sysinit:/etc/rc.d/rc.sysinit
Defines the system default boot level of 3, and specifies that the/etc/rc.d/rc.sysinit script is run when the system is initialized
11, edit Rc.sysinit file, display welcome information
Then run/bin/bash
and give Execute permission
12. Run sync to the hard drive
13,, will make minilinux of the main machine, add a virtual machine, from this block to do minilinux system host boot.
But this did not succeed, loaded into the kernel, and then switched the root, it ended up as if it did not run init to perform rc.d/rc.sysinit solution??
Make a simple Linux system