1、添加一块新硬盘、并使系统识别
[root@centos6 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan [root@centos6 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan [root@centos6 ~]# echo "- - -" > /sys/class/scsi_host/host2/scan [root@centos6 ~]# lsblk ............. sdc 8:32 0 20G 0 disk
2、分区,格式化
[root@centos6 ~]# fdisk /dev/sdc [root@centos6 ~]# lsblk sdc 8:32 0 20G 0 disk ├─sdc1 8:33 0 305.9M 0 part ├─sdc2 8:34 0 10G 0 part ├─sdc3 8:35 0 1K 0 part (扩展分区) └─sdc5 8:37 0 2G 0 part [root@centos6 ~]# mkfs.ext4 /dev/sdc1 [root@centos6 ~]# mkfs.ext4 /dev/sdc2 [root@centos6 ~]# blkid /dev/sdc1: UUID="b08d627b-e0ac-4623-9a72-7b9aecfc005e" TYPE="ext4" /dev/sdc2: UUID="e80e35d8-d510-4d17-be71-561a3a48cfbb" TYPE="ext4"
3、进行新系统的boot目录制作
[root@centos6 ~]# mkdir /mnt/boot [root@centos6 ~]# mount /dev/sdc1 /mnt/boot [root@centos6 ~]# grub-install --root-directory=/mnt /dev/sdc [root@centos6 ~]# cp /boot/initramfs-2.6.32-642.el6.x86_64.img /mnt/boot/initramfs [root@centos6 ~]# cp /boot/vmlinuz-2.6.32-642.el6.x86_64 /mnt/boot/vmlinuz [root@centos6 ~]# ls /mnt/boot/ grub initramfs lost+found vmlinuz [root@centos6 ~]# vim /mnt/boot/grub/grub.conf default=0 timeout=5 hiddenmenu title My Mini Linux root (hd0,0) kernel /vmlinuz ro root=/dev/sda2 selinux=0 init=/bin/bash initrd /initramfs
4、进行新系统的/目录制作
[root@centos6 ~]# mkdir /mnt/sysroot [root@centos6 ~]# mount /dev/sdc2 /mnt/sysroot/ [root@centos6 ~]# cd /mnt/sysroot/ [root@centos6 sysroot]# ls lost+found [root@centos6 sysroot]# mkdir {bin,boot,dev,etc,home,lib,lib64,proc,root,sbin,sys,usr} [root@centos6 sysroot]# ls bin boot dev etc home lib lib64 lost+found proc root sbin sys usr [root@centos6 sysroot]# copycmd.sh bash (自己编写的命令复制脚本)[手动复制时,注意路径和库文件要一并复制] 复制一些常用的命令:echo ls cat cd pwd mkdir touch... [root@centos6 sysroot]# tree bin bin ├── bash ├── cat ├── ls ├── mkdir ├── pwd └── touch 0 directories, 6 files [root@centos6 sysroot]# tree lib64 lib64 ├── ld-linux-x86-64.so.2 ├── libacl.so.1 ├── libattr.so.1 ├── libcap.so.2 ├── libc.so.6 ├── libdl.so.2 ├── libpthread.so.0 ├── librt.so.1 ├── libselinux.so.1 └── libtinfo.so.5 0 directories, 10 files
5、测试启动
原创文章,作者:sixijie,如若转载,请注明出处:http://www.178linux.com/46280