Private Custom-linux System

Source: Internet
Author: User


Self-made Linux systems:


1. Partitioning and creating the file system

[Email protected] ~]# Fdisk/dev/sdb

Divided into two necessary partitions

/DEV/SDB1 corresponding/boot/dev/sdb2 corresponding to the root/

To create a file system:

[Email protected] ~]# mkfs.ext4/dev/sdb1[[email protected] ~]# MKFS.EXT4/DEV/SDB2


2. Create mount point and Mount Boot

[Email protected] ~]# mkdir/mnt/boot[[email protected] ~]# mount/dev/sdb1/mnt/boot


3. Install grub to generate grub files

[Email protected] ~]# Grub-install--root-directory=/mnt//dev/sdb

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/87/49/wKioL1fbXY3QWc0nAAAT2PlX1Bo997.png "title=" 1.png " alt= "Wkiol1fbxy3qwc0naaat2plx1bo997.png"/>


4, Establish grub.conf:

[Email protected] ~]# vim/mnt/boot/grub/grub.conf
Default=0timeout=3title mylinux Root (hd0,0) kernel/vmlinuz-2.6.32-642.el6.x86_64 root=/dev/sda2 selinux=0 Init=/bi N/bash initrd/initramfs-2.6.32-642.el6.x86_64.img


5. Restore kernel and Initramfs files

[Email protected] ~]# cp/boot/vmlinuz-2.6.32-642.el6.x86_64/mnt/boot/[[email protected] ~]# cp/boot/ initramfs-2.6.32-642.el6.x86_64.img/mnt/boot/

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/4C/wKiom1fbX9Tj49aVAAAlhI0v-PM339.png "title=" 2.png " alt= "Wkiom1fbx9tj49avaaalhi0v-pm339.png"/>


6. Create a level directory

[Email protected] ~]# mkdir/mnt/sysroot/[[email protected] ~]# mount/dev/sdb2/mnt/sysroot/
[Email protected] ~]# Mkdir–pv/mnt/sysroot/{etc,lib,lib64,bin,sbin,tmp,var,usr,sys,proc,opt,home,root,boot,dev, Mnt,media}

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/87/49/wKioL1fbYPqCl9v3AAAR3lGTkto147.png "title=" 3.png " alt= "Wkiol1fbypqcl9v3aaar3lgtkto147.png"/>


7. Edit the Fstab file

[Email protected] ~]# Vim/mnt/sysroot/etc/fstab
/dev/sda1/boot ext4 Defaults 1 1/DEV/SDA2/EXT4 defaults 1 2


8. Copy bash, related commands and related library files


Because of the large number of files, one copy is more cumbersome, so it is recommended to use scripts to implement replication tasks.

[Email protected] ~]# vim copycmd.sh
#!/bin/bashch_root= "/mnt/sysroot" [ ! -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  "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:  " commandwhile [ " $command  !=  "quit"  ];d o     if bincopy  $command  ;then         libcopy  $command     fi    read -p  "Please input  a command or quit:  " commanddone 

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/4C/wKiom1fbadmgy1XbAAAXEVfWgCo546.png "title=" 4.png " alt= "Wkiom1fbadmgy1xbaaaxevfwgco546.png"/>


9, now a know that Linux has been made to complete, it has a very simple function, but there is a need to add additional features later. Let's take a look at the boot.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/87/4C/wKiom1fbfHeAKz5bAAtzUSuSnGw946.gif "title=" Gif.gif "width=" 735 "height=" 415 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:735px;height:415px; "alt=" Wkiom1fbfheakz5baatzususngw946.gif "/>


In this way, a simple small Linux has been made to complete, you can put it on a USB stick and other portable devices, can be used at any time, modify and so on ...

This article is from the "I ' m Groot" blog, so be sure to keep this source http://groot.blog.51cto.com/11448219/1853090

Private Custom-linux System

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.