Merge lp:~jani/ubuntu/vivid/initramfs-tools-ubuntu-touch/resize-userdata into lp:ubuntu/vivid/initramfs-tools-ubuntu-touch

Proposed by Jani Monoses
Status: Approved
Approved by: Oliver Grawert
Approved revision: 95
Proposed branch: lp:~jani/ubuntu/vivid/initramfs-tools-ubuntu-touch/resize-userdata
Merge into: lp:ubuntu/vivid/initramfs-tools-ubuntu-touch
Diff against target: 51 lines (+23/-0)
2 files modified
hooks/touch (+1/-0)
scripts/touch (+22/-0)
To merge this branch: bzr merge lp:~jani/ubuntu/vivid/initramfs-tools-ubuntu-touch/resize-userdata
Reviewer Review Type Date Requested Status
Oliver Grawert Approve
Review via email: mp+257326@code.launchpad.net

Commit message

Resize userdata filesystem if it does not fill the whole userdata partition.

Description of the change

Resize userdata filesystem if it does not fill the whole userdata partition.

To post a comment you must log in.
Revision history for this message
Oliver Grawert (ogra) wrote :
review: Approve
Revision history for this message
Oliver Grawert (ogra) wrote :

eeek, totally missed that there is more code in this one ... not merged yet indeed ....

Unmerged revisions

95. By Jani Monoses

Resize userdata filesystem on firs boot.

94. By Jani Monoses

Add /sbin/resize2fs to support resizing of userdata on first boot.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/touch'
2--- hooks/touch 2015-03-26 17:36:51 +0000
3+++ hooks/touch 2015-04-24 07:10:38 +0000
4@@ -21,6 +21,7 @@
5 copy_exec /sbin/swapon /sbin
6 copy_exec /sbin/reboot /sbin
7 copy_exec /sbin/e2fsck /sbin
8+copy_exec /sbin/resize2fs /sbin
9 copy_exec /bin/chown /bin
10 copy_exec /bin/mount /bin
11 copy_exec /bin/readlink /sbin
12
13=== modified file 'scripts/touch'
14--- scripts/touch 2015-04-21 18:53:57 +0000
15+++ scripts/touch 2015-04-24 07:10:38 +0000
16@@ -163,6 +163,26 @@
17 cd $OLD_PWD
18 }
19
20+resize_userdata_if_needed() {
21+
22+ # See if the filesystem on the userdata partition needs resizing (usually on first boot).
23+ # If the difference between the partition size and the filesystem size is above a small
24+ # threshold, assume it needs resizing to fill the partition.
25+
26+ path=$1
27+
28+ # Partition size in 1k blocks
29+ pblocks=$(grep ${path#/dev/*} /proc/partitions | awk {'print $3'})
30+ # Filesystem size in 4k blocks
31+ fsblocks=$(dumpe2fs -h $path | grep "Block count" | awk {'print $3'})
32+ # Difference between the reported sizes in 1k blocks
33+ dblocks=$(($pblocks-4*$fsblocks))
34+ if [ $dblocks -gt 10000 ];then
35+ resize2fs -f $path
36+ echo "initrd: resized userdata filesystem to fill $path" >/dev/kmsg || true
37+ fi
38+}
39+
40 mountroot()
41 {
42 # list of possible userdata partition names
43@@ -217,6 +237,8 @@
44 fsck_end=`date +%s`
45 echo "initrd: checking filesystem for userdata took (including e2fsck) $((fsck_end-fsck_start)) seconds" >/dev/kmsg || true
46
47+ resize_userdata_if_needed ${path}
48+
49 echo "initrd: mounting $path" >/dev/kmsg || true
50
51 # Mount the data partition to a temporary mount point

Subscribers

People subscribed via source and target branches

to all changes: