Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: Remount filesystems after resizing them #19418

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented Oct 2, 2023

No description provided.

@mvollmer mvollmer added the blocked Don't land until something else happens first (see task list) label Oct 2, 2023
@mvollmer mvollmer requested a review from jelly October 2, 2023 08:19
@jelly
Copy link
Member

jelly commented Oct 2, 2023

# test/verify/check-storage-mounting:462:56: E261 at least two spaces before inline comment

@mvollmer mvollmer force-pushed the storage-remount-after-resize branch from 7a8bb8a to e8510ce Compare October 5, 2023 07:06
@mvollmer mvollmer removed the blocked Don't land until something else happens first (see task list) label Oct 5, 2023
@mvollmer mvollmer temporarily deployed to gh-cockpituous October 17, 2023 07:33 — with GitHub Actions Inactive
@jelly
Copy link
Member

jelly commented Oct 17, 2023

I just noticed that we support creating a partitionless filesystem so basically mkfs.xfs /dev/sda, but there is no option to resize this filesystem. Is this a missing feature?

NVM: you can't seem to create a half formatted partitionless disk, this would be insanely silly :)

Resizing grow to full (created a separate issue for this)

Resizing XFS to the max gave an error (which I closed...) about the sizes mismatching. It turns out the partition is now resized but the FS is not so a user will end up with:

image

I can't grow this now, a user will get:

Error resizing filesystem on /dev/sda1: Process reported exit code 1: data size 524028 too large, maximum is 524027 

@jelly
Copy link
Member

jelly commented Oct 17, 2023

Comments related to the PR:

Shrinking /boot/efi does succeed? But re-mounting does not work

image

fstab looks like:

UUID=7B77-95E7  /boot/efi       vfat    defaults,uid=0,gid=0,umask=077,shortname=winnt  0       2

Actions list does not show it will mount after growing

image

If an error happens during resizing (not enough space or so) we already umounted so the next grow/shrink button click will result in:

image

Unrelated, we can't grow/shrink a vfat partition to arbitrary sizes

Danger alert:Error resizing filesystem on /dev/vda2: Failed to resize the filesystem on '/dev/vda2' (GNU Parted cannot resize this partition to this size. We're working on it!)

It seems this is about shrinking to a specific size which errors out.

image

This happens on libblockdev 2.28 on RHEL 9. And the resize code is different from what I am looking at for libblockdev master. So let's re-test this on Fedora 39.

Reproduced on Fedora-39, this is a libblockdev bug, as vfat-resize comes from libblockdev-tools (which we might want on our images). So this error comes from libparted which makes it seems it can't detect the fat type of the partition?

The issue here is that you can only resize vfat in certain cluster sizes. Depending on if it's Fat 16 or Fat 32.

We can shrink to zero,this never makes sense (should create a separate issue for this)

image

self.content_row_action(fsys_row, "Mount")
self.confirm()
self.wait_mounted(fsys_row, fsys_tab)
self.wait_mounted(fsys_row, fsys_tab)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we verify that the mount options are the same?

Copy link
Member

@jelly jelly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When any resize action fails, either due to space constraints or something else we already umounted the FS and changing the size and then trying to resize will fail as Cockpit errors out with "FS is already umounted"

@mvollmer
Copy link
Member Author

Shrinking /boot/efi does succeed? But re-mounting does not work

/dev/vda2 is mounted on both /boot/efi and /efi before the resize, but there is no fstab entry for /efi. Do you know why that is? (Why is it mounted twice?)

But we should fix Cockpit in any case:

  • refuse to resize in the first place when there are mounts without fstab
  • ignore mounts without fstab entry during unmounting, resizing will likely fail.
  • do the resize, but ignore failures from remounting
  • ...

I think the first option is best.

@mvollmer
Copy link
Member Author

When any resize action fails, either due to space constraints or something else we already umounted the FS and changing the size and then trying to resize will fail as Cockpit errors out with "FS is already umounted"

Yes, that's a old bug...

@mvollmer
Copy link
Member Author

We can shrink to zero,this never makes sense (should create a separate issue for this)

Well, this is caught in the dialog before starting any action. But yeah, very small sizes will likely never succeed and Cockpit could prevent that. But since in the case of shrinking, the filesystem is resized first, and if that fails immediately, no harm has been done, no? The only thing to improve is the error message or user experience.

@mvollmer
Copy link
Member Author

Reproduced on Fedora-39, this is a libblockdev bug

Thanks for investigating this. Can we do anything about it in Cockpit? Maybe refusing to resize vfat is the best option.

@jelly
Copy link
Member

jelly commented Oct 18, 2023

TL;DR

On RHEL-9-4 we have this

findmnt
├─/efi systemd-1 autofs rw,relatime,fd=47,pgrp=1,timeout
│ └─/efi /dev/vda2 vfat rw,relatime,fmask=0077,dmask=007
└─/boot /dev/vda3 xfs rw,relatime,seclabel,attr2,inode
└─/boot/efi /dev/vda2 vfat rw,relatime,fmask=0077,dmask=007

Shrinking /boot/efi does succeed? But re-mounting does not work

/dev/vda2 is mounted on both /boot/efi and /efi before the resize, but there is no fstab entry for /efi. Do you know why that is? (Why is it mounted twice?)

This was with a standard Fedora-39 image.

/dev/vda3 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)

I recall what I did. I was trying to resize /boot which umount's both /boot/efi and /boot

[root@fedora-39-127-0-0-2-2201 ~]# mount | grep boot
/dev/vda2 on /boot type ext4 (rw,relatime,seclabel)
/dev/vda3 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)
[root@fedora-39-127-0-0-2-2201 ~]# grep boot /etc/fstab
UUID=19a5c8b5-13c3-43d2-a59d-c78e275ba9e2 /boot                   ext4    defaults        1 2
UUID=6558-48D7          /boot/efi               vfat    defaults,uid=0,gid=0,umask=077,shortname=winnt 0 2

But now I can't reproduce it on Fedora -39. But on RHEL-9-4 this problem does happen:

image

[root@rhel-9-4-127-0-0-2-2201 ~]# grep boot /etc/fstab
UUID=5b68f570-1c4e-4953-9308-4bc9f6a3c8f6       /boot   xfs     defaults        0       0
UUID=7B77-95E7  /boot/efi       vfat    defaults,uid=0,gid=0,umask=077,shortname=winnt  0       2
[root@rhel-9-4-127-0-0-2-2201 ~]# grep boot /etc/fstab
[root@rhel-9-4-127-0-0-2-2201 ~]# mount | grep boot
/dev/vda3 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
/dev/vda2 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)

Note that the only different is /boot being xfs instead of ext4? This is a rather interesting bug

But we should fix Cockpit in any case:

* refuse to resize in the first place when there are mounts without fstab

Or show a warning that it won't be remounted?

* ignore mounts without fstab entry during unmounting, resizing will likely fail.

* do the resize, but ignore failures from remounting

* ...

I think the first option is best.

@jelly
Copy link
Member

jelly commented Oct 18, 2023

Reproduced on Fedora-39, this is a libblockdev bug

Thanks for investigating this. Can we do anything about it in Cockpit? Maybe refusing to resize vfat is the best option.

It's not a libblockdev bug per se, well it depends on what you expect from an API. FAT16/32 can only be resized to certain block sizes, maybe xfs too? But libblockdev hard errors if you propose to resize it to 15.5MB or so. I created a follow up issue for this in Cockpit.

@mvollmer mvollmer temporarily deployed to gh-cockpituous October 23, 2023 13:44 — with GitHub Actions Inactive
@mvollmer
Copy link
Member Author

Or show a warning that it won't be remounted?

Yes, that's what I did now, kinda Mounts without fstab entry will be unmounted, but not be remounted. There is no big warning about that, the dialog just doesn't mention that they will be remounted.

image

@mvollmer mvollmer requested a review from jelly October 23, 2023 13:47
@mvollmer
Copy link
Member Author

Actions list does not show it will mount after growing

Fixed, see #19418 (comment)

.filter(function (s) { return s.indexOf("x-parent") === 0 })
.join(",");
if (dir[0] != "/")
dir = "/" + dir;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test. Details

actions: is_top ? get_actions(_("unmount")) : [_("unmount")],
has_fstab_entry,
set_noauto: !is_top && !is_temporary,
actions: (is_top ? get_actions(_("unmount")) : [_("unmount")]).concat(has_fstab_entry ? [_("mount")] : []),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test. Details

@mvollmer
Copy link
Member Author

mvollmer commented Oct 24, 2023

Thanks for investigating this. Can we do anything about it in Cockpit? Maybe refusing to resize vfat is the best option.

It's not a libblockdev bug per se, well it depends on what you expect from an API. FAT16/32 can only be resized to certain block sizes, maybe xfs too? But libblockdev hard errors if you propose to resize it to 15.5MB or so. I created a follow up issue for this in Cockpit.

Cockpit should try to predict errors as much as possible and steer the user away from triggering them, but it's always an option to just let the tool fail in obscure ways. So if VFAT has baroque restrictions on what sizes it can be resized to, which depend on the version of parted that we are ultimately using, then I think we can just shrug, and expose the ugly belly of the beast.

@@ -791,6 +815,9 @@ export function get_active_usage(client, path, top_action, child_action) {
}

function enter_unmount(block, location, is_top) {
const [, mount_point] = get_fstab_config_with_client(client, block);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing that get_fstab_config_with_client can return [], this leads to mount_point being undefined, it might be better to use === below. But looking at it, it should do the right thing currently.

@jelly jelly merged commit 4e34a3c into cockpit-project:main Oct 24, 2023
100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants