Created
November 24, 2013 17:04
-
-
Save oogali/7629503 to your computer and use it in GitHub Desktop.
Kickstart snippet to avoid installing on wrong hard drive (or wiping your USB stick)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%pre | |
MIN_SIZE=100 | |
MAX_SIZE=600 | |
rootdisk= | |
for dev in sd vd xvd ; do | |
for drive in a b c d ; do | |
bdev="/sys/block/${dev}${drive}" | |
if [ -z "${rootdisk}" ]; then | |
if [ -d "${bdev}" ] && [ "$(cat ${bdev}/removable)" == "0" ]; then | |
devsize=$(($(cat ${bdev}/size)/2**21)) | |
if [ "${devsize}" -gt ${MIN_SIZE} ] && [ "${devsize}" -lt ${MAX_SIZE} ]; then | |
rootdisk="${dev}${drive}" | |
fi | |
fi | |
fi | |
done | |
done | |
cat <<EOF>>/tmp/drive-selection | |
bootloader --location=mbr --driveorder=${rootdisk} --append="crashkernel=auto" | |
clearpart --drives=${rootdisk} --all --initlabel | |
zerombr yes | |
part /boot --fstype=ext4 --size=1024 --ondisk=${rootdisk} | |
part swap --size=16384 --ondisk=${rootdisk} | |
part pv.253003 --grow --size=200 --ondisk=${rootdisk} | |
EOF | |
%end | |
%include /tmp/drive-selection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this was very useful :)