make cobbler support reserve disk space
Closes-Bug: 1399880 Change-Id: I44cc52e90ca1be0033d5f4b030eb90cb99bbc01b
This commit is contained in:
parent
fc34b4e9ce
commit
cf0c3bdcc9
@ -57,7 +57,7 @@ install
|
||||
reboot
|
||||
|
||||
%pre
|
||||
$SNIPPET('kickstar_pre_log')
|
||||
$SNIPPET('kickstart_pre_log')
|
||||
$SNIPPET('kickstart_start')
|
||||
$SNIPPET('kickstart_pre_install_network_config')
|
||||
$SNIPPET('kickstart_pre_partition_disks')
|
||||
@ -80,12 +80,14 @@ libestr
|
||||
libgt
|
||||
liblogging
|
||||
rsyslog
|
||||
parted
|
||||
%end
|
||||
|
||||
%post --log=/var/log/post_install.log
|
||||
$SNIPPET('kickstart_post_log')
|
||||
$SNIPPET('kickstart_post_install_kernel_options')
|
||||
$SNIPPET('kickstart_post_install_network_config')
|
||||
$SNIPPET('kickstart_post_partition_disks')
|
||||
|
||||
chkconfig iptables off
|
||||
chkconfig ip6tables off
|
||||
|
@ -66,6 +66,7 @@ d-i live-installer/net-image string http://$http_server/cobbler/ks_mirror/$distr
|
||||
# root account and password
|
||||
d-i passwd/root-login boolean true
|
||||
d-i passwd/make-user boolean false
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
#if $getVar('password', '') != ""
|
||||
d-i passwd/root-password-crypted password $password
|
||||
#else
|
||||
|
@ -2,6 +2,7 @@
|
||||
# This script runs in the chroot /target by default
|
||||
$SNIPPET('preseed_post_install_kernel_options')
|
||||
$SNIPPET('preseed_post_install_network_config')
|
||||
$SNIPPET('preseed_post_partition_disks')
|
||||
$SNIPPET('preseed_ssh')
|
||||
$SNIPPET('preseed_ntp')
|
||||
$SNIPPET('preseed_post_apt_repo_config')
|
||||
|
33
cobbler/snippets/kickstart_post_partition_disks
Normal file
33
cobbler/snippets/kickstart_post_partition_disks
Normal file
@ -0,0 +1,33 @@
|
||||
partitions=\$(pvs --noheadings --separator :| cut -d: -f1,2)
|
||||
vg_remove=0
|
||||
remove_partitions=''
|
||||
echo "partitions \$partitions" >> /tmp/post_partition.log
|
||||
|
||||
for partition in \$partitions; do
|
||||
partition_vg=(\${partition//:/ })
|
||||
partition=\${partition_vg[0]}
|
||||
vg=\${partition_vg[1]}
|
||||
if [[ "\$vg" == "reserved" ]]; then
|
||||
echo "prepare remove partition \$partition" >> /tmp/post_partition.log
|
||||
remove_partitions="\${remove_partitions} \$partition"
|
||||
vg_remove=1
|
||||
else
|
||||
echo "ignore \$vg since it is not reserved" >> /tmp/post_partition.log
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "\${vg_remove}" != "0" ]]; then
|
||||
vgremove -f reserved
|
||||
fi
|
||||
|
||||
for remove_partition in \${remove_partitions}; do
|
||||
echo "remove partition \${remove_partition}" >> /tmp/post_partition.log
|
||||
pvremove -ff -y \${remove_partition}
|
||||
set \$(echo \${remove_partition} | sed -e 's/^\(.*\)\([0-9]\+\)\$/\1 \2/g')
|
||||
partition_disk=\$1
|
||||
partition_number=\$2
|
||||
if [ -z "\${partition_disk}" -o -z "\${partition_number}" ]; then
|
||||
continue
|
||||
fi
|
||||
parted \${partition_disk} rm \${partition_number}
|
||||
done
|
@ -24,7 +24,7 @@ get_ifname() {
|
||||
IFNAME=$(esxcfg-nics -l | grep -i "$1" | cut -d " " -f 1)
|
||||
else
|
||||
IFNAME=$(ifconfig -a | grep -i "$1" | cut -d " " -f 1)
|
||||
if [ -z $IFNAME ]; then
|
||||
if [ -z "$IFNAME" ]; then
|
||||
IFNAME=$(ifconfig -a | grep -i -B 2 "$1" | sed -n '/flags/s/:.*$//p')
|
||||
fi
|
||||
fi
|
||||
|
@ -3,6 +3,9 @@
|
||||
#set partition_size = $getVar('partition_size', None)
|
||||
#set partition_maxsize = $getVar('partition_maxsize', None)
|
||||
#set disk_reserve_size = $getVar('disk_reserve_size', None)
|
||||
#set disk_max_size = $getVar('disk_max_size', None)
|
||||
#set default_disk_reserve_size = $getVar('default_disk_reserve_size', '0')
|
||||
#set default_disk_max_size = $getVar('default_disk_max_size', '0')
|
||||
|
||||
#if $hostname == None
|
||||
#set $vgname = "VolGroup00"
|
||||
@ -121,6 +124,8 @@ declare -A reserve_disks_size
|
||||
#set disk_name, size = $disk_and_size.split(' ', 1)
|
||||
#set disk_name = $disk_name.strip()
|
||||
#if $size.endswith('K')
|
||||
#set disk_size = $int($size[:-1]) / 1000
|
||||
#elif size.endswith('M')
|
||||
#set disk_size = $int($size[:-1])
|
||||
#elif $size.endswith('G')
|
||||
#set disk_size = $int($size[:-1]) * 1000
|
||||
@ -137,6 +142,57 @@ disk=/dev/${disk_name}
|
||||
reserve_disks_size[\$disk]=${disk_size}
|
||||
#end for
|
||||
#end if
|
||||
#if $default_disk_reserve_size.endswith('K')
|
||||
#set disk_size = $int($default_disk_reserve_size[:-1]) / 1000
|
||||
#elif $default_disk_reserve_size.endswith('M')
|
||||
#set disk_size = $int($default_disk_reserve_size[:-1])
|
||||
#elif $default_disk_reserve_size.endswith('G')
|
||||
#set disk_size = $int($default_disk_reserve_size[:-1]) * 1000
|
||||
#elif $default_disk_reserve_size.endswith('T')
|
||||
#set disk_size = $int($default_disk_reserve_size[:-1]) * 1000000
|
||||
#else
|
||||
#set disk_size = $int($default_disk_reserve_size)
|
||||
#end if
|
||||
default_reserve_disk_size=${disk_size}
|
||||
|
||||
declare -A max_disks_size
|
||||
#if $disk_max_size != None
|
||||
#set disk_sizes = [disk_size.strip() for disk_size in $disk_max_size.split(';') if disk_size.strip()]
|
||||
#for disk_and_size in $disk_sizes
|
||||
#set disk_name, size = $disk_and_size.split(' ', 1)
|
||||
#set disk_name = $disk_name.strip()
|
||||
#if $size.endswith('K')
|
||||
#set disk_size = $int($size[:-1]) / 1000
|
||||
#elif $size.endswith('M')
|
||||
#set disk_size = $int($size[:-1])
|
||||
#elif $size.endswith('G')
|
||||
#set disk_size = $int($size[:-1]) * 1000
|
||||
#elif $size.endswith('T')
|
||||
#set disk_size = $int($size[:-1]) * 1000000
|
||||
#else
|
||||
#set disk_size = $int($size)
|
||||
#end if
|
||||
#if $getVar('partition_by_path', '0') != "0"
|
||||
disk=/dev/disk/by-path/\${disk_mapping[\${disk_name}]}
|
||||
#else
|
||||
disk=/dev/${disk_name}
|
||||
#end if
|
||||
max_disks_size[\$disk]=${disk_size}
|
||||
#end for
|
||||
#end if
|
||||
|
||||
#if $default_disk_max_size.endswith('K')
|
||||
#set disk_size = $int($default_disk_max_size[:-1]) / 1000
|
||||
#elif $default_disk_max_size.endswith('M')
|
||||
#set disk_size = $int($default_disk_max_size[:-1])
|
||||
#elif $default_disk_max_size.endswith('G')
|
||||
#set disk_size = $int($default_disk_max_size[:-1]) * 1000
|
||||
#elif $default_disk_max_size.endswith('T')
|
||||
#set disk_size = $int($default_disk_max_size[:-1]) * 1000000
|
||||
#else
|
||||
#set disk_size = $int($default_disk_max_size)
|
||||
#end if
|
||||
default_max_disk_size=${disk_size}
|
||||
|
||||
declare -A partitions_percentage
|
||||
declare -A partitions_name
|
||||
@ -261,24 +317,49 @@ if [[ x"\${partitions_name[/]}" == x"" ]]; then
|
||||
partitions_name[/]="root"
|
||||
fi
|
||||
|
||||
echo "partition disks" >> /tmp/log
|
||||
|
||||
vggroup=''
|
||||
reserve_vggroup=''
|
||||
let disk_nums=\${#sorted_disks[@]}
|
||||
let disk_offset=0
|
||||
while [ \$disk_offset -lt \$disk_nums ];
|
||||
do
|
||||
let pv_id=\$disk_offset+1
|
||||
disk=\${sorted_disks[\$disk_offset]}
|
||||
if [ ! -z \${reserve_disks_size[\${disk}]} ]; then
|
||||
reserve_partname="reverse.0\$pv_id"
|
||||
reserve_disk_size=\${reserve_disks_size[\${disk}]}
|
||||
echo "part \${reserve_partname} --size=\${reserve_disk_size} --ondisk=\${disk}" >> /tmp/part-include
|
||||
fi
|
||||
partname="pv.0\$pv_id"
|
||||
echo "part \$partname --size=1 --grow --ondisk=\${disk}" >> /tmp/part-include
|
||||
vggroup="\$vggroup \$partname"
|
||||
let disk_offset=\$disk_offset+1;
|
||||
while [ \${disk_offset} -lt \${disk_nums} ]; do
|
||||
let pv_id=\${disk_offset}+1
|
||||
disk=\${sorted_disks[\${disk_offset}]}
|
||||
if [ ! -z "\${reserve_disks_size[\$disk]}" ]; then
|
||||
reserve_disk_size=\${reserve_disks_size[\$disk]}
|
||||
else
|
||||
reserve_disk_size=\${default_reserve_disk_size}
|
||||
fi
|
||||
echo "reserve \${reserve_disk_size} on \${disk}" >> /tmp/log
|
||||
if [ \${reserve_disk_size} -gt 0 ]; then
|
||||
reserve_partname="pv.1\${pv_id}"
|
||||
echo "part \${reserve_partname} --size=\${reserve_disk_size} --ondisk=\${disk}" >> /tmp/part-include
|
||||
reserve_vggroup="\${reserve_vggroup} \${reserve_partname}"
|
||||
fi
|
||||
partname="pv.0\${pv_id}"
|
||||
if [ ! -z "\${max_disks_size[\${disk}]}" ]; then
|
||||
max_disk_size=\${max_disks_size[\${disk}]}
|
||||
else
|
||||
max_disk_size=\${default_max_disk_size}
|
||||
fi
|
||||
echo "partition \${disk} max size \${max_disk_size}" >> /tmp/log
|
||||
if [ \${max_disk_size} -gt 0 ]; then
|
||||
maxsize_param="--maxsize=\${max_disks_size[\${disk}]}"
|
||||
else
|
||||
maxsize_param=""
|
||||
fi
|
||||
echo "part \$partname --size=1 --grow \${maxsize_param} --ondisk=\${disk}" >> /tmp/part-include
|
||||
vggroup="\$vggroup \$partname"
|
||||
let disk_offset=\$disk_offset+1;
|
||||
done
|
||||
|
||||
echo "volgroup $vgname \$vggroup" >> /tmp/part-include
|
||||
if [ ! -z "\${reserve_vggroup}" ]; then
|
||||
echo "volgroup reserved \${reserve_vggroup}" >> /tmp/part-include
|
||||
fi
|
||||
if [ ! -z "\$vggroup" ]; then
|
||||
echo "volgroup $vgname \$vggroup" >> /tmp/part-include
|
||||
fi
|
||||
|
||||
declare -A sorted_partitions
|
||||
sorted_partitions[0]=\${default_partition}
|
||||
|
@ -35,7 +35,7 @@ echo '' > /tmp/network_log
|
||||
physical_interfaces=""
|
||||
for physical_interface in \$(ip -o link | cut -d: -f2 | grep -v lo); do
|
||||
echo "processing physical interface \${physical_interface}" >> /tmp/network_log
|
||||
if [ -z \${physical_interfaces} ]; then
|
||||
if [ -z "\${physical_interfaces}" ]; then
|
||||
physical_interfaces="\${physical_interface}"
|
||||
else
|
||||
physical_interfaces="\${physical_interfaces} \${physical_interface}"
|
||||
@ -69,7 +69,7 @@ logical_interfaces=""
|
||||
#if $interface_type in ("master","bond","bonded_bridge_slave")
|
||||
#set $numbondingdevs += 1
|
||||
#end if
|
||||
if [ -z \${logical_interfaces} ]; then
|
||||
if [ -z "\${logical_interfaces}" ]; then
|
||||
logical_interfaces="$iname"
|
||||
else
|
||||
logical_interfaces="\${logical_interfaces} $iname"
|
||||
@ -77,7 +77,7 @@ fi
|
||||
#if $mac != ""
|
||||
#set mac = $mac.replace(':', '_')
|
||||
physical_interface=\${physical_mac_interface_$mac}
|
||||
if [ ! -z \${physical_interface} ]; then
|
||||
if [ ! -z "\${physical_interface}" ]; then
|
||||
logical_interface_mapping_$iname=\${physical_interface}
|
||||
eval "physical_interface_mapping_\${physical_interface}=$iname"
|
||||
echo "set logical interface $iname map to physical interface \${physical_interface}" >> /tmp/network_log
|
||||
@ -93,11 +93,11 @@ echo "logical interfaces \${logical_interfaces}" >> /tmp/network_log
|
||||
|
||||
for logical_interface in \${logical_interfaces}; do
|
||||
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
|
||||
if [ ! -z \${physical_interface} ]; then
|
||||
if [ ! -z "\${physical_interface}" ]; then
|
||||
continue
|
||||
fi
|
||||
eval "physical_interface_mac=\\${physical_interface_mac_\${logical_interface}}"
|
||||
if [ -z \${physical_interface_mac} ]; then
|
||||
if [ -z "\${physical_interface_mac}" ]; then
|
||||
continue
|
||||
fi
|
||||
eval "logical_interface_mapping_\${logical_interface}=\${logical_interface}"
|
||||
@ -108,10 +108,10 @@ done
|
||||
unset_physical_interfaces=""
|
||||
for physical_interface in \${physical_interfaces}; do
|
||||
eval "logical_interface=\\${physical_interface_mapping_\${physical_interface}}"
|
||||
if [ ! -z \${logical_interface} ]; then
|
||||
if [ ! -z "\${logical_interface}" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -z \${unset_physical_interfaces} ]; then
|
||||
if [ -z "\${unset_physical_interfaces}" ]; then
|
||||
unset_physical_interfaces="\${physical_interface}"
|
||||
else
|
||||
unset_physical_interfaces="\${unset_physical_interfaces} \${physical_interface}"
|
||||
@ -122,10 +122,10 @@ echo "unset phsycial interfaces \${unset_physiccal_interfaces}" >> /tmp/network_
|
||||
unset_logical_interfaces=""
|
||||
for logical_interface in \${logical_interfaces}; do
|
||||
eval "physical_interface=\\${logical_interface_mapping_\${logical_interface}}"
|
||||
if [ ! -z \${physical_interface} ]; then
|
||||
if [ ! -z "\${physical_interface}" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -z \${unset_logical_interfaces} ]; then
|
||||
if [ -z "\${unset_logical_interfaces}" ]; then
|
||||
unset_logical_interfaces="\${logical_interface}"
|
||||
else
|
||||
unset_logical_interfaces="\${unset_logical_interfaces} \${logical_interface}"
|
||||
@ -247,14 +247,14 @@ echo "iface $iname inet dhcp" >> /etc/network/interfaces
|
||||
#pass
|
||||
#else
|
||||
physical_interface=\${logical_interface_mapping_$iname}
|
||||
if [ ! -z \${physical_interface} ]; then
|
||||
if [ ! -z "\${physical_interface}" ]; then
|
||||
eval "physical_mac=\\${physical_interface_mac_\${physical_interface}}"
|
||||
fi
|
||||
if [ ! -z \$physical_mac ]; then
|
||||
if [ ! -z "\${physical_mac}" ]; then
|
||||
physical_mac=\$(echo \${physical_mac} | tr '_' ':')
|
||||
echo " hwaddress ether \${physical_mac}" >> /etc/network/interfaces
|
||||
fi
|
||||
if [ -f "/etc/modprobe.conf" ] && [ ! -z \$physical_interface ]; then
|
||||
if [ -f "/etc/modprobe.conf" ] && [ ! -z "\${physical_interface}" ]; then
|
||||
grep \${physical_interface} /etc/modprobe.conf | sed "s/\$physical_interface/$iname/" >> /etc/modprobe.conf.cobbler
|
||||
grep -v \${physical_interface} /etc/modprobe.conf >> /etc/modprobe.conf.new
|
||||
rm -f /etc/modprobe.conf
|
||||
@ -346,7 +346,7 @@ for physical_interface in \${sorted_physical_interfaces}; do
|
||||
echo "auto \${physical_interface}" >> /etc/network/interfaces
|
||||
echo "iface \${physical_interface} inet static" >> /etc/network/interfaces
|
||||
eval "physical_mac=\\${physical_interface_mac_\${physical_interface}}"
|
||||
if [ ! -z \${physical_mac} ]; then
|
||||
if [ ! -z "\${physical_mac}" ]; then
|
||||
physical_mac=\$(echo \${physical_mac} | tr '_' ':')
|
||||
echo " hwaddress ether \${physical_mac}" >> /etc/network/interfaces
|
||||
fi
|
||||
|
34
cobbler/snippets/preseed_post_partition_disks
Normal file
34
cobbler/snippets/preseed_post_partition_disks
Normal file
@ -0,0 +1,34 @@
|
||||
set \$(ls -l /dev/disk/by-label | tr -s '\t' ' ' | cut -d' ' -f9,11)
|
||||
label_mapping_nums=\$((\$#/2))
|
||||
label_mapping_offset=0
|
||||
echo "label_mapping_nums: \$label_mapping_nums" >> /tmp/preseed.log
|
||||
remove_partitions=""
|
||||
while [ \$label_mapping_offset -lt \$label_mapping_nums ]; do
|
||||
partition_label=\$1
|
||||
partition_name=\$(basename \$2)
|
||||
shift 2
|
||||
label_mapping_offset=\$((\${label_mapping_offset}+1))
|
||||
if [ -z "\${partition_label}" -o -z "\${partition_name}" ]; then
|
||||
continue
|
||||
fi
|
||||
partition=/dev/\${partition_name}
|
||||
if expr match "\${partition_label}" "reserved_.*"; then
|
||||
remove_partitions="\${remove_partitions} \${partition}"
|
||||
echo "add \${partition} into remove list" >> /tmp/preseed.log
|
||||
fi
|
||||
done
|
||||
echo "remove partitions \${remove_partitions}" >> /tmp/preseed.log
|
||||
|
||||
for partition in \${remove_partitions}; do
|
||||
if [ -z "\$partition" ]; then
|
||||
continue
|
||||
fi
|
||||
set \$(echo \${partition} | sed -e 's/^\(.*\)\([0-9]\+\)\$/\1 \2/g')
|
||||
partition_disk=\$1
|
||||
partition_number=\$2
|
||||
echo "remove disk \${partition_disk} partition \${partition_number}" >> /tmp/preseed.log
|
||||
if [ -z "\${partition_disk}" -o -z "\${partition_number}" ]; then
|
||||
continue
|
||||
fi
|
||||
parted \${partition_disk} rm \${partition_number}
|
||||
done
|
@ -25,7 +25,7 @@ get_ifname() {
|
||||
IFNAME=$(esxcfg-nics -l | grep -i "$1" | cut -d " " -f 1)
|
||||
else
|
||||
IFNAME=$(ifconfig -a | grep -i "$1" | cut -d " " -f 1)
|
||||
if [ -z $IFNAME ]; then
|
||||
if [ -z "$IFNAME" ]; then
|
||||
IFNAME=$(ifconfig -a | grep -i -B 2 "$1" | sed -n '/flags/s/:.*$//p')
|
||||
fi
|
||||
fi
|
||||
|
@ -3,6 +3,9 @@
|
||||
#set partition_size = $getVar('partition_size', None)
|
||||
#set partition_maxsize = $getVar('partition_maxsize', None)
|
||||
#set disk_reserve_size = $getVar('disk_reserve_size', None)
|
||||
#set disk_max_size = $getVar('disk_max_size', None)
|
||||
#set default_disk_reserve_size = $getVar('default_disk_reserve_size', '0')
|
||||
#set default_disk_max_size = $getVar('default_disk_max_size', '0')
|
||||
|
||||
#if $hostname == None
|
||||
#set $vgname = "VolGroup00"
|
||||
@ -24,21 +27,22 @@ while [ \$disk_mapping_offset -lt \$disk_mapping_nums ]; do
|
||||
#else
|
||||
found_disk_type=1
|
||||
#end if
|
||||
disk_path=\$(echo \$1 | tr '-' '_' | tr ':' '_' | tr '.' '_')
|
||||
disk_name=\$(basename \$2)
|
||||
disk_mapping_offset=\$((\${disk_mapping_offset}+1))
|
||||
shift 2
|
||||
|
||||
if [ \$found_disk_type -gt 0 ]; then
|
||||
disk_name=\$(basename \$2)
|
||||
if [ -z "\${disk_mapping}" ]; then
|
||||
disk_mapping="\${disk_name}"
|
||||
else
|
||||
disk_mapping="\${disk_mapping} \${disk_name}"
|
||||
fi
|
||||
disk_path=\$(echo \$1 | tr '-' '_' | tr ':' '_' | tr '.' '_')
|
||||
eval "disk_\${disk_name}=\${disk_path}"
|
||||
eval "disk_\${disk_path}=\${disk_path}"
|
||||
eval "disk_path_\${disk_path}=/dev/\${disk_name}"
|
||||
eval "disk_path_\${disk_name}=/dev/\${disk_name}"
|
||||
fi
|
||||
disk_mapping_offset=\$((\${disk_mapping_offset}+1))
|
||||
shift 2
|
||||
done
|
||||
|
||||
for key in \${disk_mapping}; do
|
||||
@ -49,7 +53,7 @@ done
|
||||
partition_disks=""
|
||||
disks=""
|
||||
for disk in \$(list-devices disk); do
|
||||
if [ -z \$disk ]; then
|
||||
if [ -z "\$disk" ]; then
|
||||
continue
|
||||
fi
|
||||
disk_name=\$(basename \$disk)
|
||||
@ -57,7 +61,7 @@ for disk in \$(list-devices disk); do
|
||||
dd if=/dev/zero of=\$disk bs=512 count=1
|
||||
#end if
|
||||
eval "disk_path=\\${disk_\${disk_name}}"
|
||||
if [ -z \${disk_path} ]; then
|
||||
if [ -z "\${disk_path}" ]; then
|
||||
echo "ignore disk \${disk_name} since it is not in disk_mapping" >> /tmp/preseed.log
|
||||
continue
|
||||
fi
|
||||
@ -81,13 +85,13 @@ for disk in \$(list-devices disk); do
|
||||
#end if
|
||||
if [ \$found_disk -gt 0 ]; then
|
||||
echo "add disk \${disk_name} in partitioning list" >> /tmp/preseed.log
|
||||
if [ -z \$partition_disks ]; then
|
||||
if [ -z "\${partition_disks}" ]; then
|
||||
partition_disks="\${disk_name}"
|
||||
else
|
||||
partition_disks="\${partition_disks} \${disk_name}"
|
||||
fi
|
||||
fi
|
||||
if [ -z \$disks ]; then
|
||||
if [ -z "\$disks" ]; then
|
||||
disks="\${disk_name}"
|
||||
else
|
||||
disks="\${disks} \${disk_name}"
|
||||
@ -123,10 +127,10 @@ echo "sorted disks for $disk_num disks: \${sorted_disks}" >> /tmp/preseed.log
|
||||
|
||||
first_disk_name=""
|
||||
for disk_name in \${sorted_disks}; do
|
||||
if [ -z \${disk_name} ]; then
|
||||
if [ -z "\${disk_name}" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -z \${first_disk_name} ]; then
|
||||
if [ -z "\${first_disk_name}" ]; then
|
||||
first_disk_name=\${disk_name}
|
||||
break
|
||||
fi
|
||||
@ -135,11 +139,11 @@ echo "first disk \${first_disk_name}" >> /tmp/preseed.log
|
||||
|
||||
#if $getVar('keep_old_partitions', '0') != "0"
|
||||
for disk_name in \${sorted_disks}; do
|
||||
if [ -z \${disk_name} ]; then
|
||||
if [ -z "\${disk_name}" ]; then
|
||||
continue
|
||||
fi
|
||||
eval "disk=\\${disk_path_\${disk_name}}"
|
||||
if [ -z \${disk} ]; then
|
||||
if [ -z "\${disk}" ]; then
|
||||
continue
|
||||
fi
|
||||
dd if=/dev/zero of=\${disk} bs=512 count=1
|
||||
@ -155,7 +159,7 @@ disk_partitions=\$(pvs --noheadings --separator :| cut -d: -f1)
|
||||
remove_partitions=""
|
||||
remove_vgs=""
|
||||
for disk_partition in \${disk_partitions}; do
|
||||
if [ -z \$disk_partition ]; then
|
||||
if [ -z "\${disk_partition}" ]; then
|
||||
continue
|
||||
fi
|
||||
disk_partition_name=\$(basename \${disk_partition})
|
||||
@ -163,11 +167,11 @@ for disk_partition in \${disk_partitions}; do
|
||||
remove_vg=""
|
||||
remove_partition=""
|
||||
for remove_disk_name in \${remove_disks}; do
|
||||
if [ -z \${remove_disk_name} ]; then
|
||||
if [ -z "\${remove_disk_name}" ]; then
|
||||
continue
|
||||
fi
|
||||
eval "remove_disk=\\${disk_path_\${remove_disk_name}}"
|
||||
if [ -z \${remove_disk} ]; then
|
||||
if [ -z "\${remove_disk}" ]; then
|
||||
continue
|
||||
fi
|
||||
if expr match "\${disk_partition}" "\${remove_disk}.*"; then
|
||||
@ -177,8 +181,8 @@ for disk_partition in \${disk_partitions}; do
|
||||
echo "partition \${disk_partition} does not match \${remove_disk}.*" >> /tmp/preseed.log
|
||||
fi
|
||||
done
|
||||
if [ ! -z \$remove_vg ]; then
|
||||
if [ -z \$remove_vgs ]; then
|
||||
if [ ! -z "\${remove_vg}" ]; then
|
||||
if [ -z "\${remove_vgs}" ]; then
|
||||
remove_vgs="\${remove_vg}"
|
||||
else
|
||||
vg_removed=0
|
||||
@ -192,8 +196,8 @@ for disk_partition in \${disk_partitions}; do
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ ! -z \$remove_partition ]; then
|
||||
if [ -z \$remove_partitions ]; then
|
||||
if [ ! -z "\${remove_partition}" ]; then
|
||||
if [ -z "\${remove_partitions}" ]; then
|
||||
remove_partitions="\${remove_partition}"
|
||||
else
|
||||
remove_partitions="\${remove_partitions} \${remove_partition}"
|
||||
@ -213,14 +217,14 @@ done
|
||||
select_disks=""
|
||||
echo "remove disks \${remove_disks}" >> /tmp/preseed.log
|
||||
for remove_disk_name in \${remove_disks}; do
|
||||
if [ -z \${remove_disk_name} ]; then
|
||||
if [ -z "\${remove_disk_name}" ]; then
|
||||
continue
|
||||
fi
|
||||
eval "remove_disk=\\${disk_path_\${remove_disk_name}}"
|
||||
if [ -z \$remove_disk ]; then
|
||||
if [ -z "\${remove_disk}" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -z \${select_disks} ]; then
|
||||
if [ -z "\${select_disks}" ]; then
|
||||
select_disks="\${remove_disk}"
|
||||
else
|
||||
select_disks="\${select_disks},\${remove_disk}"
|
||||
@ -231,14 +235,14 @@ echo "select disks \${select_disks}" >> /tmp/preseed.log
|
||||
|
||||
partition_disks=""
|
||||
for disk_name in \${sorted_disks}; do
|
||||
if [ -z \${disk_name} ]; then
|
||||
if [ -z "\${disk_name}" ]; then
|
||||
continue
|
||||
fi
|
||||
eval "disk=\\${disk_path_\${disk_name}}"
|
||||
if [ -z \$disk ]; then
|
||||
if [ -z "\$disk" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -z \${partition_disks} ]; then
|
||||
if [ -z "\${partition_disks}" ]; then
|
||||
partition_disks="\${disk}"
|
||||
else
|
||||
partition_disks="\${partition_disks} \${disk}"
|
||||
@ -259,6 +263,8 @@ echo "partition fstype \${partition_fstype}" >> /tmp/preseed.log
|
||||
#set disk_name, size = $disk_and_size.split(' ', 1)
|
||||
#set disk_name = $disk_name.strip()
|
||||
#if $size.endswith('K')
|
||||
#set disk_size = $int($size[:-1]) / 1000
|
||||
#elif $size.endswith('M')
|
||||
#set disk_size = $int($size[:-1])
|
||||
#elif $size.endswith('G')
|
||||
#set disk_size = $int($size[:-1]) * 1000
|
||||
@ -270,6 +276,51 @@ echo "partition fstype \${partition_fstype}" >> /tmp/preseed.log
|
||||
reserve_disk_size_${disk_name}=${disk_size}
|
||||
#end for
|
||||
#end if
|
||||
#if $default_disk_reserve_size.endswith('K')
|
||||
#set disk_size = $int($default_disk_reserve_size[:-1]) / 1000
|
||||
#elif $default_disk_reserve_size.endswith('M')
|
||||
#set disk_size = $int($default_disk_reserve_size[:-1])
|
||||
#elif $default_disk_reserve_size.endswith('G')
|
||||
#set disk_size = $int($default_disk_reserve_size[:-1]) * 1000
|
||||
#elif $default_disk_reserve_size.endswith('T')
|
||||
#set disk_size = $int($default_disk_reserve_size[:-1]) * 1000000
|
||||
#else
|
||||
#set disk_size = $int($default_disk_reserve_size)
|
||||
#end if
|
||||
default_reserve_disk_size=${disk_size}
|
||||
|
||||
#if $disk_max_size != None
|
||||
#set disk_sizes = [disk_size.strip() for disk_size in $disk_max_size.split(';') if disk_size.strip()]
|
||||
#for disk_and_size in $disk_sizes
|
||||
#set disk_name, size = $disk_and_size.split(' ', 1)
|
||||
#set disk_name = $disk_name.strip()
|
||||
#if $size.endswith('K')
|
||||
#set disk_size = $int($size[:-1]) / 1000
|
||||
#elif $size.endswith('M')
|
||||
#set disk_size = $int($size[:-1])
|
||||
#elif $size.endswith('G')
|
||||
#set disk_size = $int($size[:-1]) * 1000
|
||||
#elif $size.endswith('T')
|
||||
#set disk_size = $int($size[:-1]) * 1000000
|
||||
#else
|
||||
#set disk_size = $int($size)
|
||||
#end if
|
||||
max_disk_size_${disk_name}=${disk_size}
|
||||
#end for
|
||||
#end if
|
||||
|
||||
#if $default_disk_max_size.endswith('K')
|
||||
#set disk_size = $int($default_disk_max_size[:-1]) / 1000
|
||||
#elif $default_disk_max_size.endswith('M')
|
||||
#set disk_size = $int($default_disk_max_size[:-1])
|
||||
#elif $default_disk_max_size.endswith('G')
|
||||
#set disk_size = $int($default_disk_max_size[:-1]) * 1000
|
||||
#elif $default_disk_max_size.endswith('T')
|
||||
#set disk_size = $int($default_disk_max_size[:-1]) * 1000000
|
||||
#else
|
||||
#set disk_size = $int($default_disk_max_size)
|
||||
#end if
|
||||
default_max_disk_size=${disk_size}
|
||||
|
||||
partition_names=""
|
||||
default_partition_name=""
|
||||
@ -288,7 +339,7 @@ default_partition_name=""
|
||||
#set volname = ''
|
||||
# $vol is not starts with /
|
||||
#end if
|
||||
if [ -z \$partition_names ]; then
|
||||
if [ -z "\${partition_names}" ]; then
|
||||
partition_names="$volname"
|
||||
else
|
||||
partition_names="\$partition_names $volname"
|
||||
@ -378,13 +429,13 @@ partition_maxsize_$volname=${vol_max_size}
|
||||
#end for
|
||||
#end if
|
||||
|
||||
if [ -z \${default_partition_name} ]; then
|
||||
if [ -z "\${default_partition_name}" ]; then
|
||||
default_partition_name=root
|
||||
fi
|
||||
|
||||
default_partition_percentage=100
|
||||
for key in \${partition_names}; do
|
||||
if [ -z \$key ]; then
|
||||
if [ -z "\$key" ]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "\$key" == "\${default_partition_name}" ]]; then
|
||||
@ -394,7 +445,7 @@ for key in \${partition_names}; do
|
||||
continue
|
||||
fi
|
||||
eval "partition_percentage=\\${partition_percentage_\$key}"
|
||||
if [ ! -z \${partition_percentage} ]; then
|
||||
if [ ! -z "\${partition_percentage}" ]; then
|
||||
if [ \${default_partition_percentage} -gt \${partition_percentage} ]; then
|
||||
default_partition_percentage=\$((\${default_partition_percentage}-\${partition_percentage}))
|
||||
else
|
||||
@ -404,25 +455,25 @@ for key in \${partition_names}; do
|
||||
done
|
||||
eval "partition_percentage_\${default_partition_name}=\${default_partition_percentage}"
|
||||
|
||||
if [ -z \$partition_point_boot ]; then
|
||||
if [ -z "\${partition_point_boot}" ]; then
|
||||
partition_point_boot="/boot"
|
||||
if [ -z \$partition_names ]; then
|
||||
if [ -z "\${partition_names}" ]; then
|
||||
partition_names="boot"
|
||||
else
|
||||
partition_names="\${partition_names} boot"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z \$partition_size_boot ]; then
|
||||
if [ -z "\${partition_size_boot}" ]; then
|
||||
partition_size_boot=500
|
||||
fi
|
||||
|
||||
if [ -z \$partition_maxsize_boot ]; then
|
||||
if [ -z "\${partition_maxsize_boot}" ]; then
|
||||
partition_maxsize_boot=\$partition_size_boot
|
||||
fi
|
||||
|
||||
eval "first_disk=\\${disk_path_\${first_disk_name}}"
|
||||
if [ -z \${first_disk} ]; then
|
||||
if [ -z "\${first_disk}" ]; then
|
||||
first_disk=/dev/sda
|
||||
fi
|
||||
|
||||
@ -432,24 +483,24 @@ format{ } use_filesystem{ } filesystem{ \${partition_fstype} } \
|
||||
mountpoint{ /boot } device{ \${first_disk} } \
|
||||
"
|
||||
|
||||
if [ -z \$partition_point_swap ]; then
|
||||
if [ -z "\${partition_point_swap}" ]; then
|
||||
partition_point_swap="swap"
|
||||
if [ -z \$partition_names ]; then
|
||||
if [ -z "\${partition_names}" ]; then
|
||||
partition_names="swap"
|
||||
else
|
||||
partition_names="\${partition_names} swap"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z \$partition_size_swap ]; then
|
||||
if [ -z "\${partition_size_swap}" ]; then
|
||||
partition_size_swap=256
|
||||
fi
|
||||
|
||||
if [ -z \$partition_percentage_swap ]; then
|
||||
if [ -z "\${partition_percentage_swap}" ]; then
|
||||
partition_percentage_swap=200
|
||||
fi
|
||||
|
||||
if [ -z \$partition_maxsize_swap ]; then
|
||||
if [ -z "\${partition_maxsize_swap}" ]; then
|
||||
partition_maxsize_swap=10%
|
||||
fi
|
||||
|
||||
@ -458,9 +509,9 @@ partition_param_swap="linux-swap \
|
||||
device{ \${first_disk} } \
|
||||
"
|
||||
|
||||
if [ -z \$partition_point_root ]; then
|
||||
if [ -z "\${partition_point_root}" ]; then
|
||||
partition_point_root="/"
|
||||
if [ -z \$partition_names ]; then
|
||||
if [ -z "\${partition_names}" ]; then
|
||||
partition_names="root"
|
||||
else
|
||||
partition_names="\$partition_names root"
|
||||
@ -469,18 +520,18 @@ fi
|
||||
|
||||
recipe="boot-root ::"
|
||||
for key in \${partition_names}; do
|
||||
if [ -z \$key ]; then
|
||||
if [ -z "\$key" ]; then
|
||||
continue
|
||||
fi
|
||||
eval "partition=\\${partition_point_\$key}"
|
||||
echo "partition \$partition => \$key" >> /tmp/preseed.log
|
||||
eval "partition_percentage=\\${partition_percentage_\$key}"
|
||||
if [ -z \$partition_percentage ]; then
|
||||
if [ -z "\${partition_percentage}" ]; then
|
||||
partition_percentage=0
|
||||
fi
|
||||
echo "partition percentage \$partition => \${partition_percentage}" >> /tmp/preseed.log
|
||||
eval "partition_size=\\${partition_size_\$key}"
|
||||
if [ -z \$partition_size ]; then
|
||||
if [ -z "\${partition_size}" ]; then
|
||||
partition_size=1
|
||||
fi
|
||||
echo "partition size \$partition => \${partition_size}" >> /tmp/preseed.log
|
||||
@ -496,7 +547,7 @@ for key in \${partition_names}; do
|
||||
fi
|
||||
echo "partition maxsize \$partition => \${partition_maxsize}" >> /tmp/preseed.log
|
||||
eval "partition_param=\\${partition_param_\$key}"
|
||||
if [ -z \${partition_param} ]; then
|
||||
if [ -z "\${partition_param}" ]; then
|
||||
partition_param="\${partition_fstype} \
|
||||
\\$lvmok{ } method{ format } format{ } \
|
||||
use_filesystem{ } filesystem{ \${partition_fstype} } \
|
||||
@ -508,25 +559,41 @@ mountpoint{ \$partition }"
|
||||
done
|
||||
|
||||
for disk_name in \${sorted_disks}; do
|
||||
if [ -z \${disk_name} ]; then
|
||||
if [ -z "\${disk_name}" ]; then
|
||||
continue
|
||||
fi
|
||||
eval "disk=\\${disk_path_\${disk_name}}"
|
||||
if [ -z \$disk ]; then
|
||||
if [ -z "\$disk" ]; then
|
||||
continue
|
||||
fi
|
||||
disk_name=\$(basename \$disk)
|
||||
eval "reserve_disk_size=\\${reserve_disk_size_\${disk_name}}"
|
||||
if [ ! -z \${reserve_disk_size} ]; then
|
||||
if [ -z "\${reserve_disk_size}" ]; then
|
||||
reserve_disk_size=\${default_reserve_disk_size}
|
||||
fi
|
||||
echo "disk \${disk} reserve disk size \${reserve_disk_size}" >> /tmp/preseed.log
|
||||
if [ \${reserve_disk_size} -gt 0 ]; then
|
||||
reserve_disk_param="\${partition_fstype} \
|
||||
method{ format } format{ } use_filesystem{ } filesystem{ \${partition_fstype} } device{ \${disk} }"
|
||||
\\$primary{ } device{ \${disk} } \
|
||||
method{ format } format{ } label{ reserved_\${disk_name} } \
|
||||
use_filesystem{ } filesystem{ \${partition_fstype} }"
|
||||
recipe="\$recipe \${reserve_disk_size} \${reserve_disk_size} \${reserve_disk_size} \${reserve_disk_param} ."
|
||||
echo "reserve partition param \${disk_name} => \${reserve_disk_param}" >> /tmp/preseed.log
|
||||
fi
|
||||
eval "max_disk_size=\\${max_disk_size_\${disk_name}}"
|
||||
if [ -z "\${max_disk_size}" ]; then
|
||||
max_disk_size=\${default_max_disk_size}
|
||||
fi
|
||||
echo "disk \${disk} max disk size \${max_disk_size}" >> /tmp/preseed.log
|
||||
if [ \${max_disk_size} -gt 0 ]; then
|
||||
maxsize_param=\${max_disk_size}
|
||||
else
|
||||
maxsize_param=-1
|
||||
fi
|
||||
disk_param="\${partition_fstype} \
|
||||
\\$defaultignore{ } \\$primary{ } device{ \${disk} } \
|
||||
method{ lvm } vg_name{ $vgname }"
|
||||
recipe="\$recipe 512 512+100% -1 \${disk_param} ."
|
||||
recipe="\$recipe 512 512+100% \${maxsize_param} \${disk_param} ."
|
||||
echo "partition param \${disk_name} => \${disk_param}" >> /tmp/preseed.log
|
||||
done
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user