[Merge] lp:~w-ondra/ubuntu/vivid/initramfs-tools-ubuntu-touch/fstab into lp:ubuntu/initramfs-tools-ubuntu-touch

Ricardo Salveti rsalveti at rsalveti.net
Tue Mar 31 04:50:50 UTC 2015


Review: Needs Fixing

Yes, this needs to be separated into 3 different MRs:
1 - Boot mode selection
2 - Extra/custom scripts support
3 - Support for another device partition (devicemount).

And I agree with ogra here that for 3, this is not really required. Adding fstab would help by not having to add the boot cmdline arguments in bootloader/kernel/aboot-format, but at the cost of having to always repack the initrd or support 2 different code paths for the same thing.

We really don't expect us to support yet another partition, so it's more than fine to use the kernel cmd line to track that now.

If all you need, in order to drop the current arale customizations, is supporting a new partition configuration, we can make this MR to simply add parsing/mounting support for "devicemount".

And to be clear with what we discussed on IRC:
<rsalveti> right, it's still unclear to me why we need support for fstab in there, but sure
<rsalveti> we can discuss in the mr

With the MR we could finally understand that the only thing we need is a new cmdline option (that will later be removed). There is no real need for fstab here.

Diff comments:

> === modified file 'scripts/touch'
> --- scripts/touch	2015-03-20 02:30:21 +0000
> +++ scripts/touch	2015-03-27 08:27:52 +0000
> @@ -28,6 +28,9 @@
>  		esac
>  	fi
>  
> +	# Check if there is custom boot reason identification
> +	type custom_identify_boot_mode &>/dev/null && custom_identify_boot_mode

Can this be separated in another MR?

> +
>  	echo "initrd: boot mode: $BOOT_MODE" >/dev/kmsg || true
>  }
>  
> @@ -92,6 +95,7 @@
>  		echo $1 | egrep -q "^#" && continue
>  		([ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]) && continue
>  		([ "$2" = "/system" ] || [ "$2" = "/data" ]) && continue
> +		([ "$2" = "/" ] || [ "$2" = "/userdata" ] || [ "$2" = "/android/system" ]) && continue
>  
>  		label=$(echo $1 | awk -F/ '{print $NF}')
>  		[ -z "$label" ] && continue
> @@ -99,7 +103,9 @@
>  		echo "initrd: checking mount label $label" >/dev/kmsg || true
>  
>  		# In case fstab provides /dev/mmcblk0p* lines
> +		# some kernels create sym links to root for mount devices, which migh use /dev/blocl/mmcblk0p*		
>  		path="/dev/$label"
> +		[ -n "$(readlink $1)" ] && path="/dev/$(readlink $1 | awk -F/ '{print $NF}')"
>  		for dir in by-partlabel by-name by-label by-path by-uuid by-partuuid by-id; do
>  			if [ -e "/dev/disk/$dir/$label" ]; then
>  				path="/dev/disk/$dir/$label"
> @@ -162,6 +168,11 @@
>  
>  mountroot()
>  {
> +	if [ -f /scripts/touch-custom ]; then
> +		echo "initrd: Sourcing custom touch script" >/dev/kmsg || true
> +		. /scripts/touch-custom
> +	fi

Can this be separated in another MR?

> +
>  	# list of possible userdata partition names
>  	partlist="userdata UDA DATAFS USERDATA"
>  
> @@ -198,11 +209,17 @@
>  		done
>  	fi
>  
> +	# if we have fstbat check for userdata device mount
> +	[ -f /fstab ] && path=$(grep -F -w '/userdata' /fstab | awk '{print $1}')
> +
>  	if [ -z "$path" ]; then
>  		echo "initrd: Couldn't find data partition. Spawning adbd ..." >/dev/kmsg || true
>  		panic "Couldn't find data partition. Spawning adbd ..."
>  	fi
>  
> +	# Device specific pre mount check.
> +	type custom_prepare_for_mount &>/dev/null && custom_prepare_for_mount
> +
>  	echo "initrd: checking filesystem integrity for the userdata partition" >/dev/kmsg || true
>  	# Mounting and umounting first, let the kernel handle the journal and
>  	# orphaned inodes (faster than e2fsck). Then, just run e2fsck forcing -y.
> @@ -230,10 +247,17 @@
>  		done
>  	fi
>  
> +	# if we have /fstab check for syspart there
> +	[ -f /fstab ] && syspart=$(grep -F -w '/' /fstab | awk '{print $1}')
> +
>  	identify_boot_mode
>  
> +	# Check if we need to handle some special boot case
> +	if [ -n "$syspart" ] && [ "$BOOT_MODE" != "ubuntu" -a "$BOOT_MODE" != "android" ]; then
> +		echo "initrd: Booting to custom $BOOT_MODE mode." >/dev/kmsg || true
> +		type boot_$BOOT_MODE &>/dev/null && boot_$BOOT_MODE
>  	# Only care about factory mode when using a real partition
> -	if [ -n "$syspart" ] && [ "$BOOT_MODE" = "android" ]; then
> +	elif [ -n "$syspart" ] && [ "$BOOT_MODE" = "android" ]; then

Can this be separated in another MR?

>  		# Factory mode, just boot directly into the android rootfs
>  		mkdir -p /ubuntu-system
>  		mkdir -p /android-rootfs
> @@ -242,9 +266,19 @@
>  		echo "initrd: mounting ubuntu system partition" >/dev/kmsg || true
>  		mount -o rw $syspart /ubuntu-system
>  		mount -o remount,ro /ubuntu-system
> +		if [ -f /fstab ]; then
> +			mount_android_partitions /fstab /ubuntu-system
> +			[ -n "$(grep -F -w '/custom' /fstab)" ] && mount -o remount,ro /ubuntu-system/custom
> +		fi
>  
>  		echo "initrd: mounting android system image" >/dev/kmsg || true
> -		mount -o loop,ro /ubuntu-system/var/lib/lxc/android/system.img /android-system
> +		if [ -f /fstab ]; then
> +			devicemount=$(grep -F -w '/android/system' /fstab | awk '{print $1}')
> +			mount -o rw $devicemount /android-system
> +			mount -o remount,ro /android-system
> +		else	
> +			mount -o loop,ro /ubuntu-system/var/lib/lxc/android/system.img /android-system
> +		fi
>  
>  		echo "initrd: extracting android ramdisk" >/dev/kmsg || true
>  		OLD_CWD=$(pwd)
> @@ -295,22 +329,37 @@
>  			mount -o loop,rw /tmpmnt/system.img ${rootmnt}
>  		fi
>  		if [ -e /tmpmnt/.writable_image ]; then
> -			echo "initrd: mounting system.img (image developer mode)" >/dev/kmsg || true
> +			echo "initrd: mounting system (image developer mode)" >/dev/kmsg || true
>  			mountroot_status="$?"
>  		else
> -			echo "initrd: mounting system.img (user mode)" >/dev/kmsg || true
> +			echo "initrd: mounting system (user mode)" >/dev/kmsg || true
>  			mount -o remount,ro ${rootmnt}
>  			mountroot_status="$?"
>  		fi
>  		mount --move /tmpmnt ${rootmnt}/userdata
>  
> +		# parse and mount what is left in initrd fstab
> +		if [ -f /fstab ]; then
> +			mount_android_partitions /fstab ${rootmnt}
> +			if [ ! -e ${rootmnt}/userdata/.writable_image -a -n "$(grep -F -w "/custom" /fstab)" ]; then
> +				echo "initrd: mounting /custom (user mode)" >/dev/kmsg || true
> +				mount -o remount,ro ${rootmnt}/custom
> +			fi
> +		fi
> +
>  		# Set ubuntu version properties
>  		mkdir -p ${rootmnt}/userdata/android-data
>  		set_ubuntu_version_properties ${rootmnt} ${rootmnt}/userdata/android-data
>  
>  		# Mount the android system partition to a temporary location
>  		mkdir -p /android-system
> -		mount -o loop,ro ${rootmnt}/var/lib/lxc/android/system.img /android-system
> +		if [ -f /fstab ]; then
> +			devicemount=$(grep -F -w '/android/system' /fstab | awk '{print $1}')
> +			mount -o rw $devicemount /android-system
> +			[ ! -e ${rootmnt}/userdata/.writable_image ] && mount -o remount,ro /android-system
> +		else
> +			mount -o loop,ro ${rootmnt}/var/lib/lxc/android/system.img /android-system
> +		fi
>  
>  		# Get device information
>  		device=$(grep ^ro.product.device= /android-system/build.prop |sed -e 's/.*=//')
> @@ -408,7 +457,7 @@
>  		mount_android_partitions "${rootmnt}/var/lib/lxc/android/rootfs/fstab*" ${rootmnt}/android
>  
>  		# system is a special case
> -		echo "initrd: mounting ${rootmnt}/var/lib/lxc/android/system.img as ${rootmnt}/android/system" >/dev/kmsg || true
> +		echo "initrd: moving mount /android-system to ${rootmnt}/android/system" >/dev/kmsg || true
>  		mount --move /android-system ${rootmnt}/android/system
>  
>  		# Ubuntu overlay available in the Android system image (hardware specific configs)
> 


-- 
https://code.launchpad.net/~w-ondra/ubuntu/vivid/initramfs-tools-ubuntu-touch/fstab/+merge/254366
Your team Ubuntu branches is subscribed to branch lp:ubuntu/initramfs-tools-ubuntu-touch.



More information about the Ubuntu-reviews mailing list