Score:0

How to resize unmountable BTRFS filesystem

br flag

I have a disk with LVM with two logical volumes media and root. The former is almost empty the latter is almost full, so I wanted to resize both.

The logical volume media is dm-crypt + BtrFS. In order to resize the filesystem, the LUKS container and the logical volume, I ran the following commands:

sudo btrfs filesystem resize 1T /mnt
sudo umount /mnt
sudo cryptsetup close /dev/mapper/luks-container
sudo lvresize --size 1T /dev/mapper/hdd-media

Now I cannot mount /dev/mapper/luks-container anymore. The relevant output is

[ 2853.075049] BTRFS info (device dm-2): disk space caching is enabled
[ 2853.075058] BTRFS info (device dm-2): has skinny extents
[ 2853.079920] BTRFS error (device dm-2): device total_bytes should be at most 1099494850560 but found 1099511627776
[ 2853.079926] BTRFS error (device dm-2): failed to read chunk tree: -22
[ 2853.081181] BTRFS error (device dm-2): open_ctree failed

So apparently, both 1T sizes differed slightly and the BrtFS would like to be bigger than it can. This is no problem at all, I could just shrink it a little more, but for that I would have to mount it, which is impossible.

How could I fix this situation? How could I shrink the BtrFS a bit further without being able to mount it?

Score:0
br flag

I found a workaround. Instead of shrinking an unmountable filesystem, I increased the size of the logical volume a bit.

sudo lvresize --size 1025G /dev/mapper/hdd-media

Note that I had to close the LUKS container in order to make the file system mountable for this.

Since this is only a workaround and not an answer to the question above, I will not accept it.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.