镜像完成后可用于PXE环境或U盘randisk等
安装系统
考虑到实际应用中Ramdisk需要保持小而精,故在安装系统时选择最小化安装,然后再安装所需要的包。
安装必要软体
tool | 描述 |
---|---|
vim | |
ifconfig | net-tools |
lspci | pciutils |
numactl | |
nfs | |
tmux | |
ftp | |
bc | |
smartctl | smartmontools |
mailx | |
mktemp | |
mcelog | |
ipmi | ipmitool和OpenIPMI |
编译环境 | gcc make kernel-headers gcc-c kernel-devel |
dos2unix | |
ethtool | |
lsusb | usbutils |
zlib | |
zip | |
unzip | |
killall | psmisc |
sg3_utils | |
numactl | |
locate | mlocate |
rngd.service | rng-tools |
strace | strace |
expect | expect和tcl |
openssh | |
openssh-server | |
nvme | |
mcelog | |
smartd | |
issdcm |
一些OS设置
代码语言:javascript复制systemctl set-default multi-user.target
timedatectl set-timezone Asia/Shanghai #Modify TIME zone
systemctl disable firewalld
systemctl disable NetworkManager
sed -i "/^SELINUX=/cSELINUX=disabled" /etc/selinux/config #disable SELINUX
setenforce 0 #shutdown SELINUX
sed -i "s/^ExecStart=-/sbin/agetty --noclear %I $TERM/& --autologin root/g" /usr/lib/systemd/system/getty@.service #root autologin
sed -i "s/^ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM/& --autologin root/g" /usr/lib/systemd/system/serial-getty@.service #root Serial autologin
sed -i "/^#UseDNS/cUseDNS no" /etc/ssh/sshd_config #SSH setting
sed -i "/^#IgnoreUserKnownHosts no/cIgnoreUserKnownHosts yes" /etc/ssh/sshd_config #SSH setting
sed -i "/StrictHostKeyChecking/cStrictHostKeyChecking no" /etc/ssh/ssh_config #SSH client setting
echo -e "set -g mode-keys vinset -g prefix C-anunbind C-bnbind C-a send-prefix" > /root/.tmux.conf #tmux setting
打包系统
代码语言:javascript复制[root@localhost ~]# cat make_img.sh
#!/bin/bash
###############################################
# Filename : make_img.sh
# Author : PedroQin
# Date : 2020-01-17 15:54:12
# Description :
# Version : 1.0.0
###############################################
target_folder="/temp/create_os"
os_folder="$target_folder/os"
# show message in green
function green_message()
{
tput bold
echo -ne "