linux启动,grub,kickstart

1、简述linux操作系统启动流程

  • post→boot sequence(bios)→boot loader(mbr)→kernel(ramdisk)→rootfs→switchroot→/sbin/init→/etc/inittab,/etc/init/*.conf→设定默认运行级别→系统初始化脚本→关闭或启动对应级别的服务→启动终端

2、简述grub启动引导程序配置及命令行接口详解

命令行接口

  • help
  • help COMMAND
  • root (hd0,0)设定根分区为第一块磁盘的第一个分区
  • find (hd0,0)/PATH 查找文件
  • kernel /PATH init=/sbin/init selinux=0 ro root=/dev/DEVICE 设定内核文件
  • initrd /PATH 设定ramdisk
  • boot 启动

    配置文件

  • /etc/grub.conf 是/boot/grub/grub.conf的软链接
  • 配置项:
    • hiddenmenu:隐藏菜单
    • timeout:超时时间
    • default:默认启动菜单项,从0开始
    • splashing:图片
    • title:标题
    • password --md5 STRING:编辑内核时要按p输入密码(使用grub-md5-crypt生成)

3、实现kickstart文件制作与光盘镜像制作

kickstart文件

  • 包括命令段,程序包段,脚本段

    命令段
  • 必备:
    • 认证方式:authconfig --enableshadow --passalgo=sha512
    • bootloader位置:bootloader --location=mbr --dirverorder=sda --append="crashkernel=auto rhgb quiet"
    • 键盘:keyboard us 美式
    • 语言:lang en_US.UTF-8
    • 清空mbr:zerombr
    • 清除分区:clearpart --all
    • boot分区:part /boot --fstype=ext4 --size=500
    • pv分区:part pv.008002 --size=51200
    • 卷组:volgroup myvg --pesize=4096 pv.008002
    • lv:logvol / --fstype=ext4 --size=10240 myvg
    • 密码:rootpw --iscrypted (使用openssl passwd -1 -salt `openssl rand -hex 4`生成)
    • 时区:timezone Asiz/Shanghai
  • 可选:
    • install:或upgrade 安装或升级
    • img文件:url url=http://PATH 或cdrom
    • 文本:text,默认gui
    • 网络:network --onboot yes --device eth0 --bootproto dhcp --noipv6
    • 防火墙:firewall --disabled
    • selinux:selinux --disabled
    • 安装后命令:halt poweroff reboot
    • repo源:repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100

      程序包段
%package
@group_name
package
-package
%end
脚本段
  • %pre:安装前脚本
  • %post:安装后脚本

制作kickstart文件

  • 使用system-config-kickstart 图形工具生成ks.cfg
  • 使用ksvalidator验证ks文件的有效性

    制作启动iso

  • 将源系统的isolinux文件夹和ks文件拷贝到myboot
  • 修改配置文件 isolinux.cfg timeout=3 ks=cdrom:/ks.cfg
  • 使用mkisofs制作iso

[root@centos6-mould myboot]# cat ks.cfg
# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
text
url --url=http://mirrors.aliyun.com/centos/6.9/os/x86_64/
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw --iscrypted $6$7Qqmg6dcGcdJctX3$1pOxPQQaczPgnVS2DxM9OX728VAqtg4Nq5NbXbKDlcyVJClmPMbLMBxhWYJfz9WsSym3toubAEpFI5k8ifjzP0
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone 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
zerombr
clearpart --all

part /boot --fstype=ext4 --asprimary --size=500
part swap --asprimary --size=1024
part / --fstype=ext4 --grow --asprimary --size=200


repo --name="CentOS" --baseurl=http://mirrors.aliyun.com/centos/6.9/os/x86_64/ --cost=100

%packages
@core
@server-policy
@workstation-policy
@Base
@Development tools
%end
[root@centos6-mould myboot]# chmod u+w isolinux/ -R
[root@centos6-mould myboot]# mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --boot-info-table -V "centos 6 boot x86_64" -c isolinux/boot.cat -b isolinux/isolinux.bin -o /root/boot.iso myboot

猜你喜欢

转载自www.cnblogs.com/xuluchuan/p/9271831.html