使用VNC遠程安裝CentOS 7作業系統

來源:互聯網
上載者:User

標籤:

使用VNC遠程安裝CentOS 7作業系統

by 無若

 

資料中心一般都不在本地,如果希望重新安裝系統,難道還要跑到資料中心...
所以必須要有一種方式來遠程解決這個問題。

目前CentOS 7主要使用的引導方式是grub2,這與過去的grub1差別其實是很大的。

 

1. 確定你的網卡名稱,IP等相關資訊

# 查看 IP地址及網卡資訊
[[email protected] /]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:21:70:5c:a5:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.17.131/24 brd 192.168.17.255 scope global enp3s0
valid_lft forever preferred_lft forever
inet6 fe80::221:70ff:fe5c:a56f/64 scope link
valid_lft forever preferred_lft forever

# 查看網關

[[email protected] /]# ip route show
default via 192.168.17.254 dev enp3s0 proto static metric 100
192.168.17.0/24 dev enp3s0 proto kernel scope link src 192.168.17.131 metric 100

從這裡我們可以得到如下資訊:

裝置名稱: enp3s0

IP地址:192.168.17.131

網關地址:192.168.17.254

 

2. 下載 CentOS 的 bootstrap 檔案

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

 

3. 添加grub啟動條目

查看/boot/grub2/grub.cfg,找到如下代碼部分:

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‘ {        load_video        set gfxpayload=keep        insmod gzio        insmod part_msdos        insmod xfs        set root=‘hd0,msdos1‘        if [ x$feature_platform_search_hint = xy ]; then          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        else          search --no-floppy --fs-uuid --set=root 3ee40dd3-d836-4aa5-b145-9fbc2541b151        fi    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 LANG=en_US.UTF-8        initrd16 /initramfs-3.10.0-327.22.2.el7.x86_64.img}

然後把這一段拷貝到/etc/grub.d/40_custom中做如下修改:

#!/bin/shexec 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 ‘NetInstall‘ {        load_video        set gfxpayload=keep        insmod gzio        insmod part_msdos        insmod xfs        set root=‘hd0,msdos1‘        if [ x$feature_platform_search_hint = xy ]; then          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        else          search --no-floppy --fs-uuid --set=root 3ee40dd3-d836-4aa5-b145-9fbc2541b151        fi    linux16 /vmlinuz-7 inst.vnc inst.vncpassword=12345678 inst.headless ip=192.168.17.131::192.168.17.254:255.255.255.0::enp3s0:none nameserver=114.114.114.114 inst.repo=http://mirror.centos.org/centos/7/os/x86_64/ inst.lang=en_US inst.keymap=us    initrd16 /initrd-7.img}

此處解釋一下格式:

inst.vnc #啟用vnc

inst.vncpassword=12345678 # vnc 登陸密碼(至少是8個及其以上的字元)

inst.headless

ip=192.168.17.131::192.168.17.254:255.255.255.0::enp3s0:none

# ip=ip::網關:子網路遮罩::裝置名稱:none

nameserver=114.114.114.114 # DNS地址

inst.repo=http://mirror.centos.org/centos/7/os/x86_64/

# yum源地址

inst.lang=en_US

# 預設語言

inst.keymap=us

# 鍵盤模式

 

# 配置/etc/default/grub

開啟 /etc/default/grub

修改 GRUB_DEFAULT=0 為 GRUB_DEFAULT=saved

 

# 再檢查一次,所有配置

 

4. 重建配置,使配置生效

# 重建grub配置

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

# 列出所有啟動條目

awk -F\‘ ‘$1=="menuentry " {print $2}‘ /etc/grub2.cfg

# 下一次啟動使用NetInstall,僅使用一次

grub2-reboot NetInstall

# 重啟系統

reboot

 

5. 使用VNC安裝CentOS系統 

其他資料都提到等待一分鐘左右,個人實驗等待了約10分鐘,這主要取決於網速。

下載 tightVNC (http://www.tightvnc.com/download.php)

密碼就是上面設定的 12345678

 

成功進入CentOS的安裝介面

 

注意:這裡使用的是外部的yum源,很多情況下網路是封閉的,那麼就必須搭建一台內網的yum原始伺服器,具體可以參考

http://www.cnblogs.com/gleaners/p/5735472.html

 

參考:

http://www.danpros.com/2016/02/how-to-install-centos-7-remotely-using-vnc 

 

使用VNC遠程安裝CentOS 7作業系統

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.