一、请详细描述CentOS系统的启动流程(详细到每个过程系统做了哪些事情)
1)加电自检,BIOS启动引导阶段; 在该过程中实现硬件的初始化以及查找启动介质; 从MBR中装载启动引导管理器(GRUB)并运行该启动引导管理; 2)GRUB启动引导阶段; 装载stage1 装载stage1.5 装载stage2 读取/boot/grub.conf文件并显示启动菜单; 装载所选的kernel和initrd文件到内存中 3)内核阶段: 运行内核启动参数; 解压initrd文件并挂载initd文件系统,装载必须的驱动; 挂载根文件系统 4)init用户空间初始化阶段: 启动/sbin/init程序; 运行rc.sysinit脚本,设置系统环境,启动swap分区,检查和挂载文件系统; 读取/etc/inittab文件,运行在/et/rc.d/rc<#>.d中定义的不同运行级别的服务初始化脚本; 打开字符终端1-6号控制台/打开图形显示管理,设置登录
二、为运行于虚拟机上的CentOS 6添加一块新硬件,提供两个主分区;
(1) 为硬盘新建两个主分区;并为其安装grub;
(2) 为硬盘的第一个主分区提供内核和ramdisk文件; 为第二个分区提供rootfs;
(3) 为rootfs提供bash、ls、cat程序及所依赖的库文件;
(4) 为grub提供配置文件;
(5) 将新的硬盘设置为第一启动项并能够正常启动目标主机;
[10:45:49 [email protected]_S ~]# fdisk /dev/sdc #为新硬盘新建两个主分区 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xb29dae4d. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won‘t be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: 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): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-2610, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +10G Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (1307-2610, default 1307): Using default value 1307 Last cylinder, +cylinders or +size{K,M,G} (1307-2610, default 2610): Using default value 2610 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [10:58:53 [email protected]_S ~]#mkfs -t ext4 /dev/sdc1 [10:58:53 [email protected]_S ~]#mkfs -t ext4 /dev/sdc2 [11:09:31 [email protected]_S ~]#mkdir /mnt/{boot,sysroot} [11:09:33 [email protected]_S ~]#mount /dev/sdc1 /mnt/boot/ [11:10:03 [email protected]_S ~]#mount /dev/sdc2 /mnt/sysroot/ [11:26:36 [email protected]_S ~]#cp /boot/vmlinuz-2.6.32-431.el6.x86_64 /mnt/boot/ [11:26:37 [email protected]_S ~]#cp /boot/initramfs-2.6.32-431.el6.x86_64.img /mnt/boot/ [11:28:52 [email protected]_S ~]# vim /mnt/boot/grub/grub.conf #新建一个 grub 配置文件 default=0 timeout=15 title CentOS6.5 homemake root (hd0,0) kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/sdc2 selinux=0 init=/bin/bash initrd /initramfs-2.6.32-431.el6.x86_64.img [11:31:29 [email protected]_S ~]#mkdir -p /mnt/rootfs/{bin,lib64} [11:31:30 [email protected]_S ~]#cp -r /bin/{bash,ls,cat} /mnt/rootfs/bin/ #复制bash,ls,cat,所依赖的库文件 [11:31:36 [email protected]_S ~]#cp $(ldd /bin/bash | awk ‘$3~/^\/lib64/{print $3}‘) /mnt/rootfs/lib64/# [11:31:42 [email protected]_S ~]#cp $(ldd /bin/ls | awk ‘$3~/^\/lib64/{print $3}‘) /mnt/rootfs/lib64/ [11:31:54 [email protected]_S ~]#cp $(ldd /bin/cat | awk ‘$3~/^\/lib64/{print $3}‘) /mnt/rootfs/lib64/ 重启服务器设置从sdc启动进入系统
三、制作一个kickstart文件以及一个引导镜像。描述其过程。
[16:27:10 [email protected]_S ~]#cat myks.cfg # Kickstart file automatically generated by anaconda. #version=DEVEL install cdrom lang zh_CN.UTF-8 keyboard us network --onboot no --device eth0 --bootproto dhcp --noipv6 rootpw --iscrypted $6$We6z2yOuLLzQlEQQ$97ev7j9SgwMI0P5hRj79nccpgyPxqIQxSixn69PUIsJA/BmnY92sFl7QoBF2W4IeS79Nm.c0iI5ACdVqWOCFT/ firewall --service=ssh authconfig --enableshadow --passalgo=sha512 selinux --enforcing timezone --utc Asia/Shanghai bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" # The following is the partition information you requested # Note that any partitions you deleted are not expressed # here so unless you clear all partitions first, this is # not guaranteed to work #clearpart --none #part /boot --fstype=ext4 --size=200 #part swap --size=8192 #part / --fstype=ext4 --grow --size=200 repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100 %packages @base @chinese-support @core @debugging @development @directory-client @java-platform @network-file-system-client @print-client @server-platform @server-policy @workstation-policy pax oddjob sgpio device-mapper-persistent-data systemtap-client jpackage-utils samba-winbind certmonger pam_krb5 krb5-workstation [16:32:50 [email protected]_S ~]#mkdir -p /data/iso/isolinux [16:34:41 [email protected]_S ~]#cp /media/isolinux/* /data/iso/isolinux/ [16:35:13 [email protected]_S ~]#cp /root/anaconda-ks.cfg /data/iso/isolinux/myks.cfg [16:36:47 [email protected]_S ~]#mkisofs -R -J -T -v –no-emul-boot –boot-load-size 4 –boot-info-table -V "CentOS 6.8 x86_64 boot" -b /data/iso/isolinux/isolinux.bin -c /data/iso/isolinux/boot.cat -o /root/boot.iso myiso #创建引导镜像
时间: 2024-10-08 07:36:08