Self-made Linux small system

Source: Internet
Author: User

Homemade Linux

Today God said how to make a self-made Linux, that is, with a new hard disk to make a Linux. The hard drive is torn down and crashed into other machines and can be used as usual, and everything needs to be added yourself.

I'm going to do it in the virtual machine. Hey ...

1. Add a new hard drive to my centos and divide the area and format it.

[[email protected] ~]# fdisk /dev/sdbwarning: dos-compatible mode is  Deprecated. it ' s strongly recommended to          switch off the mode  (command  ' C ')  and change display units  to         sectors  (command  ' u '). command  (m for help):  ncommand action   e   extended    p   primary partition  (1-4) ppartition number  (1-4):  1first cylinder  (1-2610, default 1): Using default value 1last cylinder , +cylinders or +size{k,m,g}  (1-2610, default 2610): +10GCommand  (M  FOR HELP): ncommand action   e   extended    P   primary partition  (1-4) ppartition number  (1-4): 2first cylinder  (1307-2610, default  1307): Using default value 1307last cylinder, +cylinders or +size{k,m, g}  (1307-2610, default 2610):using default value 2610command  (m for  HELP):  wthe partition table has been altered! Calling ioctl ()  to re-read partition table. Syncing disks. [[email protected] ~]# lsblkname   maj:min rm  size ro  type mountpointsr0     11:0    1  3.7g   0 rom  /media/centos_6.9_finalsda      8:0     0  200G  0 disk├─sda1   8:1    0     1g  0 part /boot├─sda2   8:2    0   50g  0 part /├─sda3   8:3     0   50G  0 part /app├─sda4   8:4     0    1K  0 part└─sda5   8:5     0    2G  0 part [SWAP]sdb       8:16   0   20G  0 disk├─sdb1   8:17    0   10G  0 part└─sdb2   8:18   0    10g  0 part         = "SDB is my new hard drive, Divided into two 10G partitions. [[email protected] ~]#

[[email protected] ~]# mkfs.ext4 /dev/sdb1mke2fs 1.41.12  (17-May-2010) Filesystem  label=OS type: LinuxBlock size=4096  (log=2) fragment size=4096  (log=2) stride=0 blocks, stripe width=0 blocks655776 inodes, 2622603 blocks131130  blocks  (5.00%)  reserved for the super userfirst data block= 0maximum filesystem blocks=268854886481 block groups32768 blocks per group,  32768 fragments per group8096 inodes per groupsuperblock backups  STORED ON BLOCKS: 32768, 98304, 163840, 229376, 294912, 819200,  884736, 1605632Writing inode tables: done                              creating journal  (32768 blocks):  donewriting superblocks and filesystem accounting  information: donethis filesystem will be automatically checked every  20 mounts or180 days, whichever comes first.  use tune2fs  -c or -i to override. [[email protected] ~]#

Create two partitions one is mounted for the root directory and the other is for boot mount.

2. Create the/media/boot under your own Linux (the boot is the boot that was made), and then mount the/dev/sda1 to/media/boot, which is not a demonstration.

3. Install Grub:grub-install--root-directory=/media/dev/sdb later (cannot be sdb{1,2},grub installation is 446 bytes not yet partition before installation)

[[email protected] ~]# grub-install --root-directory=/media/ /dev/sdbprobing  Devices to guess bios drives. this may take a long time. Installation finished. no error reported. this is the contents of the device map /media//boot/grub/ if this is correct or not. if any of the  lines is incorrect,fix it and re-run the script  ' Grub-install '. (fd0)/dev/fd0 (hd0)/DEV/SDA (HD1)/dev/sdb[[email protected] ~]#[[email protected] ~]#[[email  protected] grub]# pwd/media/boot/grub[[email protected] grub]#         jfs_stage1_5       ufs2_ stage1_5e2fs_stage1_5     minix_stage1_5    &Nbsp;vstafs_stage1_5fat_stage1_5      reiserfs_stage1_5  xfs_stage1_ 5ffs_stage1_5      stage1iso9660_stage1_5  stage2[[email  protected] grub]#        === "Now there's a basic file under grub.

4. Copy some important documents. The Vm,init file name on my machine is defined by myself, and may not be the same as other versions.

[[email protected] ~]# cp/boot/vmlinuz/media/boot/[[email protected] ~]# Cp/boot/initramfs.img/media/boot/[[email Pro Tected] ~]#

5. Create an edit grub.conf file

[Email protected] ~]# vim/media/boot/grub/grub.confdefault=0timeout=5title cnetos 8.8 kernel/vmlinuz root=/dev/s Da2 Init=/bin/bash initrd/initramfs.img~

Kernel and INITRD add two files for my fourth copy, so the file name is the same.

6. I made a script in advance, the script function is the input command, the command and associated libraries are CP to a directory (that is, now the newly created boot), using this script to implement their own small Linux command function.

[[email protected] ~]# please  Input command (q or quit)  : ls Please enter a destination path (absolute path):  /media/bin/ls  ======> / Media/bin /lib64/ ======> /media/lib64/ /lib64/  ======> /media/lib64/ /lib64/ ======> /media/lib64/ /lib64/ ======> /media/lib64/ /lib64/ = =====> /media/lib64/ /lib64/ ======> /media/lib64/  /lib64/ ======> /media/lib64/ /lib64/ ======> /media/lib64/ /lib64/ ======>  /media/lib64/ 

function as above, after copying the important commands you need to create this simple Linux is almost complete.

[[email protected] media]# mkdir {etc,root,sys,usr,var,proc}[[email protected] media]# lsbin Dev Home lib64 proc Sbin tmp Varboot etc lib lost+found root sys usr is now almost like a simple Linux.

It's now possible to install this own hard drive on other machines and see how it works.

650) this.width=650; "title=" 3s}ekez1$z3w ' 5y~lze} (ts.png "src=" Wkiom1nbfecbedpkaaa5vkvt8pe605.png-wh_500x0-wm_3-wmp_4-s_3964665841.png "alt=" Wkiom1nbfecbedpkaaa5vkvt8pe605.png-wh_50 "/>

This article is from the "Mlon Guest" blog, please be sure to keep this source

Self-made Linux small system

Related Article

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: 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.