32.8.5. Changing partition layout


The following example %pre script generates a different set of partitioning commands depending on whether the system has two drives or not.
%pre
#!/bin/sh
hds=""
mymedia=""
for file in /proc/ide/h* do
	mymedia=`cat $file/media`
	if [ $mymedia == "disk" ] ; then
		hds="$hds `basename $file`"
	fi
done
set $hds
numhd=`echo $#`
drive1=`echo $hds | cut -d' ' -f1`
drive2=`echo $hds | cut -d' ' -f2`
#Write out partition scheme based on whether there are 1 or 2 hard drives
if [ $numhd == "2" ] ; then
	#2 drives
	echo "#partitioning scheme generated in %pre for 2 drives" > /tmp/part-include
	echo "clearpart --all" >> /tmp/part-include
	echo "zerombr" >> /tmp/part-include
	echo "part /boot --fstype ext3 --size 75 --ondisk hda" >> /tmp/part-include
	echo "part / --fstype ext3 --size 1 --grow --ondisk hda" >> /tmp/part-include
	echo "part swap --recommended --ondisk $drive1" >> /tmp/part-include
	echo "part /home --fstype ext3 --size 1 --grow --ondisk hdb" >> /tmp/part-include
else
	#1 drive
	echo "#partitioning scheme generated in %pre for 1 drive" > /tmp/part-include
	echo "clearpart --all" >> /tmp/part-include
	echo "part /boot --fstype ext3 --size 75" >> /tmp/part-include
	echo "part swap --recommended" >> /tmp/part-include
	echo "part / --fstype ext3 --size 2048" >> /tmp/part-include
	echo "part /home --fstype ext3 --size 2048 --grow" >> /tmp/part-include
fi
%end
Adding the following line after the %pre script then instructs Kickstart to execute the commands that were generated by the script above:
%include /tmp/part-include
Red Hat logoGithubRedditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

© 2024 Red Hat, Inc.