Merge ~lfaraone/ubuntu/+source/initramfs-tools:lp798414 into ~ubuntu-kernel/ubuntu/+source/initramfs-tools:ubuntu

Proposed by Luke Faraone on 2016-10-25
Status: Needs review
Proposed branch: ~lfaraone/ubuntu/+source/initramfs-tools:lp798414
Merge into: ~ubuntu-kernel/ubuntu/+source/initramfs-tools:ubuntu
Diff against target: 35 lines (+17/-0)
1 file modified
update-initramfs (+17/-0)
Reviewer Review Type Date Requested Status
LaMont Jones 2016-12-23 Pending
Mathieu Trudel-Lapierre 2016-10-25 Pending
Review via email: mp+309191@code.launchpad.net
To post a comment you must log in.
Jarno Suni (jarnos) wrote :

Just a note that egrep is told to be deprecated (in manual page), "grep -E" is is the recommended form. That said, grep -o '[0-9]*' would work here, too. Or awk 'NR==2{print $1}'

Jarno Suni (jarnos) wrote :

It might not happen with default settings, but could it happen that also a backup initrd.img file will be generated? If so, 50 MiB might not be enough.

Unmerged commits

40f5c4c... by Luke Faraone on 2016-10-25

update-initramfs: Print an error if insufficient space on $BOOTDIR

Check to see if there's a reasonable amount of free space on $BOOTDIR. If there
isn't, warn the user of this and point them to useful documentation.

A threshold of 50MiB is used since an initramfs is about 35MiB on a desktop
installation of 16.04.

LP: #798414

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/update-initramfs b/update-initramfs
2index 91442a4..10de744 100755
3--- a/update-initramfs
4+++ b/update-initramfs
5@@ -159,6 +159,22 @@ remove_initramfs_bak()
6 verbose "Removing ${initramfs_bak}"
7 }
8
9+# In case generating the initramfs fails due to a lack of disk space, print a
10+# friendly error message.
11+spacecheck()
12+{
13+ # Reasonable upper-bound for an initramfs.
14+ MIN_FREE=50
15+
16+ # The available disk space in MiB
17+ free_space=$(df "${BOOTDIR}" --output=avail --block-size=1M | egrep -o '[0-9]+')
18+
19+ if [ $free_space -lt $MIN_FREE ]; then
20+ echo ""
21+ echo "update-initramfs: ${BOOTDIR} has ${free_space}MiB available; at least ${MIN_FREE}MiB is recommended."
22+ echo "update-initramfs: For help, see <https://help.ubuntu.com/community/LowDiskOnBoot>."
23+ fi
24+}
25
26 generate_initramfs()
27 {
28@@ -177,6 +193,7 @@ generate_initramfs()
29 remove_initramfs_bak
30 rm -f "${initramfs}.new"
31 echo "update-initramfs: failed for ${initramfs} with $mkinitramfs_return." >&2
32+ spacecheck
33 exit $mkinitramfs_return
34 fi
35 }

Subscribers

People subscribed via source and target branches