最近使用VNC远程重装一台Linux操作系统,心得如下:

1. 一定要详细记录原有服务器的网络参数,IP,MASK,Gateway。

2. 测试原系统对外访问能力,保证安装镜像能正确获取。

3. 复制引导文件

mkdir /centos_install
cd /centos_install
wget http://ip/centos/6.8/images/pxeboot/initrd.img
wget http://ip/centos/6.8/images/pxeboot/vmlinuz
cp vmlinuz /boot/vmlinuz.cent.pxe
cp initrd.img /boot/initrd.img.cent.pxe

4. 安装引导(原系统为Centos6)

vi /boot/grub/grub.conf
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS 6 (2.6.32-642.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root nomodeset rd_NO_LUKS rd_NO_MD rd_LVM_LV=VolGroup/lv_swap crashkernel=auto LANG=zh_CN.UTF-8 rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-642.el6.x86_64.img
上述root为系统安装位置,远程启动镜像也在此处,在hideenmenu下添加:

title Centos Install (PXE) 
root (hd0,0)
kernel /vmlinuz.cent.pxe vnc vncpassword=123457 headless ip=x.x.x.x netmask=255.255.255.0 gateway=x.x.x.x dns=8.8.8.8 ksdevice=em1 method=http://ip/centos/6.8/ lang=en_US keymap=us 
initrd /initrd.img.cent.pxe
安装位置要对应,kernel行要替换为原有系统的网络配置信息。

5. 安装引导(原系统为Centos7)

vi /etc/grub.d/05_PXE
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
menuentry "PXE" {
set root=(hd0,gpt2)
kernel /vmlinuz.cent.pxe vnc vncpassword=123457 headless ip=x.x.x.x netmask=255.255.255.0 gateway=x.x.x.x dns=8.8.8.8 ksdevice=em1 method=http://ip/centos/6.8/ lang=en_US keymap=us 
initrd /initrd.img.cent.pxe
上述root,一定要与/boot/grub2/grub.conf中启动项相同!

vi /etc/default/grub

将
GRUB_DEFAULT=saved
改为
GRUB_DEFAULT=PXE

最后
grub2-mkconfig  -o /boot/grub2/grub.cfg 

生成新的启动文件,检查/boot/grub2/grub.conf看生成的文件是否正确


6. 重新启动系统,用vnc_view连接 IP:5001,即可启动安装过程。

7. 安装完成后的网络操作。

    安装完成后,进行网络配置,要注意以下两点:

    1. 多网口,一定要保留安装时生成的网口的配置不动,等其它网口配置成功后,再进行下步操作

    2. 要使网络配置改变,要用reboot,  service network restart会造成服务器无法连接。

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐