使用kickstart脚本安装CentOS7

一直使用PXE来安装Linux系统是系统集成中最基础的工作,同时也是最容易被忽略的,平时一旦系统安装好之后,很少再管这部分。

关于PXE的集成工具,现在已经很多了,如cobbler。

但为了减少在这方面投入的时间,我们依然采用DHCP+TFTP+HTTP的方式来安装Linux系统。

PXE服务器是基于ubuntu12.04-server-amd64配置的,CentOS系统使用kickstart脚本安装。

关于CentOS的kickstart脚本,可以通过kickstart图形界面直接配置生成。

安装kickstart脚本配置软件包:

yum install -y system-config-kickstart


此处贴出CentOS7的kickstart安装配置脚本:

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Reboot after installation
reboot
# Root password
rootpw --iscrypted $1$KEKVRRLj$GbaEa4dC8CirdAbuDvq9e1
user --name="user" --password="password"
# System timezone
timezone Asia/Chongqing
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# Use network installation
url --url="http://172.16.112.133/CentOS7.0"
# System language
lang en_US
# Firewall configuration
firewall --disabled
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
firstboot --enable
ignoredisk --only-use=sda
# SELinux configuration
selinux --disabled
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr

#autopart --type=lvm
# Partition clearing information
clearpart --all --initlabel --drives=sda

#Allow partition the system as needed
%include /tmp/partition.ks

%pre
#!/bin/sh
act_mem=`cat /proc/meminfo | grep MemTotal | awk '{printf("%d",$2/1024)}'`
echo "" > /tmp/partition.ks
echo "clearpart --all --initlabel" >> /tmp/partition.ks
echo "part /boot --fstype=ext4 --asprimary --size=20000" >> /tmp/partition.ks
echo "part swap --fstype=swap --size=${act_mem}" >> /tmp/partition.ks

## / partition use the dev directly
#echo "part / --fstype=ext4 --grow --size=1" >> /tmp/partition.ks

## / partition use the lvm
echo "part pv.100 --size=1  --grow" >> /tmp/partition.ks
echo "volgroup myvg pv.100" >>/tmp/partition.ks
echo "logvol / --fstype="ext4" --name=lv_root --vgname=myvg --size=1 --grow" >>/tmp/partition.ks
%end

%packages
@base
@core
@desktop-debugging
@dial-up
@directory-client
@fonts
@gnome-apps
@gnome-desktop
@guest-agents
@guest-desktop-agents
@input-methods
@internet-browser
@java-platform
@multimedia
@network-file-system-client
@print-client
@remote-desktop-clients
@x11


######## graphic admin tools #############
@graphical-admin-tools
policycoreutils-gui
setroubleshoot
system-config-kickstart
wireshark-gnome


############ virtualization tools ########
@virtualization-client
@virtualization-platform
@virtualization-tools
fence-virtd-libvirt
fence-virtd-multicast
fence-virtd-serial
libguestfs-java
libguestfs-tools
libvirt-cim
libvirt-java
libvirt-snmp
perl-Sys-Virt
qemu-kvm-tools

%end

%post
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
mkdir /root/test
touch /root/test/testfile
echo "testfile in the root path" > /root/test/testfile%end


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值