2017年8月2日 星期三

PXE 結合 Kickstart 一鍵安裝CentOS

繼之前的PXE服務後(choons-world.blogspot.tw/2017/07/pxeos.html),這次結合CentOS Kickstart安裝Centos
讓使用者一健安裝好自定義的os

# 首先, 先建立一個ks檔案
vim /install/kickstart/firstKickStart.ks
====
#version=DEVEL
# System authorization information 使用加密協定sha512
auth --enableshadow --passalgo=sha512
# Use network installation
url --url="http://10.0.2.254/centos7"
# Use graphical install 用文字模式安裝
text
# Run the Setup Agent on first boot
firstboot --disable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8

# Network information(hard pc:--device=eno1)
network  --bootproto=dhcp --device=enp0s3 --ipv6=auto --activate
network  --hostname=localhost.localdomain

# Root password(--plaintext abc1234) plaintext是明碼 iscrryted是sha512加密後的字串
rootpw --iscrypted $6$3cHk0s2ZwYgs5$B66RHGSUflDgFF1
# SELinux configuration
selinux --permissive
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Taipei --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# bootloader --append="rhgb quiet crashkernel=auto" --location=mbr
autopart --type=lvm

# Partition clearing information
clearpart --none --initlabel

# # Clear the Master Boot Record
# zerombr
# # Partition clearing information
# clearpart --all --initlabel --drives=sda
# # Disk partitioning information
# part /boot --asprimary --fstype="xfs" --size=5000
# part swap --asprimary --fstype="swap" --size=16384
# part / --asprimary --fstype="xfs" --grow


%packages
@^minimal
@core
chrony
kexec-tools

%end


######in packages #######
# @base
# @development
# @java-platform

%post
# add user and add to sudo list
# useradd -m -G wheel -s /bin/bash choon
# echo 'choon:choon123' | chpasswd
# mkdir /home/hadoop/.ssh/
# wget -q http://10.0.2.254/tftproot/ks/id_rsa.pub -O /home/choon/.ssh/authorized_keys
# wget -q http://10.0.2.254/tftproot/ks/id_rsa.pub -O /home/choon/.ssh/id_rsa.pub
# wget -q http:///10.0.2.254/tftproot/ks/id_rsa -O /home/choon/.ssh/id_rsa
# chmod 600 /home/choon/.ssh/id_rsa
# chown -R choon.choon /home/choon/.ssh/


# import GPG key for ssh
# mkdir /root/.ssh/
# wget -q http://10.0.2.254/tftproot/ks/id_rsa.pub -O /root/.ssh/authorized_keys
# wget -q http://10.0.2.254/tftproot/ks/id_rsa.pub -O /root/.ssh/id_rsa.pub
# wget -q http://10.0.2.254/tftproot/ks/id_rsa -O /root/.ssh/id_rsa
# chmod 600 /root/.ssh/id_rsa
######in packages #######


%addon com_redhat_kdump --enable --reserve-mb='auto'

%end

%anaconda
# 限制密碼
pwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --notempty
pwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --notempty
%end
========

vim /etc/httpd/conf.d/pxeboot.conf
=====加在後面=====
Alias /ks /install/kickstart

<Directory /install/kickstart>
        Options Indexes FollowSymLinks
        Require all granted
        Allow from 127.0.0.1 10.0.2.0/24 
</Directory>
=================

systemctl restart httpd

vim /install/tftpboot/pxelinux.cfg/default
====加在後面====
LABEL kickstart1
  MENU LABEL Boot from PXE Server for AUTO Install CentOS 7
  kernel ./kernel/centos7/images/pxeboot/vmlinuz
  append initrd=./kernel/centos7/images/pxeboot/initrd.img  ks=http://10.0.2.254/ks/firstKickStart.ks 
===============

ref:
http://linux.vbird.org/linux_enterprise/0120installation.php#pxe_installation

沒有留言:

張貼留言

Centos GUI Webserver 設定

新灌的一台Centos7可以做以下的設定 語系設定: - sudo localectl set-locale LC_CTYPE=zh_TW.UTF-8 修改ssh port - http://linux.vbird.org/linux_server/0310telne...