File: ext2_or_ext3_boot

package info (click to toggle)
partman-ext3 119
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 884 kB
  • sloc: sh: 555; makefile: 2
file content (118 lines) | stat: -rwxr-xr-x 3,137 bytes parent folder | download | duplicates (7)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/sh
# Check that the boot partition is the 1st (primary) partition, that
# it is of type ext2 or ext3, and that it is marked as bootable.

ARCH="$(archdetect)"

case $ARCH in
    arm*)
	machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//') || true
	case "$machine" in
	    "Buffalo Linkstation Pro/Live" | "Buffalo/Revogear Kurobox Pro" \
		    | "Buffalo Linkstation Mini")
		;;
	    "GLAN Tank")
		;;
	    "HP Media Vault mv2120")
		;;
	    *)
		exit 0
		;;
	esac
	;;
    mipsel/loongson-2f)
	;;
    *)
	exit 0
	;;
esac

. /lib/partman/lib/base.sh

for dev in $DEVICES/*; do
	[ -d "$dev" ] || continue
	cd $dev
	open_dialog PARTITIONS
	while { read_line num id size type fs path name; [ "$id" ]; }; do
		[ "$fs" != free ] || continue
		[ -f $id/method ] || continue
		[ -f $id/acting_filesystem ] || continue
		[ -f $id/mountpoint ] || continue
		mountpoint=$(cat $id/mountpoint)
		filesystem=$(cat $id/acting_filesystem)
		if [ "$mountpoint" = / ]; then
			root_fs=$filesystem
			root_type=$type
			root_path=$path
			if [ -f $id/bootable ]; then
				root_bootable=yes
			fi
		elif [ "$mountpoint" = /boot ]; then
			boot_fs=$filesystem
			boot_type=$type
			boot_path=$path
			if [ -f $id/bootable ]; then
				boot_bootable=yes
			fi
		fi
	done
	close_dialog
done

# If no separate boot partition exists root acts as boot
if [ -z "$boot_path" ]; then
	boot_fs=$root_fs
	boot_type=$root_type
	boot_path=$root_path
	boot_bootable=$root_bootable
fi

# We need an ext2 or ext3 filesystem to boot
if [ "$boot_fs" != ext2 ] && [ "$boot_fs" != ext3 ]; then
	db_set partman-ext3/boot_not_ext2_or_ext3 true
	db_input critical partman-ext3/boot_not_ext2_or_ext3 || true
	db_go || true
	db_get partman-ext3/boot_not_ext2_or_ext3
	if [ "$RET" = true ]; then
		exit 1
	fi
fi

# The boot file system has to be the first primary partition

# ... but for now don't run the check if /boot is on RAID1.  Right now,
# there's no good way to map a RAID device to its physical partition
# and then run the checks on that partition (see #509799).
if echo $boot_path | grep -q "^/dev/md"; then
	raid=${boot_path#/dev/}
	if grep "^$raid" /proc/mdstat | grep -q " raid1 "; then
		exit 0
	fi
fi

part_num=$(echo "$boot_path" | sed -e 's/.*[^0-9]\+//')
if [ "$boot_type" != primary ] || [ "$part_num" -ne 1 ]; then
	db_set partman/boot_not_first_partition true
	db_input critical partman/boot_not_first_partition || true
	db_go || true
	db_get partman/boot_not_first_partition
	if [ "$RET" = true ]; then
		exit 1
	fi
fi

# Make sure that the boot partition is marked as bootable
## Note: this won't work for RAID because the physical partition must be
## marked bootable whereas we're checking the /boot partition (i.e. the
## md partition on top of the physical partition).  However, there's
## some code above that exists this script when /boot is on RAID1.
if [ "$ARCH" != mipsel/loongson-2f ] && [ "$boot_bootable" != "yes" ]; then
	db_set partman-ext3/boot_not_bootable true
	db_input critical partman-ext3/boot_not_bootable || true
	db_go || true
	db_get partman-ext3/boot_not_bootable
	if [ "$RET" = true ]; then
		exit 1
	fi
fi