In a virtual machine, you can use a host to install a small linux operating system. The steps are as follows: add a new disk to grub and divide it into three partitions: sdb1, sdb2, and sdb3, which are 100 M, 512 M, and 128 M, respectively, format in ext3 file system format... you can use a host to install a small linux operating system in a virtual environment. The steps are as follows:
Step 1: Add grub
Add a new disk on the host and divide it into three partitions: 100 M, 512 M, and 128 M for sdb1, sdb2, and sdb3, which are formatted as ext3 file systems. Create two directories # mkdir/mnt/boot # mkdir/mnt/sysroot on the host machine. Mount sdb1 to/mnt/boot # monut/dev/sdb1/mnt/boot. the steps for adding grub are described in detail in the previous blog. The second method is used to add grub.
Step 2: Copy the kernel to the disk.
# Mount/dev/sdb1/mnt/boot
# Cp/boot/vmlinuz-2.6.18-164.el5/mnt/boot/vmlinuz
Step 3: unzip the initrd-2.6.18-164.el5.img
# Mkdir/tmp/linux
# Cp/boot/initrd-2.6.18-164.el5.img/tmp/linux
# Cd/tmp/linux
# Mv initrd-2.6.18-164.el5.img initrd-2.6.18-164.el5.img.gz
# Gzip-d initrd-2.6.18-164.el5.img.gz
# Cpio-id <initrd-2.6.18-164.el5.img
Because this file cannot be used directly, edit the init script in this directory.
Vim init
Change/dev/vol0/root to/dev/sda2
Step 3 create a directory
# Mount/dev/sdb2/mnt/sysroot
# Cd/mnt/sysroot
# Mkdir-pv {/etc/rc. d, bin, sbin, usr, var, proc, sys, tmp, lib, mnt, media, misc, opt, dev, srv}
# Cp/sbin/init sbin/
# Cp/bin/bash bin/
# Vim etc/inittab
{
Id: 3: initdefault:
Si: sysinit:/etc/rc. d/rc. sysinit
}
# Vim etc/rc. d/rc. sysinit
{
#! /Bin/bash
Echo-e "\ tWelcome to LLinux"
/Bin/bash
}
Give rc. sysinit an execution permission
# Chmod + x etc/rc. d/rc. sysinit
Step 4 Copy the required library file
Use ldd to view the library files on which a command depends, and copy the required library files to/mnt/sysroot/lib.
# Ldd bin/bash
# Ldd bin/init
Step 6 is encapsulation
There is a initrd-2.6.18-164.el5.img in the/tmp/linux directory.
Delete this file
# Rm initrd-2.6.18-164.el5.img
Also: bin dev etc init lib proc sbin sys sysroot
These files are reencapsulated.
# Find. | cpio-o-H newc-quit | gzip-9>/mnt/boot/initrd.gz
Add a configuration file for grub:
# Cd grub
# Vim grub. conf
{
Default = 0
Timeout = 5
Title Llinux
Root (hd0, 0)
Kernel/vmlinuz ro root =/dev/sda2
Initrd/initrd.gz
}
Use chroot to test whether the instance can be started.
Create a new virtual machine and use it to the disk. in this way, a small Linux is successfully installed.
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