Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions subiquity/server/controllers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,10 +1398,16 @@ async def v2_edit_partition_POST(
if data.partition.boot is not None and data.partition.boot != partition.boot:
raise ValueError("edit_partition does not support changing boot")
spec: PartitionSpec = {"mount": data.partition.mount or partition.mount}
# NOTE from ogayot: it is my understanding that in this context, having
# format=None (which is the default value) means to keep the current
# format. To change from ext4 to "unformatted", one must specify
# format="".
if data.partition.format is not None:
if data.partition.format != partition.original_fstype():
if data.partition.wipe is None:
raise ValueError("changing partition format requires a wipe value")
if data.partition.wipe is None and partition.preserve:
Copy link
Member Author

@ogayot ogayot Jan 27, 2025

Choose a reason for hiding this comment

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

Should we check the value of preserve at the FS level (which may or may not exist) ? This is what we do to label "to be reformatted as ...." and "to be formatted as ....".

fs = device.fs()
if fs is not None:
if fs.preserve:
format_desc = _("already formatted as {fstype}")
elif device.original_fstype() is not None:
format_desc = _("to be reformatted as {fstype}")
else:
format_desc = _("to be formatted as {fstype}")

Copy link
Member Author

Choose a reason for hiding this comment

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

@dbungert do you know? i.e., the difference between partition.preserve and partition.fs.preserve?

Copy link
Member

Choose a reason for hiding this comment

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

I will defer to the curtin documentation on this one. https://curtin.readthedocs.io/en/latest/topics/storage.html

From a label standpoint this is a very subtle difference.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be clear, this works because preserve is already set for existing objects by default?

raise ValueError(
"changing format of existing partition requires a wipe value"
)
spec["fstype"] = data.partition.format
if data.partition.size is not None:
spec["size"] = data.partition.size
Expand Down
Loading