Ubuntu Pastebin

Paste from rsalveti at Fri, 20 Mar 2015 02:56:11 +0000

Download as text
 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
#!/bin/bash
#
mount_android_partitions() {
	fstab=$1
	mount_root=$2

	echo "initrd: checking fstab $fstab for additional mount points" || true

	cat ${fstab} | while read line; do
		set -- $line

		# Skip any unwanted entry
		echo $1 | egrep -q "^#" && continue
		([ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]) && continue
		([ "$2" = "/system" ] || [ "$2" = "/data" ]) && continue

		label=$(echo $1 | awk -F/ '{print $NF}')
		[ -z "$label" ] && continue

		echo "initrd: checking mount label $label" || true

		# In case fstab provides /dev/mmcblk0p* lines
		path="/dev/$label"
		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"
				break
			fi
		done

		# MTD based devices, such as the emulator
		if [ ! -e "$path" ] && echo $label | egrep -q "^mtdblock"; then
			path="/dev/$label"
		fi

		[ ! -e "$path" ] && continue

		mkdir -p ${mount_root}/$2
		echo "initrd: mounting $path as ${mount_root}/$2" || true
		mount $path ${mount_root}/$2 -t $3 -o $4
	done
}

mount_android_partitions /var/lib/lxc/android/rootfs/fstab* /android
Download as text