差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
osprovision:kickstart:ubuntu:networkproblem:basic [2016/10/06 22:16]
tony
osprovision:kickstart:ubuntu:networkproblem:basic [2023/06/25 09:48] (目前版本)
行 1: 行 1:
 {{tag>​Ubuntu kickstart Os_Provision}} {{tag>​Ubuntu kickstart Os_Provision}}
-====== Ubuntu-server Network Setting Of The Automated Installation ​(Working..) ​======+====== Ubuntu-server Network Setting Of The Automated Installation ======
 ===== Basic Process ===== ===== Basic Process =====
 +在RHEL/​CentOS、VMWare ESXI與SLES的自動安裝系統流程中,都有pre與post階段。Ubuntu的kickstart檔案,也提供了pre與post區塊;但Ubuntu與其它distribution最大差異在於:​ pre階段並沒載入網卡驅動。它的流程像這樣:​
 +  - Run pre script。
 +  - Detect HW。
 +  - Install OS。
 +  - Run post script。
 +在Detect HW階段,會去偵測並設定網卡。
 +===== Multiple NICs Warning =====
 +當你有兩張以上網卡且都可以連線的時候,安裝就會停住,並要求你選一張:​(圖片來自於[[http://​askubuntu.com/​questions/​617558/​preseed-doesnt-automatically-select-network-interface-on-ubuntu-14-04-automate|link]])\\
 +{{:​osprovision:​kickstart:​ubuntu:​networkproblem:​ubuntu_config_network.png?​600|}}\\
 +原先我是在preseed檔案中宣告了:​
 +<code bash>
 +d-i netcfg/​choose_interface select auto
 +</​code>​
 +但它卻很惱殘的選第一張且無法連線的網卡。後來爬文發現這是一個bug,所以改在isolinux.cfg或grub.cfg中串入以下參數:​
 +<code bash>
 +netcfg/​choose_interface=auto
 +</​code>​
 +以isolinux.cfg為例:​
 +<code bash>
 +append file=/​cdrom/​example.seed ​ initrd=/​install/​initrd.gz ks=cdrom:/​ks.cfg netcfg/​choose_interface=auto
 +</​code>​
 +如此就會自動挑一張可以用的或者是你在kickstart檔案中所宣告的device名稱。
 +===== Config Multiple NICs =====
 +在RHEL/​CentOS中,面對多張需要被設定的網卡,你可以在kickstart檔案中,透過多個network指令與--device參數去完成設定。而在Ubuntu上,即使你設定了多個network指令,也只有最後一個會生效。這意味著以下的內容只有em2會在第二階段被設定:​
 +<code bash>
 +network --bootproto=dhcp --device=em1
 +network --bootproto=dhcp --device=em2
 +</​code>​
 +這個問題我目前的解決方式是在%post的區塊去設定網卡。我提供設定dhcp的方式給大家參考:​
 +<code bash>
 +%post --interpreter=/​bin/​bash ​
 +FILE_NET_CONFIG=/​etc/​network/​interfaces
  
-===== Multiple NICs ===== +network_devices=($(ls -I lo /​sys/​class/​net)) 
 +for device in ${network_devices[@]};​ 
 +do 
 + check_config=`cat $FILE_NET_CONFIG | grep $device` 
 + if [ ! "​$check_config"​ ]; then 
 + echo auto $device >> $FILE_NET_CONFIG 
 + echo iface $device inet dhcp >> $FILE_NET_CONFIG 
 +  
 + dhclient -r $device 
 + dhclient $device 
 +  
 + ifconfig $device down 
 +  
 + status="​up";​ 
 + until [ -z "​$status"​ ] 
 + do 
 + status=$(ifconfig |grep -e '​^$device ') 
 + sleep 1 
 + done 
 +  
 + ifconfig $device up 
 + fi 
 +done 
 +</​code>​ 
 +設定static ip的方式等到我有做再分享。 
 +===== Reference ​===== 
 +  * [[http://​askubuntu.com/​questions/​617558/​preseed-doesnt-automatically-select-network-interface-on-ubuntu-14-04-automate|automatically select network interface problem]]
  
 +====== ​ ======
 +----
 +\\
 +~~DISQUS~~