yast / yast-storage-ng

Rewrite of https://github.com/yast/yast-storage
http://yast.github.io/
GNU General Public License v2.0
13 stars 19 forks source link

Prevent setting the Volume Label for a Mounted Btrfs or Swap [master] #1342

Closed shundhammer closed 1 year ago

shundhammer commented 1 year ago

Target Branch

This is the merge of #1341 to master / Factory.

Bugzilla

L3: https://bugzilla.suse.com/show_bug.cgi?id=1211337

Trello

https://trello.com/c/JvuZVVU3

Problem

Trying to change the volume label of a mounted Btrfs or swap partition in the YaST partitioner fails with an error message

Setting label of btrfs on /dev/sda2 (57.50 GiB) to root Unexpected situation found in the system.

The "Details" button shows

Caught signal #127: "/sbin/btrfs filesystem label '/dev/sda2' 'root'

which is scary and confusing and does not give the user any hint what's actually wrong.

Unexpected_situation

Caught_signal

In the case of a root Btrfs, it even hangs later because subvolumes cannot be mounted.

Cause

Even though some filesystem types do support changing the volume label while mounted, in our context this has implications with the subvolumes. Handling the subvolumes properly very likely requires a very intrusive code change which involves quite some risk.

Fix

So we chose the less intrusive approach to disable it on the UI level: When we detect that the filesystem or swap space is actively mounted, we are now disabling the "Volume Label" field in the "Fstab Options" dialog.

Screenshots

partitioner-btrfs Partitioner with a mounted Btrfs on /dev/sdb1

partitioner-edit Editing /dev/sdb1

btrfs-mounted "Volume Label" field disabled because the filesystem is mounted, so changing it would fail.

partitioner-edit-after-unmount After unmounting, saving the changes and entering the partitioner again, the volume label can now be changed.

Test

Extensive manual tests in a VM with a second virtual disk where partitions can be easily added and changed.

Related PRs

coveralls commented 1 year ago

Coverage Status

coverage: 97.752% (-0.003%) from 97.755% when pulling 4c965750daff43ae242d90f284e819f589f77df5 on huha-vol-label-master into 1e609c107a158d4cc4c73361aaad4f3f4182352b on master.

yast-bot commented 1 year ago

:heavy_check_mark: Public Jenkins job #467 successfully finished :heavy_check_mark: Created OBS submit request #1091235