diff --git a/build-initrd.sh b/build-initrd.sh index 64a9d5e..778f41a 100755 --- a/build-initrd.sh +++ b/build-initrd.sh @@ -47,7 +47,7 @@ done [ -z $OUT ] && OUT=./out # list all packages needed for halium's initrd here -[ -z $INCHROOTPKGS ] && INCHROOTPKGS="initramfs-tools dctrl-tools dmsetup e2fsprogs libc6-dev zlib1g-dev libssl-dev busybox-static parse-android-dynparts" +[ -z $INCHROOTPKGS ] && INCHROOTPKGS="initramfs-tools dctrl-tools dmsetup e2fsprogs libc6-dev lvm2 zlib1g-dev libssl-dev busybox-static parse-android-dynparts" BOOTSTRAP_BIN="qemu-debootstrap --arch $ARCH --variant=minbase" diff --git a/debian/control b/debian/control index 1c6df61..63b61cd 100644 --- a/debian/control +++ b/debian/control @@ -13,6 +13,7 @@ Depends: initramfs-tools, coreutils, busybox-static, e2fsprogs, + lvm2, ${misc:Depends} Description: tools for mounting an Ubuntu Touch rootfs This package contains the scripts to boot an Ubuntu Touch device. diff --git a/debian/initramfs-tools-halium.postinst b/debian/initramfs-tools-halium.postinst index a3ea989..cc331ed 100644 --- a/debian/initramfs-tools-halium.postinst +++ b/debian/initramfs-tools-halium.postinst @@ -5,7 +5,7 @@ set -e apply_diversions() { DIR=/usr/share/initramfs-tools SUBDIRS="hooks scripts/local-premount scripts/init-top scripts/init-bottom scripts/panic" - FILES="compcache fixrtc dmsetup plymouth console_setup kbd thermal" + FILES="compcache fixrtc plymouth console_setup kbd thermal" for file in $FILES; do for subdir in $SUBDIRS; do diff --git a/hooks/halium b/hooks/halium index 6b5c68b..f43eb6a 100755 --- a/hooks/halium +++ b/hooks/halium @@ -1,7 +1,7 @@ #!/bin/sh -e MINKVER="2.6.24" -PREREQ="" +PREREQ="lvm2" DEB_HOST_MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH) # Output pre-requisites @@ -26,6 +26,7 @@ copy_exec /bin/chown /bin copy_exec /bin/mount /bin copy_exec /sbin/dmsetup /sbin copy_exec /sbin/dumpe2fs /sbin +copy_exec /sbin/lvm /sbin copy_exec /lib/$DEB_HOST_MULTIARCH/libz.so.1 copy_exec /usr/lib/$DEB_HOST_MULTIARCH/libcrypto.so copy_exec /usr/lib/$DEB_HOST_MULTIARCH/libdl.so diff --git a/scripts/halium b/scripts/halium index 5f0dc07..bb7afed 100644 --- a/scripts/halium +++ b/scripts/halium @@ -430,36 +430,50 @@ mountroot() { # Make sure the device has been created by udev before we try to mount udevadm settle - # find the right partition - for partname in $partlist; do - part=$(find /dev -name $partname | tail -1) - [ -z "$part" ] && continue - path=$(readlink -f $part) - [ -n "$path" ] && break + # Check for LVM volume group in kernel cmdline and activate LVM + vg="" + for x in $(cat /proc/cmdline); do + case ${x} in + halium_lvm_vg=*) + vg=${x#*=} + ;; + esac done - # On systems with A/B partition layout, current slot is provided via cmdline parameter. - ab_slot_suffix=$(grep -o 'androidboot\.slot_suffix=..' /proc/cmdline | tail -1 | cut -d "=" -f2) - if [ -z "$path" ] && [ ! -z "$ab_slot_suffix" ] ; then - tell_kmsg "Searching for A/B data partition on slot $ab_slot_suffix." + # Use partitions from LVM volume group if present + if [ -n "$vg" ]; then + # Check if the volume group actually exists + if lvm vgs "$vg" >/dev/null 2>&1; then + tell_kmsg "Volume group $vg found" + else + tell_kmsg "WARNING: Volume group $vg specified but not found" + vg="" + fi + fi + # First check if LVM volume group has userdata + if [ -n "$vg" ] && [ -e "/dev/$vg/userdata" ]; then + tell_kmsg "Using LVM userdata volume at /dev/$vg/userdata" + path="/dev/$vg/userdata" + else + # Find the right partition for userdata for partname in $partlist; do - part=$(find /dev -name "$partname$ab_slot_suffix" | tail -1) + part=$(find /dev -name $partname | tail -1) [ -z "$part" ] && continue path=$(readlink -f $part) [ -n "$path" ] && break done - fi - # override with a possible cmdline parameter - if grep -q datapart= /proc/cmdline; then - for x in $(cat /proc/cmdline); do - case ${x} in - datapart=*) - path=${x#*=} - ;; - esac - done + # Override with a possible cmdline parameter + if grep -q datapart= /proc/cmdline; then + for x in $(cat /proc/cmdline); do + case ${x} in + datapart=*) + path=${x#*=} + ;; + esac + done + fi fi if [ -z "$path" ]; then @@ -517,6 +531,16 @@ mountroot() { fi fi + # Override systempart with LVM rootfs if volume group is provided + if [ -n "$vg" ] && [ -e "/dev/$vg/rootfs" ]; then + tell_kmsg "Overriding systempart with LVM rootfs at /dev/$vg/rootfs" + _syspart="/dev/$vg/rootfs" + # Keep existing options if they were set, otherwise use rw + if [ -z "$_syspart_options" ]; then + _syspart_options=rw + fi + fi + # We need to add the slot suffix to $_syspart for A/B devices if [ -n "$_syspart" ] && [ ! -e "$_syspart" ] && [ ! -z "$ab_slot_suffix" ]; then tell_kmsg "A/B slot system detected! Slot suffix is $ab_slot_suffix"