[CentOS] cleartpart in kickstart on CentOS 6

Kevin C linux at tuxalafenetre.net
Mon Jul 25 09:31:37 UTC 2011


On Mon, 25 Jul 2011 02:18:53 -0700 (PDT), John Doe wrote:

> Which clearpart parameters do you use?
> Something like that?
>   clearpart --drives=sda --all

I used this on CentOS 5 without any problems :
  clearpart --all --initlabel

I also use an pre script to detect the number of drives on the server

%pre
# Determine how many drives we have
set $(list-harddrives)
let numd=$#/2
d1=$1 # This is the device of disk 1
d2=$3 # This is the device of disk 2, etc.
S1=$2 # This is the size of disk 1
S2=$4 # This is the size of disk 2, etc.

# This would be a partition scheme for two or more drives
if [ $numd -ge 2 ]; then cat << EOF >> /tmp/partinfo
# Partition clearing information
clearpart --drives=$d1,$d2 --all --initlabel
part / --asprimary --fstype="ext3" --ondisk=$d1 --size=1024
part /boot --asprimary --fstype="ext3" --ondisk=$d1 --size=200
part swap --fstype="swap" --ondisk=$d1 --recommended
part /var --fstype="ext3" --ondisk=$d1  --grow --size=1
part /var/spool/squid --fstype="ext3" --ondisk=$d2  --grow --size=1
part /usr --fstype="ext3"  --ondisk=$d1 --size=4096
part /tmp --fstype="ext3"  --ondisk=$d1 --size=1024
part /home --fstype="ext3"  --ondisk=$d1 --size=5120
EOF

else

cat << EOF >> /tmp/partinfo
# Partition clearing information
clearpart --drives=$d1 --all --initlabel
part / --asprimary --fstype="ext3" --ondisk=$d1 --size=1024
part /boot --asprimary --fstype="ext3" --ondisk=$d1 --size=200
part swap --fstype="swap" --ondisk=$d1 --recommended
part /var --fstype="ext3" --ondisk=$d1  --size=4096
part /var/spool/squid --fstype="ext3" --ondisk=$d1  --grow --size=1
part /usr --fstype="ext3"  --ondisk=$d1 --size=4096
part /tmp --fstype="ext3"  --ondisk=$d1 --size=1024
part /home --fstype="ext3"  --ondisk=$d1 --size=5120
EOF
fi


> Personally I use a %pre script to manually wipe+partition+format...

In Python,Perl or Shell? I'm searching how to wipe all drives with 
parted or fdisk.

Here is my kickstart :

# platform=x86, AMD64, ou Intel EM64T
# version=CentOS6
##### DEBUG :
#cmdline
####
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Root password
rootpw  --iscrypted S€cr€t
# Network information
network --device eth0 --bootproto dhcp
# System keyboard
keyboard fr-latin9
# System language
lang en_US.UTF-8
# SELinux configuration
selinux --enforcing
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Utilisation d'une installation via un serveur NFS
nfs --server=172.18.101.24 --dir=Miroir/CentOS/6.0/os/i386
# Reboot after installation
reboot
# System timezone
timezone --isUtc Europe/Paris
# System bootloader configuration
bootloader --location=mbr
# Disk partitioning information
clearpart --all --initlabel
# Magically figure out how to partition this thing
%include /tmp/partinfo

%pre
# Determine how many drives we have
set $(list-harddrives)
let numd=$#/2
d1=$1 # This is the device of disk 1
d2=$3 # This is the device of disk 2, etc.
S1=$2 # This is the size of disk 1
S2=$4 # This is the size of disk 2, etc.

# This would be a partition scheme for two or more drives
if [ $numd -ge 2 ]; then cat << EOF >> /tmp/partinfo
# Partition clearing information
clearpart --drives=$d1,$d2 --all --initlabel
part / --asprimary --fstype="ext3" --ondisk=$d1 --size=1024
part /boot --asprimary --fstype="ext3" --ondisk=$d1 --size=200
part swap --fstype="swap" --ondisk=$d1 --recommended
part /var --fstype="ext3" --ondisk=$d1  --grow --size=1
part /var/spool/squid --fstype="ext3" --ondisk=$d2  --grow --size=1
part /usr --fstype="ext3"  --ondisk=$d1 --size=4096
part /tmp --fstype="ext3"  --ondisk=$d1 --size=1024
part /home --fstype="ext3"  --ondisk=$d1 --size=5120
EOF

else

cat << EOF >> /tmp/partinfo
# Partition clearing information
clearpart --drives=$d1 --all --initlabel
part / --asprimary --fstype="ext3" --ondisk=$d1 --size=1024
part /boot --asprimary --fstype="ext3" --ondisk=$d1 --size=200
part swap --fstype="swap" --ondisk=$d1 --recommended
part /var --fstype="ext3" --ondisk=$d1  --size=4096
part /var/spool/squid --fstype="ext3" --ondisk=$d1  --grow --size=1
part /usr --fstype="ext3"  --ondisk=$d1 --size=4096
part /tmp --fstype="ext3"  --ondisk=$d1 --size=1024
part /home --fstype="ext3"  --ondisk=$d1 --size=5120
EOF
fi


%packages
@base
@console-internet
@core
vim-enhanced
-firstboot
-pcmciautils
-at
-rfkill
yum-presto
squid
postfix
gcc
make
sgpio
dos2unix
unix2dos
ftp
lftp
bind-libs
yum-plugin-fastestmirror
libss
ConsoleKit-libs
libedit
libtar
nss_compat_ossl
libfprint
libnih
fipscheck-lib
wget

%post --log=/root/ks-post.log
wget -N 
http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
rpm -Uvh epel-release-6-5.noarch.rpm
sed -i".bak" s/NM_CONTROLLED\=yes/NM_CONTROLLED\=no/ ifcfg-eth*
service network restart
yum install -y squidGuard
yum update -y
chkconfig postfix on
mount -t nfs 172.18.101.24:/Scripts/	/mnt
cp /mnt/linsecu.pl /root/linsecu.pl
umount /mnt


> JD
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos

-- 
Kevin C



More information about the CentOS mailing list