Practical operation of a small Linux home
Overview: with the previous system start-up process, we have a rough idea of what files and procedures are required for Linux to boot, and now we can make a little Linux of our own.
Practice steps:
1. Add a new hard drive to existing Linux
2, partition the new hard disk, two partitions are/boot and/partition (prepared for home-made Linux)
3. Format the partition and mount it to two directories (I am here for/mnt/boot and/mnt/sysroot)
4. Install grub on this new hard drive and write the grub configuration file
5. Copy the Vmlinuz files and Initramfs files to the/mnt/boot directory
6. Create a root file system for small Linux under/mnt/sysroot
7, copy Bash and some common commands and their corresponding library files to the corresponding directory under/mnt/sysroot
8. Open a new Linux and start the test with the disk that you just started
Specific operation:
1. Add a new hard drive to existing Linux
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/4F/wKioL1fc1LmT8XeNAAfIuVOfgMU709.gif "title=" Gif.gif "alt=" Wkiol1fc1lmt8xenaafiuvofgmu709.gif "/>
2, the new hard disk partition, two partitions are/boot and/partition (for home-made Linux) 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/ 87/4f/wkiol1fc1hzyxb8saaaar9troiw576.png "title=" 2016-09-17_133237.png "alt=" Wkiol1fc1hzyxb8saaaar9troiw576.png " />
3. Format the partition and mount it to two directories (I am here for/mnt/boot and/mnt/sysroot)
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/87/4F/wKioL1fc1vWiuha0AAAwrV5B0KU639.png "title=" 2016-09-17_133622.png "alt=" Wkiol1fc1vwiuha0aaawrv5b0ku639.png "/>
4. Install grub on this new hard drive and write the Grub configuration file (the Grub profile can copy the native grub.conf file and change the content to the following content)
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/87/50/wKioL1fc22LSpgYhAAApd12n_Vc090.png "title=" 2016-09-17_134014.png "alt=" Wkiol1fc22lspgyhaaapd12n_vc090.png "/>
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/87/50/wKioL1fc8WGRid8_AAAfrdNzEyw871.png "title=" 2016-09-17_152538.png "alt=" Wkiol1fc8wgrid8_aaafrdnzeyw871.png "/>5, copy vmlinuz files and Initramfs files to/mnt/boot directory
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/87/52/wKiom1fc3CyxyuIdAAARZRaj4nw519.png "title=" 2016-09-17_135846.png "alt=" Wkiom1fc3cyxyuidaaarzraj4nw519.png "/>
6. Create a root file system for small Linux under/mnt/sysroot
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/87/50/wKioL1fc3UOiYdc4AAAkK__Zb_Q765.png "title=" 2016-09-17_140302.png "alt=" Wkiol1fc3uoiydc4aaakk__zb_q765.png "/> 7, copy bash and some common commands and their corresponding library files to/mnt/ Sysroot under the corresponding directory
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/87/52/wKiom1fc436hnCszAARFZtb9t_0440.gif "title=" 1.gif " alt= "Wkiom1fc436hncszaarfztb9t_0440.gif"/>
[[email protected] ~]# cat copycmd.sh #!/bin/bashch_root= "/mnt/sysroot" //This directory corresponds to the above/mnt/sysroot, if the above directory changes, the directory here should also change [ ! -d $ch _ root ] && mkdir $ch _root bincopy () { if Which $1 &>/dev/null; then local cmd _path= ' which --skip-alias $1 ' local bin_dir= ' dirname $cmd _path ' [ -d ${ch_root}${bin_dir} ] | | mkdir -p ${ch_root}${bin_dir} [ -f ${ ch_root}${cmd_path} ] | | cp $cmd _path ${ch_root}${bin_dir} return 0 else echo&nbsP; " Command not found. " return 1 fi} libcopy () { local lib_list=$ (ldd ' which --skip-alias $1 ' | grep -Eo '/[^[:space:]]+ ') for loop in $lib _list;do local lib_dir= ' dirname $loop ' [ -d ${ch_root}${lib_dir} ] | | mkdir -p ${ch_root}${lib_dir} [ -f ${ch_root}${loop} ] | | cp $loop ${ch_root}${lib_dir} done} read -p " please input a command: " command while [ " $command " != " Quit " ];d o if bincopy $command ;then libcopy $command fi read -p "please input a command or quit: " commanddone
8. Open a new Linux and use just that disk as the new Linux boot drive
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/87/53/wKiom1fc73Wy_0wcAA6SzwwHWmM357.gif "title=" 3.gif " alt= "Wkiom1fc73wy_0wcaa6szwwhwmm357.gif"/>
Thank you for browsing ...
This article is from the "Endless Learning" blog, please be sure to keep this source http://dashui.blog.51cto.com/11254923/1853375
Make a little Linux of your own