Skip to content

Commit 89648a4

Browse files
authored
Switch to ext4 for generated .img files (#374)
Ubuntu has been using [ext4 as the default since Ubuntu 9.10](https://wiki.ubuntu.com/KarmicKoala/TechnicalOverview#ext4_by_default) (2009), and the ext3 driver in the Linux kernel was [removed](https://lwn.net/Articles/651645/) in [version 4.3](https://kernelnewbies.org/Linux_4.3#The_Ext3_filesystem_has_been_removed) (2015), so internally, the ext4 driver has been mounting the ext3 images as loop devices for a long time already on Heroku runtime instances. All mounts that overlay the read-only root filesystem in containers, such as `/app`, have also been ext4 ever since it became the default: % heroku run -- mount | head Running mount on sushi... up, run.3567 /dev/loop17 on / type ext3 (ro,nosuid,nodev,nodiratime,relatime) none on /dev type tmpfs (rw,relatime,size=492k,mode=755,inode64) /dev/mapper/evg0-evol0 on /app type ext4 (rw,relatime) /dev/mapper/evg0-evol0 on /tmp type ext4 (rw,relatime) /dev/mapper/evg0-evol0 on /var/tmp type ext4 (rw,relatime) none on /proc type proc (rw,relatime) none on /dev type tmpfs (rw,nosuid,noatime,nodiratime,size=1024k,mode=755,inode64) none on /dev/shm type tmpfs (rw,nosuid,nodev,relatime,size=65536k,nr_inodes=2048,mode=700,uid=5790,gid=5790,inode64) /dev/mapper/evg0-evol0 on /etc/passwd type ext4 (ro,relatime) /dev/mapper/evg0-evol0 on /etc/group type ext4 (ro,relatime) GUS-W-21298571
1 parent c7c46a6 commit 89648a4

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

tools/bin/capture-docker-stack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ display "Modifying image directories and files"
4040
install-heroku-files "${IMG_MNT}" |& indent
4141

4242
display "Unmounting image"
43-
df --human-readable "${IMG_MNT}" |& indent
43+
df --sync --human-readable "${IMG_MNT}" |& indent
4444
umount "${IMG_MNT}" |& indent
4545

4646
display "SHA256ing and gzipping image"

tools/bin/make-filesystem-image

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ DOCKER_IMAGE_SIZE_IN_MB="$2"
99
# of the original Docker image to avoid either wasting space or having the later tar extraction
1010
# step fail with out of disk space errors. The image will be mounted read-only at runtime, so
1111
# does not need free space for app files (separate mounts are used for those). The multiplier
12-
# here is to account for the 5-6% loss of usable space due to ext3 filesystem overhead, as well
12+
# here is to account for the 5-6% loss of usable space due to ext4 filesystem overhead, as well
1313
# as to ensure a few MB additional free space headroom.
1414
IMG_SIZE_IN_MB=$((DOCKER_IMAGE_SIZE_IN_MB * 107 / 100))
1515

@@ -23,13 +23,11 @@ mkdir -p "$(dirname "$IMG")"
2323
# https://unix.stackexchange.com/a/121888
2424
fallocate --length "${IMG_SIZE_IN_MB}MiB" "${IMG}"
2525

26-
# Format that file as an ext3 filesystem.
26+
# Format that file as an ext4 filesystem.
2727
# The `-T` argument forces the 'default' config profile to be used, since otherwise if the filesystem size
2828
# is less than 512 MB (as is the case for Heroku-24's run image) the 'small' profile would be used instead.
2929
# The `-m` argument reduces reserved-blocks-percentage from its default of 5% to 1%.
30-
# TODO: Switch to calling `mkfs.ext3` or `mke2fs -t ext3` since the `mkfs` alias is deprecated:
31-
# https://manpages.ubuntu.com/manpages/jammy/en/man8/mkfs.8.html
32-
mkfs -t ext3 -T default -m 1 -v "$IMG"
30+
mkfs.ext4 -T default -m 1 -v "$IMG"
3331

3432
# Adjust the filesystem parameters for improved performance on runtime instances.
3533
# The `-c` and `-i` arguments disable automatic filesystem checks, which are otherwise run based

0 commit comments

Comments
 (0)