X86 platform based on the grub2+busybo+linux-2.6.36 making Linux system
First, download the kernel source code, GRUB2 source code, and BusyBox Source:
- Download GRUB2 Source code
ftp://ftp.gnu.org/gnu/grub/to find the desired version, here to choose grub-1.99.tar.gz
- Download BusyBox Source code
http://www.busybox.net/downloads/to find the desired version, here to choose busybox-1.22.1.tar.bz2
- Download linux-2.6.36 Kernel source code
https://www.kernel.org/to find the desired version, here to choose LINUX-2.6.36.TAR.XZ
Second, compile the source code
Create the directory/mylinux and copy the source tarball to the/mylinux.
1. Compiling GRUB2
Decompression: TAR–XF grub-1.99.tar.gz
Switching paths for compiling: CD grub-1.97
Compile:./configure &&make&&make Install
After compiling, the genetic execution file is in the/usr/local/sbin directory
2. Compiling BusyBox
Decompression: TAR–XF busybox-1.22.1.tar.bz2
Switching paths for compiling: CD busybox-1.22.1
Configure compilation options: Make Menuconfig
Note: When you configure the compile option, you want to select the USE/USR, or make install, copy the resulting execution file to/usr in the corresponding directory. Other configurations are determined according to your needs
Compiling:make&& make install
Note: The target file generated by the compilation will be output to: _install directory
3. compile linux-2.6.36 Kernel code
Decompression: TAR–XF LINUX-2.6.36.TAR.XZ
Toggle Compilation path: CD linux-2.6.36
To configure compilation options:
Copy the configuration of the current system as the default configuration: cp/boot/config-xxx. config
Make Menuconfig Modify the kernel configuration to suit your needs
Compiling: Make && make modules && make Modules_install && make install
Third, make the root file system directory
Create directory: Mkdir–p/mylinux/sysroot
Toggle Path: Cd/mylinux/sysroot
Create root directory: mkdir-p boot dev etc home linuxrc proc Root tmp usr var lib
Copy the necessary device files from the system: Console Kmem mem Ram stderr stdout tty0 ttyS0 Zero
Fd/loop null random stdin TTY tty1 urandom
Note: You can also create your own with the Mknod command
Copy executable file: cp-raf/mylinux/busybox-1.22.1/_install/*/mylinux/sysroot/
Copy kernel module: cp–raf/lib/modules/linux-2.6.36xxx/*/mylinux/sysroot/lib/
Write system configuration file: Cd/mylinux/sysroot/etc
Create the following file: busybox.conf fstab Group INIT.D inittab issue MOTD mtab passwd profile resolv.conf Shadow shadow-
Create directory: INIT.D
- Busybox.conf is empty
- Fstab
/dev/sda1/boot ext3 defaults 0 0
/DEV/SDA2/EXT3 acl,user_xattr 1 1
PROC/PROC proc Defaults 0 0
Sysfs/sys SYSFS noauto 0 0
Debugfs/sys/kernel/debug Debugfs noauto 0 0
Usbfs/proc/bus/usb USBFS noauto 0 0
Devpts/dev/pts devpts mode=0620,gid=5 0 0
- Group
Root:x:0:root
- Inittab
:: Sysinit:/etc/init.d/rcs
:: askfirst:/bin/sh
Tty2::respawn:/bin/getty 38400 Tty2
Tty3::respawn:/bin/getty 38400 Tty3
Tty4::respawn:/bin/getty 38400 Tty4
# Stuff to does when restarting the INIT process
:: Restart:/bin/init
# Stuff to do before rebooting
:: Ctrlaltdel:/bin/reboot
:: Shutdown:/bin/umount-a-R
:: Shutdown:/bin/swapoff–a
- Issue
My Linux Release 0.1
- MOTD is empty
- mTAB is empty
- Password
Root::0:0:root:/root:/bin/ash
- Profile
#/etc/profile:system-wide. profile file for the Bourne shells
Echo
Echo
Export ps1= "[/[email protected]/h/w]/$"
echo "Done"
Alias Ll= ' Ls-l '
Alias du= ' Du-h '
Alias df= ' Df-h '
Alias rm= ' Rm-i '
Echo
- resolv.conf
NameServer 202.96.209.5
NameServer 202.96.209.6
- Shadow
root:$1$ $adltAB 9sr/mskqylivsjt/:12705:0:99999:7:::
- shadow-
Root:$1$dwu.tenp$b7anixogoizmwjr6ih8810:12705:0:99999:7:::
- Create the RCS startup script file under the INIT.D directory, plus the executable permissions, as follows:
#! /bin/sh
Mount-o REMOUNT,RW/
/bin/mount-a
>/etc/mtab
Echo
Echo-en "/t/twelcom to//033[0;32mbabylinux//033[0;39m/n"
Echo
Hostname My Linux
Four, make system boot disk
Note: Temporarily on the virtual machine to operate, the actual hard disk is also a reason
1, add a hard disk on the virtual machine, the size is set to 8G.
The newly added drive can be seen through the command fdisk–l:
Partition not yet in progress
2, the new hard disk with fdisk command partition, partition as follows:
3. Format the new disk partition:
Mkfs.ext3/dev/sdb1
Mkfs.ext3/dev/sdb2
4. Create mount Directory:
Mkdir–p/mnt/boot/mnt/sysroot
5. Mount the new disk
Mount/dev/sdb1/mnt/boot
mount/dev/sdb2/mnt/sysroot/
6. Copy the corresponding files to the new disk:
Cp/boot/vmlinuz-2.6.36-12-xxx/mnt/boot/vmlinuz
Cp/boot/initrd-2.6.36-12-xxx/mnt/boot/initrd
cp-raf/mylinux/rootfs/*/mnt/sysroot/
7. Join Grub Boot Boot:
Grub-install--root-directory=/mnt/dev/sdb
8. Create Grub Boot Menu:
/mnt/boot/grub/grub.cfg:
Set default=0
Set timeout=5
Menuentry "Gnu/linux, with Linux 3.16.3-12-default" {
Set root= (hd0,1)
Linux/vmlinuz
Initrd/initrd
}
9. Unmount the disk:
Umount/mnt/boot
Umount/mnt/sysroot
Four, to here the system is finished, the new system has been written to disk, the new disk as a system disk, you can boot the system.
Making Linux system based on grub2+busybo+linux-2.6.36 under X86 platform