Merge ~xnox/initramfs-tools-ubuntu-core/+git/initramfs-tools-devices:master into ~ubuntu-core-dev/initramfs-tools-ubuntu-core/+git/initramfs-tools-devices:master

Proposed by Dimitri John Ledkov on 2019-05-17
Status: Merged
Merged at revision: 736973766606c12510909cf2ca1eec1e5aa52c7b
Proposed branch: ~xnox/initramfs-tools-ubuntu-core/+git/initramfs-tools-devices:master
Merge into: ~ubuntu-core-dev/initramfs-tools-ubuntu-core/+git/initramfs-tools-devices:master
Diff against target: 184 lines (+14/-105)
5 files modified
debian/changelog (+7/-0)
debian/control (+1/-1)
dev/null (+0/-32)
hooks/resize (+2/-2)
scripts/local-premount/resize (+4/-70)
Reviewer Review Type Date Requested Status
Snappy Developers 2019-05-17 Pending
Ubuntu Core Development Team 2019-05-17 Pending
Review via email: mp+367599@code.launchpad.net

Commit message

Port to sfdisk, to safe 1.2M uncompressed space due to dropping libstdc++ from the initramfs.

Also, I'm not sure this should exists at all in favor of using systemd.mount fstab x-systemd.growfs option or by starting a <email address hidden>

To post a comment you must log in.
Steve Langasek (vorlon) :
Dimitri John Ledkov (xnox) :
Steve Langasek (vorlon) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index ca22009..edbba33 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+initramfs-tools-devices (0.4) eoan; urgency=medium
7+
8+ * Port from parted/sgdisk to sfdisk. Also I'm not sure this should at
9+ all exist, in favor of using systemd's .mount unit expand option.
10+
11+ -- Dimitri John Ledkov <xnox@ubuntu.com> Fri, 17 May 2019 18:22:41 +0100
12+
13 initramfs-tools-devices (0.3) disco; urgency=medium
14
15 * Add some missing binaries to the initramfs
16diff --git a/debian/control b/debian/control
17index 6ace4db..76516b9 100644
18--- a/debian/control
19+++ b/debian/control
20@@ -7,7 +7,7 @@ Standards-Version: 4.1.4
21
22 Package: initramfs-tools-devices
23 Architecture: all
24-Depends: initramfs-tools, ${misc:Depends}, parted, gdisk
25+Depends: initramfs-tools, ${misc:Depends}
26 Description: Common initramfs scripts for Ubuntu Core and Classic
27 This package contains initramfs scripts that can be useful for both
28 Ubuntu Core and Classic systems, like the resize script, which resizes
29diff --git a/hooks/resize b/hooks/resize
30index 885aa52..b8a6744 100755
31--- a/hooks/resize
32+++ b/hooks/resize
33@@ -21,9 +21,9 @@ esac
34
35 copy_exec /sbin/e2fsck /sbin
36 copy_exec /sbin/findfs /sbin
37-copy_exec /sbin/parted /sbin
38-copy_exec /sbin/sgdisk /sbin
39+copy_exec /sbin/sfdisk /sbin
40 copy_exec /sbin/resize2fs /sbin
41 copy_exec /sbin/blockdev /sbin
42+# possibly build the below into busybox
43 copy_exec /usr/bin/realpath
44 copy_exec /usr/bin/dirname
45diff --git a/resize.patch b/resize.patch
46deleted file mode 100644
47index 6e26d5a..0000000
48--- a/resize.patch
49+++ /dev/null
50@@ -1,32 +0,0 @@
51---- resize 2018-08-15 09:42:40.000000000 +0100
52-+++ resize-new 2018-08-15 08:41:22.647748986 +0100
53-@@ -38,7 +38,6 @@
54- device_size="$(($(cat "$syspath"/size)/2))"
55- sum_size="$(($(grep "$(basename "$device")[a-z0-9]" /proc/partitions|\
56- tr -s ' '|cut -d' ' -f4|tr '\n' '+'|sed 's/+$//')))"
57--w_size="$(dumpe2fs -h "$writable_part" 2>&1 | awk -F: '/Block count/{count=$2} /Block size/{size=$2} END{print count*size/1024}')"
58-
59- get_end()
60- {
61-@@ -92,7 +91,6 @@
62-
63- free_space=$((device_size-sum_size))
64- min_free_space=$((device_size/10))
65--free_w_space=$((device_size-w_size))
66-
67- # this should never be empty, else argument checking of resize2fs
68- # will recognize it as empty string (due to the quoting of the arg below) and fail
69-@@ -125,13 +123,5 @@
70- # check the filesystem before attempting re-size
71- e2fsck -fy "$writable_part" >>$LOGFILE 2>&1
72- # resize the filesystem to full size of the partition
73-- resize2fs "$resizeopts" "$writable_part" >>$LOGFILE 2>&1
74--
75--# check if we need to resize ext4 file system only
76--elif [ "$min_free_space" -lt "$free_w_space" ]; then
77-- echo "resizing fs in ${writable_part} part" >>$LOGFILE 2>&1
78-- # check the filesystem before attempting re-size
79-- e2fsck -fy "$writable_part" >>$LOGFILE 2>&1
80-- # resize the filesystem to full size of the partition
81- resize2fs "$resizeopts" "$writable_part" >>$LOGFILE 2>&1
82- fi
83diff --git a/scripts/local-premount/resize b/scripts/local-premount/resize
84index 5aabb7f..7ce2759 100755
85--- a/scripts/local-premount/resize
86+++ b/scripts/local-premount/resize
87@@ -16,7 +16,6 @@ case "$1" in
88 ;;
89 esac
90
91-TMPFILE="/run/initramfs/old-table.txt"
92 LOGFILE="/run/initramfs/resize-writable.log"
93
94 wait-for-root "LABEL=writable" "${ROOTDELAY:-180}" >/dev/null || true
95@@ -39,56 +38,6 @@ device_size="$(($(cat $syspath/size)/2))"
96 sum_size="$(($(grep $(basename $device)[a-z0-9] /proc/partitions|\
97 tr -s ' '|cut -d' ' -f4|tr '\n' '+'|sed 's/+$//')))"
98
99-get_end()
100-{
101- NUM=$1
102- lastpart="$(grep -cE ^'[0-9]{1,}': $TMPFILE)"
103- if [ "$lastpart" = "$NUM" ]; then
104- endsize="$(parted -ms $DEV print| grep ^/ | cut -d: -f2)"
105- else
106- # we are not at the end ! get the start of the next partition
107- # (minus 1 byte) instead of using the absolute end of the disk
108- endsize=$(($(parted -ms $DEV unit B print|grep ^$(($num+1)):|\
109- cut -d: -f2|sed 's/B$//')-1))
110- fi
111- echo "$endsize"
112-}
113-
114-do_gpt()
115-{
116- DISK=$1
117-
118- PARTNUM="$(sgdisk -p $DISK|grep writable|sed -r 's/^([^ ]*[ ]*){1}([^ ]*).*/\2/')"
119- GUID="$(sgdisk -i $PARTNUM $DISK|grep unique| sed 's/^.*: //g')"
120- FIRST="$(sgdisk -i $PARTNUM $DISK|grep ^First| sed 's/^.*: //g;s/ .*$//')"
121-
122- echo "fixing backup GPT" >>$LOGFILE 2>&1
123- sgdisk --move-second-header $DISK >>$LOGFILE 2>&1
124-
125- echo "Deleting partition $PARTNUM" >>$LOGFILE 2>&1
126- sgdisk -d $PARTNUM $DISK >>$LOGFILE 2>&1
127-
128- echo "Creating partition $PARTNUM at $FIRST" >>$LOGFILE 2>&1
129- sgdisk -n $PARTNUM:$FIRST:0 $DISK >>$LOGFILE 2>&1
130-
131- echo "Setting GUID of partition $PARTNUM to $GUID" >>$LOGFILE 2>&1
132- sgdisk -u $PARTNUM:$GUID $DISK >>$LOGFILE 2>&1
133-
134- echo "Setting name of $PARTNUM to writable" >>$LOGFILE 2>&1
135- sgdisk -c $PARTNUM:writable $DISK >>$LOGFILE 2>&1
136-
137- sgdisk -p $DISK >/run/initramfs/new-gpt-table.txt 2>/dev/null
138-}
139-
140-do_mbr()
141-{
142- DEV=$1
143- PART=$2
144- endsize=$(get_end $PART)
145- parted -s $DEV resizepart $PART $endsize
146-}
147-
148-
149 free_space=$(($device_size-$sum_size))
150 min_free_space=$(($device_size/10))
151
152@@ -96,28 +45,13 @@ if [ "$min_free_space" -lt "$free_space" ]; then
153 echo "initrd: found more than 10% free space on disk, resizing ${writable_part}" >/dev/kmsg || true
154 echo "initrd: partition to full disk size, see ${LOGFILE} for details" >/dev/kmsg || true
155 # back up the original partition table for later use or debugging
156- parted -ms $device unit B print >$TMPFILE 2>/dev/null
157- # grow our selected partition to max space available
158- table="$(parted -ms $device print| grep ^/| cut -d: -f6)"
159- case $table in
160- gpt)
161- # do_gpt needs the device name
162- do_gpt $device >>$LOGFILE 2>&1
163- ;;
164- mbr|msdos)
165- # do_mbr needs the device node and partition number
166- do_mbr $device $partition >>$LOGFILE 2>&1
167- resizeopts="-f"
168- ;;
169- *)
170- echo "unknown partition table type, not resizing" >>$LOGFILE
171- exit 0
172- ;;
173- esac
174+ sfdisk -d $device >>$LOGFILE 2>&1
175+ echo ',+' | sfdisk -N $partition $device >>$LOGFILE 2>&1
176+ blockdev -v --rereadpt >>$LOGFILE 2>&1
177 # make sure the partitions are ready for further use
178 udevadm settle >>$LOGFILE 2>&1
179 # check the filesystem before attempting re-size
180 e2fsck -fy $writable_part >>$LOGFILE 2>&1
181 # resize the filesystem to full size of the partition
182- resize2fs $resizeopts $writable_part >>$LOGFILE 2>&1
183+ resize2fs -fp $writable_part >>$LOGFILE 2>&1
184 fi

Subscribers

People subscribed via source and target branches