分享一个KVM(独服)面板无VNC,使用centos自带VNC重装纯净系统

coolsd 2019-4-2 100


本教程受Hetzner的VNC安装模块启发,研究改编(可用作阿里云安装纯净系统,以及任意版本操作系统)
需要默认系统Centos7(本人常用熟悉,其他系统应该大同小异)
1. 确定你的网卡名称,IP等相关信息。后面需要用到   网卡名称,IP,网关,子网掩码
2.下载 CentOS 的 bootstrap 文件 用于启动Centos可视化安装界面。一般各种版本Linux ISO镜像文件都有


  1. yum install wget
  2. cd /boot
  3. wget http://mirror.centos.org/centos/7/os/x86_64/isolinux/vmlinuz -O vmlinuz-7
  4. wget http://mirror.centos.org/centos/7/os/x86_64/isolinux/initrd.img -O initrd-7.img

复制代码
3. 添加自定义VNC安装grub启动条目
从/boot/grub2/grub.cfg 复制出当前grub引导项的内容
例如:(切记不要拷贝我的,每个机器都有UID,直接复制无法引导启动后果自负)


  1. menuentry 'CentOS Linux (3.10.0-327.22.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-327.el7.x86_64-advanced-5abaf349-18ce-4481-8e31-f29b0120827f' {

  2.         load_video
  3.         set gfxpayload=keep
  4.         insmod gzio
  5.         insmod part_msdos
  6.         insmod xfs
  7.         set root='hd0,msdos1'
  8.         if [ x$feature_platform_search_hint = xy ]; then
  9.           search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  3ee40dd3-d836-4aa5-b145-9fbc2541b151
  10.         else
  11.           search --no-floppy --fs-uuid --set=root 3ee40dd3-d836-4aa5-b145-9fbc2541b151
  12.         fi
  13.     linux16 /vmlinuz-3.10.0-327.22.2.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet.UTF-8
  14.         initrd16 /initramfs-3.10.0-327.22.2.el7.x86_64.img
  15. }

复制代码
然后把这一段粘贴到到/etc/grub.d/40_custom中做以下修改:


  1. menuentry [color=Red]'VNCInstall'[/color] {
  2.         load_video
  3.         set gfxpayload=keep
  4.         insmod gzio
  5.         insmod part_msdos
  6.         insmod xfs
  7.         set root='hd0,msdos1'
  8.         if [ x$feature_platform_search_hint = xy ]; then
  9.           search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  3ee40dd3-d836-4aa5-b145-9fbc2541b151
  10.         else
  11.           search --no-floppy --fs-uuid --set=root 3ee40dd3-d836-4aa5-b145-9fbc2541b151
  12.         fi
  13.     [color=Red]linux16 /boot/vmlinuz-7 inst.vnc inst.vncpassword=VNC密码(最少8位), inst.headless ip=主IP::网关:子网掩码::网卡名称:none nameserver=114.114.114.114 inst.repo=http://mirror.centos.org/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us
  14.     initrd16 /boot/initrd-7.img[/color]
  15. }

复制代码


inst.repo 这个是网络安装盘,没试过windows盘,爱折腾的可以试试,相当于解压ISO列出文件即可安装
#注意之前下载文件的路径需要修改,下载在那里修改对应位置
打开 /etc/default/grub
修改 GRUB_DEFAULT=0 为 GRUB_DEFAULT=saved
(有些默认就是saved,别强迫症一定要改)
4. 重建配置,使配置生效
grub2-mkconfig -o /boot/grub2/grub.cfg
##查看所有启动项
awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg

# 下一次启动使用VNCInstall,仅使用一次
grub2-reboot VNCInstall

reboot

上述信息没问题,等待1-10分钟左右,根据机器网络而定
然后打开VNC 输入IP:1  连接成功则说明引导成功,可以开始可视化安装了

附一张成功图


最新回复 (1)
  • coolsd 2019-4-3
    引用 2
    https://www.hostloc.com/thread-535747-1-1.html
返回
发新帖
本站文章均收录自网上,仅做参考用。 欢迎大家添砖加瓦,发表一些自己使用过程中遇到的问题以及解决方法。