diff --git a/README.md b/README.md index 8d54f78..6c92fe4 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Directory | Files | Note ### Generate installer ISO ```shell -export DISK_DEVS=sda,sdb # System has /dev/sda and /dev/sdb +export DISK_DEVS=sda,sdb # Disks usable by the installer; ones not present on the machine are skipped export MAIN_DISK=sda # Install OS to /dev/sda export PARTSIZE_DOCKER=8192 # 8G export PARTSIZE_LOG=2048 # 2G diff --git a/ks.tpl.cfg b/ks.tpl.cfg index ee5ef6e..48048d3 100644 --- a/ks.tpl.cfg +++ b/ks.tpl.cfg @@ -7,7 +7,8 @@ cmdline reboot # Run the Setup Agent on first boot firstboot --disable -ignoredisk --only-use=@@DISK_DEVS@@ +# ignoredisk/clearpart with the disks existing on this machine, generated in %pre +%include /tmp/ks.diskdevs.cfg # Keyboard layouts keyboard --vckeymap=us --xlayouts='jp' # System language @@ -25,8 +26,6 @@ group --name=docker %include /tmp/ks.media.cfg -# Partition clearing information -clearpart --all --initlabel --drives=@@DISK_DEVS@@ # Create partitions part /boot/efi --fstype="efi" --ondisk=@@MAIN_DISK@@ --size=200 --fsoptions="umask=0077,shortname=winnt" part / --fstype="ext4" --ondisk=@@MAIN_DISK@@ --size=2048 --mkfsoptions="-U 64eb4db5-3385-46a5-a3d5-c48197a53555" @@ -59,6 +58,26 @@ else echo "url --url http://172.16.250.1/iso" > /tmp/ks.media.cfg fi +# Pick only the disks that exist on this machine +diskdevs= +for dev in $(echo @@DISK_DEVS@@ | tr "," " ") +do + if [ -b "/dev/${dev}" ] + then + diskdevs="${diskdevs:+${diskdevs},}${dev}" + else + echo "disk ${dev} not found, skipped" + fi +done +if [ -z "${diskdevs}" ] +then + echo "no disks in DISK_DEVS (@@DISK_DEVS@@) found" +fi +cat > /tmp/ks.diskdevs.cfg <