-
最新评论
-
丁小水:前来学习交流
-
目录
-
若要构建一套完整的linux操作系统,是十分不易的。但是如果利用想成的的发行版linux,来自行构建一个小linux,也不是什么难事,下面我们来拿U盘制作一个简单的linux吧!
步骤:
1、准本fat文件系统的U盘
2、分区格式化
[root@centos6 ~]# fdisk /dev/sdb //分区 [root@centos6 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 200M 0 part /boot ├─sda2 8:2 0 97.7G 0 part / ├─sda3 8:3 0 19.5G 0 part /testdir ├─sda4 8:4 0 1K 0 part └─sda5 8:5 0 2G 0 part [SWAP] sr0 11:0 1 3.7G 0 rom /media/CentOS_6.8_Final sdb 8:16 1 7.5G 0 disk ├─sdb1 8:17 1 105.1M 0 part └─sdb2 8:18 1 105.1M 0 part //分区完成 [root@centos6 ~]# mkfs.ext4 /dev/sdb1 [root@centos6 ~]# mkfs.ext4 /dev/sdb2 //创建文件系统
3、挂载构建grub
[root@centos6 ~]# mount /dev/sdb1 /mnt/boot [root@centos6 ~]# mount /dev/sdb2 /mnt/sysroot/ [root@centos6 ~]# grub-install /dev/sdb --root-directory=/mnt Probing devices to guess BIOS drives. This may 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 of the lines is incorrect, fix it and re-run the script `grub-install'. (fd0) /dev/fd0 (hd0) /dev/sda (hd1) /dev/sdb
4、复制内核文件
[root@centos6 boot]# pwd /mnt/boot [root@centos6 boot]# cp /boot/vmlinuz-2.6.32-642.el6.x86_64 /boot/initramfs-2.6.32-642.el6.x86_64.img ./
5、创建grub.conf
[root@centos6 grub]# pwd /mnt/boot/grub [root@centos6 grub]# vim grub.conf default=0 timeout=3 title zqlinux root (hd0,0) kernel /initramfs-2.6.32-642.el6.x86_64.img root=/dev/sda2 selinux=0 init=/bin/bash initrd /vmlinuz-2.6.32-642.el6.x86_64
5、复制必要的目录并复制二进制文件乎可文件
[root@centos6 sysroot]# pwd /mnt/sysroot [root@centos6 sysroot]# mkdir etc boot var usr proc sys mount media tmp bin bin64 lib64 lib //注意:目录一定要创建完整 [root@centos6 sysroot]# cd [root@centos6 ~]# ./copycmd.sh Please input a command: bash Please input a command or quit: ls Please input a command or quit: cat Please input a command or quit: mount Please input a command or quit: quit //复制二进制文件 [root@centos6 bin]# pwd /mnt/sysroot/bin [root@centos6 bin]# ls bash cat ls mount //查看
7、编写etc/fstab文件
[root@centos6 sysroot]# vim etc/fstab /dev/sda1 /boot ext4 defaults 1 1 /dev/sda2 / ext4 defaults 1 2
8、挂载此设备到其它虚拟机
9、重启。
最后补充一点:
如果大家感觉启动的菜单着实难看,也是可以简单修改修改的
步骤:
1、安装ImageMagick
[root@centos6 ~]# yum install ImageMagick -y
2、转换图片格式
[root@centos6 ~]# convert -resize 640x480 -colors 14 example.jpg example.xpm [root@centos6 ~]# file example.xpm example.xpm: X pixmap p_w_picpath text [root@centos6 ~]# more example.xpm
3、压缩并复制
[root@centos6 ~]# gzip example.xpm [root@centos6 ~]# cp example.xpm.gz /boot/grub/
4、修改指定配置文件
[root@centos6 ~]# vim /boot/grub/grub.conf default=0 timeout=5 splashp_w_picpath=(hd0,0)/grub/example.xpm.gz //修改路径处 hiddenmenu password --md5 $1$lMdet$z4nCL9/Kau3CIIn2NBWVS. title CentOS 6 (2.6.32-642.el6.x86_64) root (hd0,0)
5、重启
0
收藏
Ctrl+Enter 发布
发布
取消