269 lines
6.1 KiB
Markdown
269 lines
6.1 KiB
Markdown
# 树莓派部署 kickstart 服务器
|
|
|
|
[TOC]
|
|
|
|
|
|
|
|
## dhcp
|
|
|
|
```bash
|
|
sudo apt install isc-dhcp-server
|
|
|
|
cat > /etc/dhcp/dhcpd.conf <<EOF
|
|
ddns-update-style interim;
|
|
allow booting;
|
|
allow bootp;
|
|
ignore client-updates;
|
|
set vendorclass = option vendor-class-identifier;
|
|
option pxe-system-type code 93 = unsigned integer 16;
|
|
subnet 192.168.10.0 netmask 255.255.255.0 {
|
|
#option routers 192.168.10.1;
|
|
option domain-name-servers 223.5.5.5;
|
|
option subnet-mask 255.255.255.0;
|
|
range dynamic-bootp 192.168.10.100 192.168.10.254;
|
|
filename "/pxelinux.0";
|
|
default-lease-time 21600;
|
|
max-lease-time 43200;
|
|
next-server 192.168.10.50;
|
|
class "pxeclients" {
|
|
match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
|
|
if option pxe-system-type = 00:02 {
|
|
filename "ia64/elilo.efi";
|
|
} else if option pxe-system-type = 00:06 {
|
|
filename "grub/grub-x86.efi";
|
|
} else if option pxe-system-type = 00:07 {
|
|
filename "grub/grub-x86_64.efi";
|
|
} else if option pxe-system-type = 00:09 {
|
|
filename "grub/grub-x86_64.efi";
|
|
} else {
|
|
filename "pxelinux.0";
|
|
}
|
|
}
|
|
|
|
}
|
|
# group for Cobbler DHCP tag: default
|
|
group {
|
|
}
|
|
EOF
|
|
|
|
sudo /etc/init.d/isc-dhcp-server start
|
|
```
|
|
|
|
|
|
|
|
## tftp
|
|
|
|
```bash
|
|
sudo apt install xinetd tftpd tftp
|
|
sudo touch /etc/xinetd.d/tftp
|
|
|
|
cat > /etc/xinetd.d/tftp <<EOF
|
|
service tftp
|
|
{
|
|
disable = no
|
|
socket_type = dgram
|
|
protocol = udp
|
|
wait = yes
|
|
user = root
|
|
server = /usr/sbin/in.tftpd
|
|
server_args = -B 1380 -v -s /var/lib/tftpboot
|
|
per_source = 11
|
|
cps = 100 2
|
|
flags = IPv4
|
|
}
|
|
EOF
|
|
|
|
sudo mkdir /var/lib/tftpboot
|
|
# 授予所有读写权限
|
|
sudo chmod -R 777 /var/lib/tftpboot
|
|
sudo chown -R nobody /var/lib/tftpboot
|
|
sudo /etc/init.d/xinetd restart
|
|
```
|
|
|
|
|
|
|
|
## httpd
|
|
|
|
```bash
|
|
sudo apt install apache2
|
|
cd /var/www/html
|
|
rm index.html
|
|
sudo sed -i 's/\/var\/www\/html/\/var\/www/' /etc/apache2/sites-enabled/000-default.conf
|
|
sudo service apache2 restart
|
|
sudo chmod -R 777 /var/www
|
|
sudo mkdir /var/www/kickstart
|
|
sudo mkdir /var/www/images
|
|
sudo mkdir /var/www/images/centos7
|
|
sudo mkdir /var/www/repo
|
|
```
|
|
|
|
## 引导
|
|
|
|
```bash
|
|
|
|
wget http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/Packages/syslinux-4.05-15.el7.x86_64.rpm -O /tmp/syslinux.rpm
|
|
sudo apt install rpm2cpio
|
|
sudo rpm2cpio /tmp/syslinux.rpm | cpio -idmv
|
|
|
|
cp /tmp/usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
|
|
|
|
mkdir /var/lib/tftpboot/pxelinux.cfg
|
|
cat > /var/lib/tftpboot/pxelinux.cfg/default << EOF
|
|
DEFAULT menu
|
|
PROMPT 0
|
|
MENU TITLE PrideCloud
|
|
TIMEOUT 200
|
|
TOTALTIMEOUT 6000
|
|
ONTIMEOUT local
|
|
|
|
LABEL local
|
|
MENU LABEL (local)
|
|
MENU DEFAULT
|
|
LOCALBOOT -1
|
|
|
|
LABEL centos7-x86_64
|
|
kernel /images/centos7-x86_64/vmlinuz
|
|
MENU LABEL centos7-x86_64
|
|
append initrd=/images/centos7-x86_64/initrd.img ksdevice=bootif lang= kssendmac text ks=http://192.168.10.50/kickstart/centos7.ks
|
|
ipappend 2
|
|
|
|
MENU end
|
|
EOF
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 挂载镜像
|
|
|
|
```bash
|
|
sudo mount -t iso9660 -o loop,ro ~/CentOS-7-x86_64-Minimal-2003.iso /var/www/images/centos7
|
|
# 编辑kickstart 文件
|
|
sudo vim /var/www/kickstart/centos7.ks
|
|
```
|
|
|
|
```bash
|
|
# /var/www/kickstart/centos7.ks
|
|
# platform =x86, AMD64, or Intel EM64T
|
|
# os=centos7
|
|
# Install OS instead of upgrade
|
|
install
|
|
# Use text mode install
|
|
text
|
|
# System keyboard
|
|
keyboard us
|
|
# System language
|
|
lang en_US
|
|
# System timezone
|
|
timezone Asia/ShangHai
|
|
# System authorization information
|
|
auth --useshadow --enablemd5
|
|
rootpw --iscrypted $1$XiTkwMpL$Y9cGAcWZC2koVK68De7LZ.
|
|
# Firewall configuration
|
|
firewall --disabled
|
|
# SELinux configuration
|
|
selinux --disabled
|
|
|
|
|
|
# Use network installation
|
|
url --url=http://192.168.10.50/images/centos7
|
|
|
|
|
|
# Clear the Master Boot Record
|
|
zerombr
|
|
# System bootloader configuration
|
|
# bootloader --location=mbr
|
|
# interface can be named as eth*
|
|
bootloader --location=mbr --append="net.ifnames=0 biosdevname=0 rhgb quiet"
|
|
|
|
# Partition clearing information
|
|
clearpart --all --initlabel
|
|
# Allow anaconda to partition the system as needed
|
|
autopart
|
|
# or
|
|
# # create 1MB biosboot type partition, centos7 and centos8 .
|
|
# part biosboot --fstype=biosboot --size=1
|
|
# # Disk partitioning information
|
|
# part /boot --fstype=xfs --size=300
|
|
# part pv.122 --fstype="lvmpv" --grow
|
|
# volgroup VolGroup00 --pesize=16384 pv.122
|
|
# logvol / --fstype="xfs" --size=10000 --name=LogVol00 --vgname=VolGroup00
|
|
|
|
|
|
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
|
|
# repo --name=Centos7-Base --baseurl=http://192.168.10.50/repo/Centos7-Base
|
|
# repo --name=Centos7-Updates --baseurl=http://192.168.10.50/repo/Centos7-Updates
|
|
# repo --name=Centos7-extras --baseurl=http://192.168.10.50/repo/Centos7-extras
|
|
# repo --name=Centos7-Epel --baseurl=http://192.168.10.50/repo/Centos7-Epel
|
|
# repo --name=source-1 --baseurl=http://192.168.10.50/images/centos7
|
|
|
|
# add repo manually
|
|
# repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream
|
|
|
|
# Network information
|
|
network --bootproto=dhcp --device=eth0 --onboot=on
|
|
|
|
# Do not configure the X Window System
|
|
skipx
|
|
# Run the Setup Agent on first boot
|
|
firstboot --disable
|
|
# Reboot after installation
|
|
reboot
|
|
|
|
%pre
|
|
set -x -v
|
|
exec 1>/tmp/ks-pre.log 2>&1
|
|
|
|
# Once root's homedir is there, copy over the log.
|
|
while : ; do
|
|
sleep 10
|
|
if [ -d /mnt/sysimage/root ]; then
|
|
cp /tmp/ks-pre.log /mnt/sysimage/root/
|
|
logger "Copied %pre section log to system"
|
|
break
|
|
fi
|
|
done &
|
|
|
|
|
|
# Enable installation monitoring
|
|
|
|
%end
|
|
|
|
%packages
|
|
|
|
|
|
# if you need puppet to install pkgs, just uncomment it
|
|
#
|
|
|
|
@core
|
|
@base
|
|
tree
|
|
nmap
|
|
wget
|
|
telnet
|
|
zsh
|
|
docker
|
|
python-pip
|
|
|
|
%end
|
|
|
|
%post --nochroot
|
|
set -x -v
|
|
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1
|
|
%end
|
|
|
|
%post
|
|
set -x -v
|
|
exec 1>/root/ks-post.log 2>&1
|
|
|
|
|
|
wget http://192.168.10.50/pride/init.sh -O /tmp/init.sh
|
|
chmod u+x /tmp/init.sh
|
|
/tmp/init.sh
|
|
# wget http://192.168.10.60/cblr/pride/init.sh -O /tmp/init.sh && chmod u+x /tmp/init.sh && /tmp/init.sh
|
|
%end
|
|
```
|
|
|