自己动手给国内外各种云重装纯净版的CentOS7.x

自己动手给国内外各种云重装纯净版的CentOS7.x
需要自己动手给国内外各种云重装纯净版的CentOS7.x或者其他Linux系统
前文 自己动手给国内外各种云重装纯净版的CentOS6.x

CentOS7使用的是grub2,/boot/grub2/grub.cfg (由grub2-mkconfig -o /boot/grub2/grub.cfg生成)
-----------------------------------------------------------------------------------------------
1、国内
wget -O /boot/vmlinuz.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe https://mirrors.aliyun.com/centos/7/os/x86_64/images/pxeboot/initrd.img

国外
wget -O /boot/vmlinuz.centos.pxe http://ftp.cuhk.edu.hk/pub/Linux/centos/7/os/x86_64/images/pxeboot/vmlinuz
wget -O /boot/initrd.img.centos.pxe http://ftp.cuhk.edu.hk/pub/Linux/centos/7/os/x86_64/images/pxeboot/initrd.img
-------------------------------------------------------------------------------------------------
2、cd /etc/grub.d
ls
00_header 01_users 20_linux_xen 30_os-prober 41_custom
00_tuned 10_linux 20_ppc_terminfo 40_custom README

vi 40_custom

将下面的信息添加进去
menuentry 'www.zhangfangzhou.cn' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe headless ip=122.114.224.36 noipv6 netmask=255.255.255.0 gateway=122.114.224.1 dns=114.114.114.114 ksdevice=eth0 method=http://mirrors.aliyun.com/centos/7/os/x86_64/ devfs=nomount lang=en_US keymap=us
initrd16 /initrd.img.centos.pxe
}

上面的IP、掩码、网关、修改为你机器的就可以

set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe
initrd16 /initrd.img.centos.pxe
这三项信息需要查看/boot/grub2/grub.cfg具体来设置

----------------
正规写法

menuentry 'www.zhangfangzhou.cn' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe inst.headless ip=122.114.224.36::122.114.224.1:255.255.255.0::eth0:none nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /initrd.img.centos.pxe
}

insmod xfs
set root='hd0,msdos1'
linux16 /vmlinuz.centos.pxe
initrd16 /initrd.img.centos.pxe
这四项信息需要查看/boot/grub2/grub.cfg具体来设置

如果磁盘用的是GPT格式的,需要添加inst.gpt选项。 If you are using GPT disk add inst.gpt option.
linux16 /vmlinuz.centos.pxe inst.gpt inst.headless ip=122.114.224.36::122.114.224.1:255.255.255.0::eth0:none nameserver=114.114.114.114 inst.repo=https://mirrors.aliyun.com/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
initrd16 /initrd.img.centos.pxe

CentOS 6 CentOS 7
vnc inst.vnc
vncpassword= inst.vncpassword=
Note: MUST at least 8 char
headless inst.headless
ip= ip=ip::gateway:netmask:hostname:interface:none
Example:
ip=10.0.0.10::10.0.0.1:255.255.255.0:host.example.com:eth0:none or ip=dhcp
gateway= See IP above
netmask= See IP above
dns= nameserver=
method= inst.repo=
lang= inst.lang=
keymap= inst.keymap=

你可以阅读整个选项变化
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-anaconda-boot-options
----------------

ls -l /etc/grub2.cfg
lrwxrwxrwx 1 root root 22 Oct 28 17:25 /etc/grub2.cfg -> ../boot/grub2/grub.cfg

3、重新生成/boot/grub2/grub.cfg
执行grub2-mkconfig -o /boot/grub2/grub.cfg

4、设置默认启动项
grub2-set-default www.zhangfangzhou.cn

5、grub2-editenv list #查看确认

6、reboot
打开vnc连接选择启动项www.zhangfangzhou.cn就可以重装了

7、信息补充
rhgb quiet
rhgb表示redhat graphics boot,就是会看到图片来代替启动过程中显示的文本信息,这些信息在启动后用dmesg也可以看到
quiet表示在启动过程中只有重要信息显示,类似硬件自检的消息不回显示

rhgb = redhat graphical boot - This is a GUI mode booting screen with
most of the information hidden while the user sees a rotating activity
icon spining and brief information as to what the computer is doing.
quiet = hides the majority of boot messages before rhgb starts. These
are supposed to make the common user more comfortable. They get alarmed
about seeing the kernel and initializing messages, so they hide them for
their comfort.

8、
也可以添加一些自定义的启动选项
menuentry "System shutdown" {
echo "System shutting down..."
halt
}

menuentry "System restart" {
echo "System rebooting..."
reboot
}