@@ -430,36 +430,50 @@ mountroot() {
430430 # Make sure the device has been created by udev before we try to mount
431431 udevadm settle
432432
433- # find the right partition
434- for partname in $partlist ; do
435- part=$( find /dev -name $partname | tail -1)
436- [ -z " $part " ] && continue
437- path=$( readlink -f $part )
438- [ -n " $path " ] && break
433+ # Check for LVM volume group in kernel cmdline and activate LVM
434+ vg=" "
435+ for x in $( cat /proc/cmdline) ; do
436+ case ${x} in
437+ halium_lvm_vg=* )
438+ vg=${x#* =}
439+ ;;
440+ esac
439441 done
440442
441- # On systems with A/B partition layout, current slot is provided via cmdline parameter.
442- ab_slot_suffix=$( grep -o ' androidboot\.slot_suffix=..' /proc/cmdline | tail -1 | cut -d " =" -f2)
443- if [ -z " $path " ] && [ ! -z " $ab_slot_suffix " ] ; then
444- tell_kmsg " Searching for A/B data partition on slot $ab_slot_suffix ."
443+ # Use partitions from LVM volume group if present
444+ if [ -n " $vg " ]; then
445+ # Check if the volume group actually exists
446+ if lvm vgs " $vg " > /dev/null 2>&1 ; then
447+ tell_kmsg " Volume group $vg found"
448+ else
449+ tell_kmsg " WARNING: Volume group $vg specified but not found"
450+ vg=" "
451+ fi
452+ fi
445453
454+ # First check if LVM volume group has userdata
455+ if [ -n " $vg " ] && [ -e " /dev/$vg /userdata" ]; then
456+ tell_kmsg " Using LVM userdata volume at /dev/$vg /userdata"
457+ path=" /dev/$vg /userdata"
458+ else
459+ # Find the right partition for userdata
446460 for partname in $partlist ; do
447- part=$( find /dev -name " $partname$ab_slot_suffix " | tail -1)
461+ part=$( find /dev -name $partname | tail -1)
448462 [ -z " $part " ] && continue
449463 path=$( readlink -f $part )
450464 [ -n " $path " ] && break
451465 done
452- fi
453466
454- # override with a possible cmdline parameter
455- if grep -q datapart= /proc/cmdline; then
456- for x in $( cat /proc/cmdline) ; do
457- case ${x} in
458- datapart=* )
459- path=${x#* =}
460- ;;
461- esac
462- done
467+ # Override with a possible cmdline parameter
468+ if grep -q datapart= /proc/cmdline; then
469+ for x in $( cat /proc/cmdline) ; do
470+ case ${x} in
471+ datapart=* )
472+ path=${x#* =}
473+ ;;
474+ esac
475+ done
476+ fi
463477 fi
464478
465479 if [ -z " $path " ]; then
@@ -517,6 +531,16 @@ mountroot() {
517531 fi
518532 fi
519533
534+ # Override systempart with LVM rootfs if volume group is provided
535+ if [ -n " $vg " ] && [ -e " /dev/$vg /rootfs" ]; then
536+ tell_kmsg " Overriding systempart with LVM rootfs at /dev/$vg /rootfs"
537+ _syspart=" /dev/$vg /rootfs"
538+ # Keep existing options if they were set, otherwise use rw
539+ if [ -z " $_syspart_options " ]; then
540+ _syspart_options=rw
541+ fi
542+ fi
543+
520544 # We need to add the slot suffix to $_syspart for A/B devices
521545 if [ -n " $_syspart " ] && [ ! -e " $_syspart " ] && [ ! -z " $ab_slot_suffix " ]; then
522546 tell_kmsg " A/B slot system detected! Slot suffix is $ab_slot_suffix "
0 commit comments