ubuntu bionic grub can't boot zstd compressed filesystem

Bug #1751517 reported by en
34
This bug affects 7 people
Affects Status Importance Assigned to Milestone
grub2 (Arch Linux)
New
Undecided
Unassigned
grub2 (Ubuntu)
Triaged
Wishlist
Unassigned

Bug Description

In the /etc/fstab of installed ubuntu bionic system I specified compress=zstd for the btrfs root filesytem
After runing 'sudo btrfs filesystem defragment -r -czstd /' the system booted to a grub shell. I could boot again by running 'sudo btrfs filesystem defragment -r -clzo /' and specifying compress=lzo in the /etc/fstab.
There is also a new bug in the btrfs tools:
btrfs does recognize the option '-clzo' but not '-c lzo'.

Tags: btrfs grub
en (b21enu)
description: updated
en (b21enu)
affects: update-manager (Ubuntu) → grub (Ubuntu)
description: updated
Steve Langasek (vorlon)
affects: grub (Ubuntu) → grub2 (Ubuntu)
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I wonder if I should be disabling zstd support in btrfs-progs, if we cannot boot them.

Revision history for this message
Lorens Gwine (lorensgwine) wrote :

There may be non root partitions that users want to compress with zstd so you shouldn't

Revision history for this message
en (b21enu) wrote :

possible workaround:
Patch all btrfs-tools so that they don't compress files accessed by grub with zstd.

pitfall:
If users repair the filesystem from a live-cd, (eg. run defragmentation), they must make sure that they don't compress files acessed by grub with zstd.

Another option:
Archlinux uses this patched grub version:

https://github.com/Antynea/grub-btrfs

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in grub2 (Ubuntu):
status: New → Confirmed
Revision history for this message
Konstantin (hi-angel-z) wrote :

> Another option:
> Archlinux uses this patched grub version:
>
> https://github.com/Antynea/grub-btrfs

This is doubly wrong. Archlinux does not use what you linked, but instead uses mainline version with some patches https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/grub#n60 Either way, it doesn't work for the topic.

But I (I'm on Archlinux) did try your github version, there's a user package grub-btrfsᴬᵁᴿ for this one. It does not boot from zstd compressed partition either.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

This would be an enhancement request.

Changed in grub2 (Ubuntu):
status: Confirmed → Triaged
importance: Undecided → Wishlist
Revision history for this message
Dmitriy Geels (dmig) wrote :

The simplest workaround for the moment:

sudo btrfs property set /boot compression lzo # ensure this dir will remain readable by grub
sudo btrfs filesystem defragment -vr /boot # ensure /boot gets recompressed

Revision history for this message
Dmitriy Geels (dmig) wrote :

Seems that btrfs ignores compression attribute if compression was set using mount option.
So, the solution is to set compression attributes per-directory:

1) remove 'compress=zstd' from your fstab root record
2) sudo btrfs property set /boot compression lzo # ensure this dir will remain readable by grub
3) sudo btrfs filesystem defragment -vrclzo /boot # ensure /boot gets recompressed
4) for $d in bin etc lib lib64 opt sbin snap srv usr var; do sudo btrfs property set /$d compression zstd; done

Directory list is for Ubuntu 18, check and adjust for your own needs.

Revision history for this message
Dmitriy Geels (dmig) wrote :

Results (using btrfs-compsize tool):

$ sudo compsize /boot/ /bin/ /usr/
Processed 240794 files, 88025 regular extents (89183 refs), 162022 inline.
Type Perc Disk Usage Uncompressed Referenced
TOTAL 50% 2.7G 5.3G 5.4G
none 100% 1.1G 1.1G 1.1G
lzo 46% 9.1M 19M 19M
zstd 37% 1.5G 4.1G 4.2G

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.