aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/cobbler/snippets/kickstart_post_partition_disks
blob: ded9e9612d20202d29704104126a6b5e762e1ca0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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} --script -- rm \${partition_number}
done