#!/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, unless the user # has told us it is ok for /boot to reside on a logical volume if echo "$scheme" | grep lvmok | grep -q "[[:space:]]/boot[[:space:]]"; then db_input critical partman-auto-lvm/no_boot || true db_go || return 255 db_get partman-auto-lvm/no_boot || true [ "$RET" = true ] || 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