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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#!/bin/sh
# Apply LVM partitioning on top of a RAID preseed
if ! [ -f /var/lib/partman/initial_auto_raid_pvs ] ||
! [ -e /lib/partman/lib/auto-lvm.sh ]; then
exit 0
fi
. /lib/partman/lib/auto-lvm.sh
# pv_devices is used by auto_lvm_perform()
pv_devices="$(cat /var/lib/partman/initial_auto_raid_pvs)"
rm -f /var/lib/partman/initial_auto_raid_pvs
db_get partman-auto/expert_recipe_file
recipe="$RET"
# Clone-and-hack from partman-auto-lvm, which can't cope with the idea of
# not needing to create partitions for itself yet.
size=0
devs=
for pv_device in $pv_devices; do
dev="$(dev_to_partman $pv_device)"
devs="${devs:+$devs }$dev"
[ -f $dev/size ] || exit 1
size=$(($size + $(cat $dev/size)))
done
set -- $devs
main_device=$1
shift
extra_devices="$*"
# Be sure the modules are loaded
modprobe dm-mod >/dev/null 2>&1 || true
modprobe lvm-mod >/dev/null 2>&1 || true
if type update-dev >/dev/null 2>&1; then
log-output -t update-dev update-dev --settle
fi
if [ "$extra_devices" ]; then
for dev in $devs; do
physdev="$(cat "$dev/device")"
target="${target:+$target }${physdev#/dev/}"
done
db_metaget partman-auto-lvm/text/multiple_disks description
target=$(printf "$RET" "$target")
else
target="$(humandev $(cat $main_device/device)) - $(cat $main_device/model)"
fi
target="$target: $(longint2human $size)"
free_size=$(convert_to_megabytes $size)
choose_recipe lvm "$target" "$free_size" || return $?
# Make sure the recipe contains lvmok tags
if ! echo "$scheme" | grep -q lvmok; then
bail_out unusable_recipe
fi
# Make sure a boot partition isn't marked as lvmok
if echo "$scheme" | grep lvmok | grep -q "[[:space:]]/boot[[:space:]]"; then
bail_out unusable_recipe
fi
expand_scheme
# Extract the mapping of which VG goes onto which PV
auto_lvm_create_vg_map
auto_lvm_perform
|