centos7.2 搭建PXE+kickstart多版本系統安裝
阿新 • • 發佈:2018-06-04
PXE CentOs7.2 kickstart 多系統安裝 網上眾多文章,但是自己搭建起來卻很少又能用的。
總結下自己的
總結下自己的
原理+單系統的實驗
這裏說明下,最好使用kickstart工具來生成ks.cfg文件(網上參數實在太多,不同系統還要不同的參數)
實驗
系統:CentOS Linux release 7.2.1511 (Core) 內核:3.10.0-327.el7.x86_64 準備工作:關閉 防火墻 和 SELINUX IP:192.168.10.17 yum -y install dhcp cp -f /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf(根據自己dhcp的版本來,不一定是4.1版本的) vim /etc/xinetd.d/tftp disable=no#將yes修改no vi /etc/dhcp/dhcpd.conf subnet 192.168.10.0 netmask 255.255.255.0 { range 192.168.10.100 192.168.10.200; option domain-name-servers pxeserver; option domain-name "1.1.1.1"; option routers 192.168.10.1; option broadcast-address 192.168.10.255; next-server 192.168.10.17; filename "pxelinux.0"; default-lease-time 60000; max-lease-time 720000; } systemctl enable dhcpd systemctl start dhcpd yum -y install nfs* vim /etc/exports /rhel6 192.168.10.0/24(rw,sync) /rhel7 192.168.10.0/24(rw,sync) mkdir /rhel6 /rhel7 虛擬機添加一個光驅(一定點擊連接cd-rom設備目錄下應該有sr0和sr1兩個光驅文件,sr0連接6系統iso sr1連接7系統iso) [root@pxeserver ~]# df -h(這裏我先連接了,所以umount掉) Filesystem Size Used Avail Use% Mounted on /dev/sda3 18G 14G 4.5G 75% / devtmpfs 475M 0 475M 0% /dev tmpfs 489M 156K 489M 1% /dev/shm tmpfs 489M 14M 476M 3% /run tmpfs 489M 0 489M 0% /sys/fs/cgroup /dev/sda1 297M 145M 153M 49% /boot tmpfs 98M 0 98M 0% /run/user/0 /dev/sr1 4.1G 4.1G 0 100% /mnt tmpfs 98M 12K 98M 1% /run/user/1000 /dev/sr0 4.2G 4.2G 0 100% /run/media/ding/CentOS_6.5_Final [root@pxeserver ~]# umount /run/media/ding/CentOS_6.5_Final/ [root@pxeserver ~]# umount /mnt/ mount /dev/sr0 /mnt/6 mount /dev/sr1 /mnt/7 cp -a /mnt/6/* /rhel6 cp -a /mnt/7/* /rhel7 vim /etc/exports /dev/sr0 4.2G 4.2G 0 100% /rhel6 /dev/sr1 4.1G 4.1G 0 100% /rhel7 systemctl restart nfs-server.service systemctl enable nfs-server.service yum -y install tftp-server tftp xinetd systemctl restart xinetd.service systemctl restart tftp.service(7裏面是tftp) systemctl enable xinetd.service systemctl enable tftp.service yum -y install syslinux-tftpboot cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ cp /rhel6/isolinux/initrd.img /var/lib/tftpboot/Cent6/ cp /rhel6/isolinux/vmlinuz /var/lib/tftpboot/Cent6/ cp /rhel7/isolinux/initrd.img /var/lib/tftpboot/Cent7/ cp /rhel7/isolinux/vmlinuz /var/lib/tftpboot/Cent7/ mkdir /var/lin/tftpboot/pxelinux.cfg cp /rhel6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default cp /rhel6/isolinux/* /var/lib/tftpboot/ vim /var/lib/tftpboot/pxelinux.cfg/default default vesamenu.c32 #prompt 1 timeout 600 display boot.msg menu background splash.jpg menu title Welcome to CentOS ! (把6.5刪去) menu color border 0 #ffffffff #00000000 menu color sel 7 #ffffffff #ff000000 menu color title 0 #ffffffff #00000000 menu color tabmsg 0 #ffffffff #00000000 menu color unsel 0 #ffffffff #00000000 menu color hotsel 0 #ff000000 #ffffffff menu color hotkey 7 #ffffffff #ff000000 menu color scrollbar 0 #ffffffff #00000000 label linux menu label ^Install or upgrade an existing system menu default kernel vmlinuz append initrd=initrd.img label vesa menu label Install system with ^basic video driver kernel vmlinuz append initrd=initrd.img xdriver=vesa nomodeset label rescue menu label ^Rescue installed system kernel vmlinuz append initrd=initrd.img rescue label local menu label Boot from ^local drive localboot 0xffff label memtest86 menu label ^Memory test kernel memtest append - label 7 kernel Cent7/vmlinuz append initrd=Cent7/initrd.img inst.ks=nfs:192.168.10.17:/rhel7/ks.cfg label 6 kernel Cent6/vmlinuz append initrd=Cent6/initrd.img ks=nfs:192.168.10.17:/rhel6/ks.cfg vim /rhel6/ks.cfg #platform=x86, AMD64, 或 Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade 指明是安裝系統還是升級系統 install # Use network installation 使用網絡安裝系統,指明包安裝路徑 nfs --server=192.168.10.17 --dir=/rhel6 # Root password 設定root密碼 rootpw --iscrypted $1$YQ5HiIDI$A82NuasWauRzCl8GWkqn10(這個是加密後的散列值字符,這裏我是從/root/anaconda-ks.cfg提取出來用的,下面也會講下怎麽生成自己想要的密碼) # System authorization information 密鑰加密算法啟用shadow文件 auth --useshadow --passalgo=sha512 # Use text mode install 使用文本模式或者圖形模式安裝系統 text # System keyboard 鍵盤設定 keyboard us # System language 語言設定 lang en_US # SELinux configuration selinux是否關閉 selinux --disabled # Do not configure the X Window System 是否安裝圖形界面 skipx # Installation logging level 日誌級別 logging --level=info # Reboot after installation 聲明安裝完成後重啟系統 reboot # System timezone 設置時區(可以改成亞洲上海) timezone Africa/Abidjan # System bootloader configuration 設定BootLoader bootloader --location=mbr # Clear the Master Boot Record 清除mbr記錄 zerombr # Partition clearing information 清除全部分區 clearpart --all --initlabel # Disk partitioning information 分區設定 part /boot --fstype="ext4" --size=200 part / --fstype="ext4" --size=16000 part swap --fstype="swap" --grow --size=2048 %packages 安裝的包設定(這裏僅僅最小化安裝) @core vim /rhel7/ks.cfg #platform=x86, AMD64, or Intel EM64T #version=DEVEL # Firewall configuration firewall --disabled # Install OS instead of upgrade install # Use FTP installation media nfs --server=192.168.10.17 --dir=/rhel7 # Root password rootpw --iscrypted $1$YQ5HiIDI$A82NuasWauRzCl8GWkqn10 # System authorization information auth useshadow passalgo=sha512 # Use graphical install graphical firstboot disable # System keyboard keyboard us # System language lang en_US # SELinux configuration selinux disabled # Installation logging level logging level=info # System timezone timezone Europe/Amsterdam # System bootloader configuration # Reboot afer installing reboot ##一定要有此 選項否則操作系統安裝完後不會自動重啟。 ###### bootloader location=mbr clearpart --all --initlabel part swap --asprimary --fstype="swap" --size=1024 part /boot --fstype xfs --size=300 part pv.01 --size=1 --grow volgroup root_vg01 pv.01 logvol / --fstype xfs --name=lv_01 --vgname=root_vg01 --size=1 --grow %packages ###要安裝的包 @^minimal @core acpid iputils man net-tools ntp ntpdate parted vim-enhanced wget %end ###以%end結尾 #%addon com_redhat_kdump --disable --reserve-mb=‘auto‘ #%end %post #--nochroot --log=/mnt/sysimage/var/log/ks.post01.log mkdir /root/test %end *(7也是最小化安裝) *(修改rootpw的方法 [root@pxeserver rhel6]# perl -e ‘print crypt("1234abcdefg",q($1$password)),"\n"‘ $1$password$kMAjDeCG9NGsvGpYFaqE21 1234abcdefg就是密碼 ) yum -y install system-config-kickstgart system-config-kickstart #圖形化配置應答文件 也可以使用我下面生成的一鍵安裝應答文件,rhel7.0裏面沒有圖像化的安裝包選擇可以到/root/anaconda-ks.cfg裏面 進行拷貝安裝圖形化的命令到你自己手動創建的ks.cfg文件末行並保存,也可以直接編寫,這裏直接編寫。 將本機機器改成vmnet2,其他要通過17服務器安裝的機器也選擇vmnet2 第一次啟動選擇從網絡啟動 安裝完畢後選擇從硬盤啟動 有問題留言區,共同解決。。
centos7.2 搭建PXE+kickstart多版本系統安裝