VM網路安裝CentOS linux!



贊助商連結


bluse
2009-01-07, 10:57 PM
請問有沒有大大試過用下載網路安裝ISO檔掛載於VM,光碟開機指定FTP或NFS安裝CentOS linux,當要設定IP相關設定時,要怎麼知道VM bridge後所得到的IP位址?:eye:

贊助商連結


oldtu
2009-01-08, 06:26 AM
可以先選擇DHCP安裝
安裝好後再使用ifconfig看取得的IP就OK囉

bx2aa
2009-01-08, 11:36 PM
NFS Server:
cat /etc/exports
/mnt/cdrom *(ro,sync)

ls /mnt/cdrom
CentOS-5.2-DVD.iso

ifconfig 查這台 NFS Server 的 IP

service nfs restart

NFS Client:
http://www.pczone.com.tw/attachment.php?attachmentid=17041&stc=1&d=1231428547
附件為 CentOS-5.2 的 網路安裝用 NFS

bx2aa
2009-01-10, 08:40 PM
既然有 Linux Serve 連 CentOS-5.2-i386-netinstall.iso 光碟也省了.
用 PXE
設定 DHCPD 和 TFTP
/etc/dhcpd.conf
ddns-update-style none;
ignore client-updates;
allow booting;
allow bootp;
class "pxeclients"{
match if substring(option vendor-class-identifier,0,9) = "PXEClient";
filename "pxelinux.0";
next-server 192.168.0.146;
}
subnet 192.168.0.0 netmask 255.255.255.0 {
option routers 192.168.0.252;
option subnet-mask 255.255.255.0;
option nis-domain "amateur.radio";
option domain-name "amateur.radio";
option domain-name-servers 139.175.55.244;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.0.100 192.168.0.110;
default-lease-time 21600;
max-lease-time 43200;
}

TFTP 不動設定
chkconfig tftp on
service xinetd restart
service dhcpd restart
請自行確認 dhcpd 與 tftp 正常運作
ps aux | grep dhcpd
netstat -a | grep :tftp
若都有開還是連不上把 iptables 關掉好了
service iptables stop


將檔案複製過去 先把 CentOS-5.2-i386-netinstall.iso mount 到 /mnt
mount /dev/hdc /mnt

cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
cp /mnt/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
cp /mnt/images/pxeboot/initrd.img /tftpboot/

然後就可以到另一台開機用網卡安裝.
http://www.pczone.com.tw/attachment.php?attachmentid=17059&stc=1&d=1231591981

bx2aa
2009-01-11, 03:27 PM
#3 和 #4 算是網路安裝的本金.
PXE 安裝 Windows XP Prosession SP3 算是利息.
現在就賺點利息.

先抓一下 syslinux
http://www.kernel.org/pub/linux/utils/boot/syslinux/
我使用 http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.72.tar.bz2

cd /tftpboot
wget http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.72.tar.bz2
tar -jxvf syslinux-3.72.tar.bz2
cd syslinux-3.72.tar.bz2
cp core/pxelinux.0 ../
cp com32/menu/menu.c32 ../
cp memdisk/memdisk ../

在 /tftpboot/pxelinux.cfg/ 建立一個針對特定網段的開機設定檔
vi /tftpboot/pxelinux.cfg/C0A800
DEFAULT menu.c32
PROMPT 0
ALLOWOPTIONS 0
TIMEOUT 50
MENU TITLE PXELinux Menu
LABEL winxp
MENU LABEL winxp
kernel winxp.0

為 tftp 設定一個 rules 把所有檔案名稱轉為小寫
vi /tftpboot/rules
ri ^[a-z]: # Remove "drive letters"
rg \\ / # Convert backslashes to slashes
rg \# @ # Convert hash marks to @ signs
rg /../ /..no../ # Convert /../ to /..no../
rg A a
rg B b
rg C c
rg D d
rg E e
rg F f
rg G g
rg H h
rg I i
rg J j
rg K k
rg L l
rg M m
rg N n
rg O o
rg P p
rg Q q
rg R r
rg S s
rg T t
rg U u
rg V v
rg W w
rg X x
rg Y y
rg Z z
r ^/(.*) \1

修改 tftp 設定
vi /etc/xinetd.d/tftp
修改其中的
server_args = -v -m /tftpboot/rules -s /tftpboot

安裝 SAMBA
我把 RHEL 5 的 CD2 光碟 mount 到 /mnt
先umount /dev/hdc
mount /dev/hdc /mnt
其他版本請自行找一下我的是在 /mnt/Server 裏
rpm -ivh /mnt/Server/samba-3.0.23c-2.i386.rpm

設定 SAMBA
vi /etc/samba/smb.conf
至少把
interface = 192.168.0.146/24 <------ 改成自己相應的
host allow = 127.0 192.168.0. <------ 改成自己相應的

最尾端增加
[reminst]
path = /tftpboot
browsable = true
read only = no
writable = yes
guest ok = yes

存檔 離開
service smb restart <------ 把 Samba 開起來
service xinetd restart <------ 重開 tftpd

安裝 cabextract
http://www.cabextract.org.uk/
http://www.cabextract.org.uk/cabextract-1.2-1.i386.rpm

cd /tmp
wget http://www.cabextract.org.uk/cabextract-1.2-1.i386.rpm
rpm -ivh cabextract-1.2-1.i386.rpm

cd /tftpboot
mkdir winxp
chmod 777 winxp

用其他 WinXP 複製檔案順便測試一下 SAMBA
把 Windows XP 的光碟檔案透過 SAMBA 複製到 RemoteInstall 目錄 [reminst]
到其他電腦把 Windows XP 光碟裡的 i386 整個目錄複製進去
\\192.168.0.146\reminst\winxp

接著處理一下幾個改大小寫的檔名
cd /tftpboot/winxp
cabextract i386/STARTROM.N1_
sed -i -e 's/NTLDR/XPLDR/g' startrom.n12 <------ 注意要用 zh_US.UTF-8 不然停著不動
(我就是用 zh_TW.BIG5 等到不耐煩 <Ctrl>+C 終止掉的) LANG=zh_US.UTF-8 (ps:記得用完改回原來的)
sed -i -e 's/ntldr/xpldr/g' startrom.n12
mv startrom.n12 ../winxp.0
cabextract i386/SETUPLDR.EX_
sed -i -e 's/winnt\.sif/winxp\.sif/g' setupldr.exe
sed -i -e 's/ntdetect\.com/ntdetect\.wxp/g' setupldr.exe
mv setupldr.exe ../xpldr
cp i386/NTDETECT.COM ../ntdetect.wxp

將所有 i386 目錄裏的檔名改為小寫
find ./ -depth | perl -ne 'chomp;m</[^/]*$>;$d=$`;$_=$f=$&;''s/([\x80-\xFF].)|(\w)/$1\l$2/g;system "/bin/mv",$d.$f,$d.$_ if $f ne $_'

新增 winxp.sif
vi /tftpboot/winxp.sif
[data]
floppyless = "1"
msdosinitiated = "1"
OriSrc = "\\192.168.0.146\reminst\winxp\i386" ;視情況自行修改
OriTyp = "4"
LocalSourceOnCD = 1
DisableAdminAccountOnDomainJoin = 1

[SetupData]
OsLoadOptions = "/fastdetect"
SetupSourceDevice = "\Device\LanmanRedirector\192.168.0.146\reminst\winxp" ;視情況自行修改

[UserData]
ComputerName = *


如果要省麻煩就直接把 driver.cab 解開
cd /tftpboot/winxp/i386
cabextract driver.cab <------ 上面改檔名沒錯的話, 現在檔名都是小寫

下載 ris-linux-0.4.tar.gz
http://oss.netfarm.it/guides/ris-linux-0.4.tar.gz
cd /tftpboot
wget http://oss.netfarm.it/guides/ris-linux-0.4.tar.gz <------ 或是用 SAMBA 把檔案複製進 \\192.168.0.146\reminst
tar -zxvf ris-linux-0.4.tar.gz
cd ris-linux-0.4
./binlsrv.py <------ 然後到其他台開始用網路安裝 Windows XP 之後就會出現驅動程式的資訊(ps:在安裝 Windows XP 前要開啟)
[root@localhost ris-linux-0.4]# binlsrv.py
Succesfully loaded 12 devices
Binlserver started... pid 2809
Recv BINL NCQ len = 48
NCQ Driver request
[R] Mac address 00:0c:29:df:b8:69
[R] Vid: 0x1022
[R] Pid: 0x2000
[R] rev_u1 = 0x2
[R] rev_u2 = 0x0
[R] rev_u3 = 0x0
[R] rev = 0x10
[R] rev2 = 0x88
[R] subsys = 0x20001022
[R] Source path: \\192.168.0.146\reminst\winxp
Checking PCI\VEN_1022&DEV_2000&SUBSYS_20001022
Checking PCI\VEN_1022&DEV_2000
Found PCI\VEN_1022&DEV_2000 in netamd2.inf
[S] Packet len = 0xc5 (197)
[S] Result code: 0x0
[S] type: 0x2
[S] base offset = 0x24 (36)
[S] drv_off = 0x50 (80)
[S] srv_off: 0x6a (106) -> 98 from start
[S] plen: 0x57 (87)
[S] p_off: 0x76 (118) -> 110 from start
[S] hid: PCI\VEN_1022&DEV_2000 - Len 0x15 (21)
[S] drv: pcntpci5.sys - Len 0xc (12)
[S] srv: PCnet - Len 0x5 (5)
[S] Description (REG_EXPAND_SZ [2]) = AMD PCNET Family PCI Ethernet Adapter
[S] Characteristics (REG_SZ [1]) = 132
[S] BusType (REG_SZ [1]) = 5
[S] Total Params: 3



http://www.pczone.com.tw/attachment.php?attachmentid=17063&stc=1&d=1231657632

bx2aa
2009-01-12, 02:15 PM
繼續

狀況1:
電腦 沒光碟機,網卡沒有 boot rom,有 Floppy
http://rom-o-matic.net/gpxe/gpxe-0.9.6/contrib/rom-o-matic/build.php?version=0.9.6&F=&arch=i386&nic=e1000%3Ae1000-0x100f+--+%5B8086%2C100f%5D&ofmt=Floppy+bootable+ROM+Image+%28.dsk%29&A=Configure
做一張符合自己網卡的開機磁片 dsk (我用 440 的 e1000 選 e1000-0x100f )
然後開機過程如附件 PXE-Floppy_Join_to_AVI.7z

狀況2:
電腦 有光碟機 ,網卡沒有 boot rom,沒有 Floppy
http://rom-o-matic.net/gpxe/gpxe-0.9.6/contrib/rom-o-matic/build.php?version=0.9.6&F=&arch=i386&nic=e1000%3Ae1000-0x100f+--+%5B8086%2C100f%5D&ofmt=Floppy+bootable+ROM+Image+%28.dsk%29&A=Configure
做一張符合自己網卡的開機光碟 iso (我用 440 的 e1000 選 e1000-0x100f )
然後開機過程如附件 PXE-CDROM_Join_to_AVI.7z

狀況 3 和 4 請自行測試

Server 上出現的訊息
[root@localhost ris-linux-0.4]# ./binlsrv.py
Succesfully loaded 254 devices
Binlserver started... pid 3594
Recv BINL NCQ len = 48
NCQ Driver request
[R] Mac address 00:0c:29:df:b8:69
[R] Vid: 0x8086
[R] Pid: 0x100f
[R] rev_u1 = 0x2
[R] rev_u2 = 0x0
[R] rev_u3 = 0x0
[R] rev = 0x0
[R] rev2 = 0x88
[R] subsys = 0xffffffff
[R] Source path: \\192.168.0.146\reminst\winxp
Checking PCI\VEN_8086&DEV_100F&SUBSYS_FFFFFFFF
Checking PCI\VEN_8086&DEV_100F
Found PCI\VEN_8086&DEV_100F in e1000325.inf
[S] Packet len = 0xc7 (199)
[S] Result code: 0x0
[S] type: 0x2
[S] base offset = 0x24 (36)
[S] drv_off = 0x50 (80)
[S] srv_off: 0x6a (106) -> 98 from start
[S] plen: 0x59 (89)
[S] p_off: 0x76 (118) -> 110 from start
[S] hid: PCI\VEN_8086&DEV_100F - Len 0x15 (21)
[S] drv: e1000325.sys - Len 0xc (12)
[S] srv: E1000 - Len 0x5 (5)
[S] Description (REG_EXPAND_SZ [2]) = Intel(R) PRO/1000 MT Network Connection
[S] Characteristics (REG_SZ [1]) = 132
[S] BusType (REG_SZ [1]) = 5
[S] Total Params: 3

bx2aa
2009-01-13, 01:38 AM
補幾句話:
當把驅動程式丟進去 i386 後 記得善用
find ./ -depth | perl -ne 'chomp;m</[^/]*$>;$d=$`;$_=$f=$&;''s/([\x80-\xFF].)|(\w)/$1\l$2/g;system "/bin/mv",$d.$f,$d.$_ if $f ne $_'

有問題先
cd /tftpboot/winxp
find ./ -depth | perl -ne 'chomp;m</[^/]*$>;$d=$`;$_=$f=$&;''s/([\x80-\xFF].)|(\w)/$1\l$2/g;system "/bin/mv",$d.$f,$d.$_ if $f ne $_'

然後再試一次
cd /tftpboot/ris-linux-0.4
./infparser.py ../winxp/i386
./binlsrv.py

bluse
2009-01-13, 08:15 PM
辛苦了大大,寫的樂樂等阿:confused: ,我只是想將ftp指向義守大學的ftp,但是安裝失敗了(有檔案掛了!),後來指向元智大學的ftp可以安裝,但是要將VM裡的硬碟設IDE,裝到某個步驟又停住了,所以研究中:(

bx2aa
2009-01-13, 10:25 PM
辛苦了大大,寫的樂樂等阿:confused: ,我只是想將ftp指向義守大學的ftp,但是安裝失敗了(有檔案掛了!),後來指向元智大學的ftp可以安裝,但是要將VM裡的硬碟設IDE,裝到某個步驟又停住了,所以研究中:(
OK FTP
vsftpd:
vi /etc/vsftpd/vsftpd.conf
去掉以下兩行的 #
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list

echo "vsftpd: 192.168.0.0/255.255.255.0" >> /etc/hosts.allow

useradd bx2aa -d /tftpboot
passwd bx2aa
123456
123456

mount /dev/hdc /tftpboot/i386
service vsftpd restart


Client:
boot: linux method=ftp://bx2aa:[email protected]/i386 ip=dhcp noipv6

也可以用 anonymous
umount /dev/hdc
mount /dev/hdc /var/ftp/pub
service vsftpd restart

Client:
boot: linux method=ftp://192.168.0.146/pub username=anonymous [email protected] ip=dhcp noipv6