Create a small Linux bare metal-2015090401 that will boot successfully

Source: Internet
Author: User
Tags uuid

we use our own to create a normal boot Linux system, but the function is not sound, only for it to boot properly: the steps are as follows:

First step: Add a new hard disk to the virtual machine

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/9D/wKioL1XpXVPxsYELAAI5tEtnSUY155.jpg "title=" 1.png " alt= "Wkiol1xpxvpxsyelaai5tetnsuy155.jpg"/>

Step Two: Create partitions on the new hard disk, 1/boot, 1 swap partitions , one root partition:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/9D/wKioL1XpXWTDuWA2AACxfrpAPVI365.jpg "title=" 2. PNG "alt=" wkiol1xpxwtduwa2aacxfrpapvi365.jpg "/>

[[EMAIL PROTECTED] ~]# FDISK -L /DEV/SDB DISK /DEV/SDB: 21.5 GB,  21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersunits =  cylinders of 16065 * 512 = 8225280bytesSector size  (logical/ Physical): 512 bytes /512 bytesi/o size  (minimum/optimal):  512 bytes  / 512bytesDisk identifier: 0x950bee79   Device Boot       Start         End      blocks   id  system/dev/sdb1                1          26       208813+ 83  Linux/dev/sdb2               27         158    1060290    82  linux swap / solaris# #swap分区类型需要调整为82   Linux  swap / solaris/dev/sdb3              159         812    5253255    83  Linux[[email protected] ~]# partx -a /dev/sdb            # #通知内核重读新分区BLKPG: device or resource  Busyerror adding partition 1blkpg: device or resource busyerror adding  partition 2BLKPG: Device or resource busyerror adding partition  3

Step three: Create a file system for the new partition

[[email protected] ~]# mkfs.ext3 /dev/sdb1mke2fs 1.41.12  (17-May-2010) Filesystem  label=OS type: LinuxBlock size=1024  (log=0) fragment size=1024  (log=0) stride=0 blocks, stripe width=0 blocks52208 inodes, 208812 blocks10440  blocks  (5.00%)  reserved for the superuserfirst data block=1maximum  filesystem blocks=6737100826 block groups8192 blocks per group, 8192  fragments pergroup2008 inodes per groupsuperblock backups stored on  blocks:         8193,24577, 40961, 57345,  73729, 204801 writing inode tables: done                              creating journal  (4096 blocks): donewriting superblocks and filesystemaccounting  information: done this filesystem will be automaticallychecked every  37 mounts or180 days, whichever comes first.  use tune2fs -c  or -i to override. [[email protected] ~]# mkfs.ext3 /dev/sdb3mke2fs 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 blocks328656 inodes, 1313313 blocks65665  blocks  (5.00%)  reserved for the superuserfirst data block=0maximum  filesystem blocks=134637158441 block groups32768 blocks per group,  32768 fragments pergroup8016 inodes per groupsuperblock backups stored on blocks:         32768,98304, 163840,  229376, 294912, 819200, 884736 Writing inode tables: done                             Creating journal  (32768 blocks):  donewriting  superblocks and filesystemaccounting information: done this filesystem  will be automaticallychecked every 27 mounts or180 days,  Whichever comes first.  use tune2fs -c or -i to override. [[email protected] ~]# mkswap /dev/sdb2      # #创建交换分区Setting  up swapspace version 1, size =1060284 kibno label,uuid= 9e278322-0033-4bdc-8739-a621149f0179[[email p rotected] ~]# blkid /dev/sdb1     # #显示分区属性, the boot partition is formatted successfully/DEV/SDB1:  label= "Boot part" uuid= "Ce836e56-3bbf-47b0-a646-846e1b5d23d6"  type= "ext3" SEC_TYPE= "ext2" [[Email  protected] ~]# blkid /dev/sdb2     # #显示分区属性, swap partition format succeeded/DEV/SDB2 : uuid= "9e278322-0033-4bdc-8739-a621149f0179"  type= "swap" [[email protected] ~]# blkid  /dev/sdb3     # #显示分区属性, the root partition is formatted successfully/dev/sdb3: label= "root" uuid= " 02EC22DF-7F8C-4CC4-82EC-79BB7F6806A2 " sec_type=" ext2 "type=" ext3 "



Fourth step: Under the /mnt directory, create boot and rootfs two partitions, and Mount Sdb1 to /mnt/boot, sdb3 Mount to /mnt/rootfs

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

Fifth Step: Create mnt in the rootfs directory , etc Dev Lib lib64 bin sbin proc SYS root home directory and use the Grub-install command to install the /c10>grub to the hard drive /dev/sdb:

[[Email protected] ~]# cd /mnt/rootfs/[[email protected] rootfs]# mkdir  -pv  mnt etc dev lib lib64 bin sbin proc sys  roothome var usrmkdir: created directory  ' mnt ' mkdir: created directory   ' etc ' mkdir: created directory  ' dev ' mkdir: created directory  ' lib ' mkdir:  created directory  ' lib64 ' mkdir: created directory  ' bin ' mkdir: created  directory  ' sbin ' mkdir: created directory  ' proc ' mkdir: created directory   ' sys ' mkdir: created directory  ' root ' mkdir: created directory  ' home ' mkdir:  created directory  ' var ' mkdir: created directory  ' usr ' [[email protected]  rootfs]# grub-install--root-directory=/mnt /dev/sdbprobing devices to guess  BIOS drives. Thismay Take a long time. Installation finished. no error reported. this is the contents of the device map/mnt/boot/grub/device.map.check  if this is correct or not. if any ofthe lines is  Incorrect,fix it and re-run the script ' Grub-install ' .  (fd0)  /dev/fd0 (hd0)          /DEV/SDA (HD1)           /dev/sdb

Sixth step: Copy the kernel and initrd files to the/mnt/boot directory, for easy configuration, here the kernel and Initramfs version number is changed to 1.1.1, and write Grub configuration file:

[Email protected] mnt]# cp/boot/vmlinuz-2.6.32-504.el6.x86_64 boot/vmlinuz-1.1.1[[email protected] mnt]# cp/boot/ Initramfs-2.6.32-504.el6.x86_64.img boot/initramfs-1.1.1.img# #initramfs和vmlinux版本号必须完全一致


to create a grub configuration file

[Email protected] mnt]# vim boot/grub/grub.conf default=0timeout=5title test-linux root (hd0,0) Kernel/vmli nuz-1.1.1 ro selinux=0 root=/dev/sda3 init=/bin/bash # #内核的初始化任务之一是激活selinux Because the small system we created is not functioning well, so we need to turn off SELinux , or boot booting is not normal, Init points the first program in user space to bash initrd/initramfs-1.1.1.img

Seventh Step: Copy the Bash program and copy the library files it depends on to the new hard disk:

[[email protected] ~]# cp -r  ' Which bash '/mnt/rootfs/bin/[[email protected]  rootfs]# ldd  ' Which bash '           linux-vdso.so.1=>   (0x00007fffda72a000)           libtinfo.so.5=> /lib64/libtinfo.so.5  (0x0000003bc6200000)           libdl.so.2=> /lib64/libdl.so.2  (0x0000003bbb600000)           libc.so.6=> /lib64/libc.so.6  (0x0000003bbba00000)           /lib64/ld-linux-x86-64.so.2 (0x0000003bbb200000) [[email protected]  rootfs]# cp /lib64/libtinfo.so.5 /mnt/rootfs/lib64/[[email protected] rootfs]#  cp /lib64/libdl.so.2/mnt/rootfs/lib64/[[email protected] rootfs]# cp /lib64/ libc.so.6/mnt/rootfs/lib64/[[email Protected] rootfs]# cp/lib64/ld-linux-x86-64.so.2 /mnt/rootfs/lib64/[[email protected]  rootfs]# sync       # #将内存中数据同步到磁盘


After performing the above operation, the new hard drive can be plugged into the new device to start: The following:

The first step:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/A1/wKiom1XpW0zytcJiAADEXfj8SRY000.jpg "title=" 3.png " alt= "Wkiom1xpw0zytcjiaadexfj8sry000.jpg"/>

Step Two:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/9D/wKioL1XpXXig1auPAAFNlM9Jo-k730.jpg "title=" 4.png " alt= "Wkiol1xpxxig1aupaafnlm9jo-k730.jpg"/>

Step Three:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/A1/wKiom1XpW13z5vPDAAEPigrUq8c216.jpg "title=" 5.png " alt= "Wkiom1xpw13z5vpdaaepigruq8c216.jpg"/>

Fourth Step:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/9D/wKioL1XpXYqSx9M6AAEVJkRy6Us956.jpg "title=" 6.png " alt= "Wkiol1xpxyqsx9m6aaevjkry6us956.jpg"/>

Fifth Step:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/A1/wKiom1XpW2_h2BfgAADLNy7ENY4842.jpg "title=" 7.png " alt= "Wkiom1xpw2_h2bfgaadlny7eny4842.jpg"/>

Sixth step:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/A1/wKiom1XpW3bCjj0iAAFJTAIRuRA836.jpg "title=" 8.png " alt= "Wkiom1xpw3bcjj0iaafjtairura836.jpg"/>

Seventh Step:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/9D/wKioL1XpXaKB2uLRAAFp3S2aDsI036.jpg "title=" 9.png " alt= "Wkiol1xpxakb2ulraafp3s2adsi036.jpg"/>

Eighth Step:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/9E/wKioL1XpXavBCjyDAADA-x2Aafc885.jpg "title=" 10.png "alt=" Wkiol1xpxavbcjydaada-x2aafc885.jpg "/>

Nineth Step: Keep the default:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/A1/wKiom1XpW5DQ2oEBAADyQ1aMed0654.jpg "title=" 11.png "alt=" Wkiom1xpw5dq2oebaadyq1amed0654.jpg "/>

Tenth step:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/A1/wKiom1XpW5nQB1ytAAFI3DFwKng416.jpg "title=" 12.png "alt=" Wkiom1xpw5nqb1ytaafi3dfwkng416.jpg "/>

Part 11th:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/9E/wKioL1XpXcajNxTZAACkKRyN9Pg569.jpg "title=" 13.png "alt=" Wkiol1xpxcajnxtzaackkryn9pg569.jpg "/>

Create complete, power-on test, need to shut down in advance to mount the new disk of the host! :

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/A1/wKiom1XpW6uieA15AACH5-tWR-M568.jpg "title=" 14.png "alt=" Wkiom1xpw6uiea15aach5-twr-m568.jpg "/>

the Grub menu is displayed. An exciting moment ————————————

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/9E/wKioL1XpXd2hNH_aAAI-_9Ci7h0838.jpg "title=" 15.png "alt=" Wkiol1xpxd2hnh_aaai-_9ci7h0838.jpg "/>

Experimental success


Create a small Linux bare metal-2015090401 that will boot successfully

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.