File c6 minimal.ks

From Alteeve Wiki
Jump to navigation Jump to search

 AN!Wiki :: File c6 minimal.ks

This is a generic, minimal installer for CentOS 6. It can be easily modified to work with and RHEL6-based distribution.

Warning: This kickstart script will delete everything from the target machine!

This includes a small script to detect the hard drives in the system and create RAID arrays as needed. It support's;

  • HP's old c0d0 and c1d0 device names.
  • RAID level 1 for 2 old-stype /dev/hdX devices.
  • Single-disk install for 1 old-style /dev/hda devices.
  • RAID level 5 for 3 to 6 /dev/sdX devices
  • RAID level 1 for 2 /dev/sdX devices.
  • Single-disk install for 1 /dev/sda devices (modern RAID controller-built arrays or single drives).
  • Single-disk install for 1 Xen's /dev/xvda virtual disk.
  • Single-disk install for 1 KVM's /dev/vda virtual disk.

Please note that if you have multiple drives in your system and do not want a RAID array, you will need to edit this script or use another script entirely.

vim ~/c6_minimal.ks
# Kickstart file created by Digimer
# Email:     digimer@alteeve.com
# Updated:   Dec. 25, 2011
# Based on:  CentOS 6.2
# Note:      Minimal server install

### Setup values.
# Doing a full install.
install

# This is the web server with the installation image. For more information on
# setting up a PXE and web server, see: 
# - http://wiki.alteeve.com/index.php/Setting_Up_a_PXE_Server_in_Fedora
url --url=http://10.255.255.254/c6/x86_64/img/

# Set the language and keyboard to en_US, UTF-8. Adjust as needed.
lang en_US.UTF-8
keyboard us

# Set the timezone to Eastern Standard/Daylight Time. To get your preferred
# time zone, run 'tzselect'. When finished, looks for the line like:
# - Therefore TZ='America/Toronto' will be used.
# Take the value in "TZ='...'" and use it below.
timezone --utc America/Toronto

# This sets the (first) ethernet device. There is currently no way to map
# device names to physical interfaces. For this reason, I use DHCP for install
# and configure the network manually post-install.
network --device eth0 --bootproto dhcp --onboot yes --hostname minimal.alteeve.com

# This is the root user's password, which is "initial". To change this, set the
# password you want for a user on an existing system. Once set, look in
# '/etc/shadow' for the line starting with the user name whom you set the
# password for. Here is an example for the user 'digimer':
# digimer:$6$YEoLNxHI$cu/673fGD/BPqfJ1RCd0F6ZRqHhkfbI6HPdy1YuKBoxA6AW7eyyWC2NmkQ/czP1dzXfBn5uJbdn/HR84i.WhO1:14896:0:99999:7:::
# The part to copy below falls between the first and second ':' character.
authconfig --enableshadow --passalgo=sha512 --enablefingerprint
rootpw --iscrypted $6$0riSEDMyCvHPdhCv$lvuhEOqU2yo9szCJHtAsVUK3maHyWlpZmVi6PCRkrOfifL/38J7SaGUopehv/rzwQvhqxNla/jPvD10uwuPY4/

# In a production system, you will likely want to enable a firewall and
# SELinux. Given that this script is likely to be used while learning though,
# I turn them both off to reduce potential problems. Please be sure to build a
# firewall (Shorewall is good) and to re-enable SELinux as final steps before
# going into production. This way you will be able to focus on resolving issues
# specific to firewalling and SELinux without wondering if problems are caused
# by the general configuration.
#firewall --service=ssh
#selinux --enforcing
firewall --disabled
selinux --disabled

# Given how often I rebuild machines, I like to pre-define the initial user and
# thus skip 'firstboot' to save time.
firstboot --disable

# Setup the first user. Here we will use the safely generic 'admin', with the
# same "initial" password. Please see the 'rootpw' option above for information
# on changing this to the password you prefer.
user --name=admin --iscrypted --password=$6$RjVwtC1Mk14aGlxv$GDWnDl3RNYyJYXRaNO9A8g6XFcu.HfFFTnj5pVyUDi1/QBy7y/e/y97YkMY1n2Vn57S4vruWy5KLG4fKurqGs1

# Reboot after the install completes rather than waiting for the user to
# manually reboot.
reboot

# This runs a script (below) that generates the partitioning information
# depending on a rudamentary test for available storage devices.
%include /tmp/part-include

# These options allow me to disable and enable services. Given that we're
# building servers, I particularly like to replace 'NetworkManager' with the
# simpler, and more static, 'network' service. If you want to add additional
# services, seperate the service names with commans. (ie: foo,bar,baz).
services --disabled NetworkManager,iptables,iptables,ip6tables
services --enabled network

# This is a very, very minimal installation. It's suitable for testing install
# programs or for machines with the minimal attack surface area.
%packages
@core
@server-policy
rsync
openssh-clients
git
perl
screen
telnet
%end

### Script to setup partitions.
%pre --log=/tmp/ks-preinstall.log
 
#!/bin/sh

# Prepare the disks in the script below. It checks '/proc/partitions' to see
# what configuration to use.

### Some detection.
if grep -q "cciss/c0d0" /proc/partitions; then
	### No RAID is needed at the software level, it's managed by the controller.
cat >> /tmp/part-include <<END
zerombr
clearpart --linux --drives=cciss/c0d0
ignoredisk --only-use=cciss/c0d0
bootloader --location=mbr --driveorder=cciss/c0d0 --append="crashkernel=auto"

part     /boot --fstype ext3 --size=256   --asprimary
part     swap  --fstype swap --size=4096  --asprimary
part     /     --fstype ext3 --size=40960 --asprimary
END
elif grep -q "cciss/c1d0" /proc/partitions; then
	### No RAID is needed at the software level, it's managed by the controller.
cat >> /tmp/part-include <<END
zerombr
clearpart --linux --drives=cciss/c1d0
ignoredisk --only-use=cciss/c1d0
bootloader --location=mbr --driveorder=cciss/c1d0 --append="crashkernel=auto"

part     /boot --fstype ext3 --size=256   --asprimary
part     swap  --fstype swap --size=4096  --asprimary
part     /     --fstype ext3 --size=40960 --asprimary
END
elif grep -q hdb /proc/partitions; then
	### /dev/hdX RAID 1
cat >> /tmp/part-include <<END
zerombr
clearpart --all --initlabel --drives=hda,hdb
ignoredisk --only-use=hda,hdb
bootloader  --location=mbr --driveorder=hda,hdb --append="crashkernel=auto"

# /boot
part raid.01 --ondisk=sda --asprimary --size=256
part raid.02 --ondisk=sdb --asprimary --size=256
# /
part raid.11 --ondisk=sda --asprimary --size=40960
part raid.12 --ondisk=sdb --asprimary --size=40960
# <swap>
part raid.21 --ondisk=sda --asprimary --size=4096
part raid.22 --ondisk=sdb --asprimary --size=4096

# Format /boot and /.
raid /boot --fstype=ext3 --level=1 --device=md0 raid.01 raid.02
raid /     --fstype=ext3 --level=1 --device=md1 raid.11 raid.12
raid swap  --fstype=swap --level=1 --device=md2 raid.21 raid.22
END
elif grep -q hda /proc/partitions; then
	### /dev/hda single
cat >> /tmp/part-include <<END
zerombr
clearpart --linux --drives=hda
ignoredisk --only-use=hda
bootloader --location=mbr --driveorder=hda --append="crashkernel=auto"

part     /boot --fstype ext3 --size=256   --asprimary
part     swap  --fstype swap --size=4096  --asprimary
part     /     --fstype ext3 --size=40960 --asprimary
END
elif grep -q sdf /proc/partitions; then
	### /dev/sdX RAID - This should be the majority.
	# 6-Drive RAID 5 w/ 1 hot spare
cat >> /tmp/part-include <<END
zerombr
clearpart --all --initlabel --drives=sda,sdb,sdc,sdd,sde,sdf
ignoredisk --only-use=sda,sdb,sdc,sdd,sde,sdf
bootloader --location=mbr --driveorder=sda,sdb,sdc,sdd,sde,sdf --append="crashkernel=auto"

## This will create a 6-drive RAID 5 array.
# The '/boot' partition. A little nuts at 6x RAID 1 but meh, what else would I
# use the 256MB parts for?
part raid.01 --size=256 --ondisk=sda
part raid.02 --size=256 --ondisk=sdb
part raid.03 --size=256 --ondisk=sdc
part raid.04 --size=256 --ondisk=sdd
part raid.05 --size=256 --ondisk=sde
part raid.06 --size=256 --ondisk=sdf

# The swap partition. Set to RAID 5, so it's actually ~5GB. It's RAID'ed and
# not individual parts because a loss of swap can still brind down a system.
part raid.11 --size=1024 --ondisk=sda
part raid.12 --size=1024 --ondisk=sdb
part raid.13 --size=1024 --ondisk=sdc
part raid.14 --size=1024 --ondisk=sdd
part raid.15 --size=1024 --ondisk=sde
part raid.16 --size=1024 --ondisk=sdf

# This is the main '/' partition for 'dom0'. The remainder of the disk space
# will be hand-crafted into a RAID 5 partition post install for either DRBD or
# iSCSI.
part raid.21 --size=10240 --ondisk=sda
part raid.22 --size=10240 --ondisk=sdb
part raid.23 --size=10240 --ondisk=sdc
part raid.24 --size=10240 --ondisk=sdd
part raid.25 --size=10240 --ondisk=sde
part raid.26 --size=10240 --ondisk=sdf

# RAID configure.
raid /boot --fstype=ext3 --level=1 --spares=1 --device=md0 raid.01 raid.02 raid.03 raid.04 raid.05 raid.06
raid swap                --level=5 --spares=1 --device=md1 raid.11 raid.12 raid.13 raid.14 raid.15 raid.16
raid /     --fstype=ext4 --level=5 --spares=1 --device=md2 raid.21 raid.22 raid.23 raid.24 raid.25 raid.26
END
elif grep -q sde /proc/partitions; then
	### /dev/sdX RAID - This should be the majority.
	# 5-Drive RAID 5
cat >> /tmp/part-include <<END
zerombr
clearpart --all --initlabel --drives=sda,sdb,sdc,sdd,sde
ignoredisk --only-use=sda,sdb,sdc,sdd,sde
bootloader --location=mbr --driveorder=sda,sdb,sdc,sdd,sde --append="crashkernel=auto"


## This will create a 5-drive RAID 5 array.
# The '/boot' partition. A little nuts at 6x RAID 1 but meh, what else would I
# use the 256MB parts for?
part raid.01 --size=256 --ondisk=sda
part raid.02 --size=256 --ondisk=sdb
part raid.03 --size=256 --ondisk=sdc
part raid.04 --size=256 --ondisk=sdd
part raid.05 --size=256 --ondisk=sde

# The swap partition. Set to RAID 5, so it's actually ~5GB. It's RAID'ed and
# not individual parts because a loss of swap can still brind down a system.
part raid.11 --size=1024 --ondisk=sda
part raid.12 --size=1024 --ondisk=sdb
part raid.13 --size=1024 --ondisk=sdc
part raid.14 --size=1024 --ondisk=sdd
part raid.15 --size=1024 --ondisk=sde

# This is the main '/' partition for 'dom0'. The remainder of the disk space
# will be hand-crafted into a RAID 5 partition post install for either DRBD or
# iSCSI.
part raid.21 --size=10240 --ondisk=sda
part raid.22 --size=10240 --ondisk=sdb
part raid.23 --size=10240 --ondisk=sdc
part raid.24 --size=10240 --ondisk=sdd
part raid.25 --size=10240 --ondisk=sde

# RAID configure.
raid /boot --fstype=ext3 --level=1 --device=md0 raid.01 raid.02 raid.03 raid.04 raid.05
raid swap                --level=5 --device=md1 raid.11 raid.12 raid.13 raid.14 raid.15
raid /     --fstype=ext4 --level=5 --device=md2 raid.21 raid.22 raid.23 raid.24 raid.25
END
elif grep -q sdd /proc/partitions; then
	### /dev/sdX RAID - This should be the majority.
	# 4-Drive RAID 5
cat >> /tmp/part-include <<END
zerombr
clearpart --all --initlabel --drives=sda,sdb,sdc,sdd
ignoredisk --only-use=sda,sdb,sdc,sdd
bootloader --location=mbr --driveorder=sda,sdb,sdc,sdd --append="crashkernel=auto"

## This will create a 4-drive RAID 5 array.
# The '/boot' partition. A little nuts at 6x RAID 1 but meh, what else would I
# use the 256MB parts for?
part raid.01 --size=256 --ondisk=sda
part raid.02 --size=256 --ondisk=sdb
part raid.03 --size=256 --ondisk=sdc
part raid.04 --size=256 --ondisk=sdd

# The swap partition. Set to RAID 5, so it's actually ~8GB. It's RAID'ed and
# not individual parts because a loss of swap can still brind down a system.
part raid.11 --size=2048 --ondisk=sda
part raid.12 --size=2048 --ondisk=sdb
part raid.13 --size=2048 --ondisk=sdc
part raid.14 --size=2048 --ondisk=sdd

# This is the main '/' partition for 'dom0'. The remainder of the disk space
# will be hand-crafted into a RAID 5 partition post install for either DRBD or
# iSCSI.
part raid.21 --size=20480 --ondisk=sda
part raid.22 --size=20480 --ondisk=sdb
part raid.23 --size=20480 --ondisk=sdc
part raid.24 --size=20480 --ondisk=sdd

# RAID configure.
raid /boot --fstype=ext3 --level=1 --device=md0 raid.01 raid.02 raid.03 raid.04
raid swap                --level=5 --device=md1 raid.11 raid.12 raid.13 raid.14
raid /     --fstype=ext4 --level=5 --device=md2 raid.21 raid.22 raid.23 raid.24
END
elif grep -q sdc /proc/partitions; then
	### /dev/sdX RAID - This should be the majority.
	# 3-Drive RAID 5
cat >> /tmp/part-include <<END
zerombr
clearpart --all --initlabel --drives=sda,sdb,sdc
ignoredisk --only-use=sda,sdb,sdc
bootloader --location=mbr --driveorder=sda,sdb,sdc --append="crashkernel=auto"

## This will create a 3-drive RAID 5 array.
# The '/boot' partition. A little nuts at 6x RAID 1 but meh, what else would I
# use the 256MB parts for?
part raid.01 --size=256 --ondisk=sda
part raid.02 --size=256 --ondisk=sdb
part raid.03 --size=256 --ondisk=sdc

# The swap partition. Set to RAID 5, so it's actually ~4GB. It's RAID'ed and
# not individual parts because a loss of swap can still brind down a system.
part raid.11 --size=2048 --ondisk=sda
part raid.12 --size=2048 --ondisk=sdb
part raid.13 --size=2048 --ondisk=sdc

# This is the main '/' partition for 'dom0'. The remainder of the disk space
# will be hand-crafted into a RAID 5 partition post install for either DRBD or
# iSCSI.
part raid.21 --size=20480 --ondisk=sda
part raid.22 --size=20480 --ondisk=sdb
part raid.23 --size=20480 --ondisk=sdc

# RAID configure.
raid /boot --fstype=ext3 --level=1 --device=md0 raid.01 raid.02 raid.03
raid swap                --level=5 --device=md1 raid.11 raid.12 raid.13
raid /     --fstype=ext4 --level=5 --device=md2 raid.21 raid.22 raid.23
END
elif grep -q sdb /proc/partitions; then
	### /dev/sdX RAID - This should be the majority.
	# 2-Drive RAID 1
cat >> /tmp/part-include <<END
zerombr
clearpart --all --initlabel --drives=sda,sdb
ignoredisk --only-use=sda,sdb
bootloader  --location=mbr --driveorder=sda,sdb --append="crashkernel=auto"

# /boot
part raid.01 --ondisk=sda --asprimary --size=256
part raid.02 --ondisk=sdb --asprimary --size=256
# /
part raid.11 --ondisk=sda --asprimary --size=40960
part raid.12 --ondisk=sdb --asprimary --size=40960
# <swap>
part raid.21 --ondisk=sda --asprimary --size=4096
part raid.22 --ondisk=sdb --asprimary --size=4096

# Format /boot and /.
raid /boot --fstype=ext3 --level=1 --device=md0 raid.01 raid.02
raid /     --fstype=ext3 --level=1 --device=md1 raid.11 raid.12
raid swap  --fstype=swap --level=1 --device=md2 raid.21 raid.22
END
elif grep -q sda /proc/partitions; then
	### /dev/sda Single drive, or hardware RAID
cat >> /tmp/part-include <<END
zerombr
clearpart --linux --drives=sda
ignoredisk --only-use=sda
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto"

part     /boot --fstype ext3 --size=256   --asprimary
part     swap  --fstype swap --size=4096  --asprimary
part     /     --fstype ext3 --size=40960 --asprimary
END
elif grep -q xvda /proc/partitions; then
        ### /dev/sda Xen virtual disk
cat >> /tmp/part-include <<END
zerombr
clearpart --linux --drives=xvda
ignoredisk --only-use=xvda
bootloader --location=mbr --driveorder=xvda --append="crashkernel=auto"

part     /boot --fstype ext3 --size=256   --asprimary
part     swap  --fstype swap --size=4096  --asprimary
part     /     --fstype ext3 --size=40960 --asprimary
END
elif grep -q vda /proc/partitions; then
        ### /dev/vda KVM Virtual Drive
cat >> /tmp/part-include <<END
zerombr
clearpart --linux --drives=vda
ignoredisk --only-use=vda
bootloader --location=mbr --driveorder=vda --append="crashkernel=auto"

part     /boot --fstype ext3 --size=256   --asprimary
part     swap  --fstype swap --size=4096  --asprimary
part     /     --fstype ext3 --size=40960 --asprimary
END
fi

%end

 

Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.