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 [SLE-15-SP5] #1341

Closed shundhammer closed 1 year ago

shundhammer commented 1 year ago

Target Branch

This is the merge of #1340 to SLE-15-SP5.

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.748% (-0.003%) from 97.751% when pulling 0eaf97c04d1b3aa71a6c0e320e7a4179b1e4a418 on huha-vol-label-sp5 into 7746bc11f8d7b03b5ae227429f7b306690c4ffb2 on SLE-15-SP5.

yast-bot commented 1 year ago

:heavy_check_mark: Internal Jenkins job #754 successfully finished :heavy_check_mark: Created IBS submit request #300737