canonical / canonical/cloud-init
cc_disk_setup always overwrites filesystem on raw disk
- Dominant language
- Python
- Stars
- 3.8k
- Forks
- 1.1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
This bug was originally filed in Launchpad as [LP: #1943156](https://bugs.launchpad.net/cloud-init/+bug/1943156)
Launchpad details
affected_projects = []
assignee = None
assignee_name = None
date_closed = None
date_created = 2021-09-09T15:21:00.623940+00:00
date_fix_committed = None
date_fix_released = None
id = 1943156
importance = medium
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1943156
milestone = None
owner = optimum-reflex
owner_name = xstaticxgpx
private = False
status = triaged
submitter = optimum-reflex
submitter_name = xstaticxgpx
tags = []
duplicates = []
_Launchpad user **xstaticxgpx(optimum-reflex)** wrote on 2021-09-09T15:21:00.623940+00:00_
See https://github.com/canonical/cloud-init/blob/758acf976f2cb67a85411467fa5fca2ea17a2283/cloudinit/config/cc_disk_setup.py#L1005-L1009
```
# File systems that support the -F flag
if overwrite or device_type(device) == "disk":
force_flag = lookup_force_flag(fs_type)
if force_flag:
fs_cmd.append(force_flag)
```
Even with `overwrite: false` when using a raw disk device (ie. /dev/sdb) the filesystem will always be overwritten. This seems unintended, as it's definitely not clarified in the documentation.
I think at the very least the documentation should be clarified that raw disk devices will ALWAYS be overwritten by default.
We ended up overwriting our `cmd` value to prevent the force flag from being added...
```
- label: DATA
filesystem: xfs
device: /dev/sdb
cmd: '/usr/sbin/mkfs.xfs %(device)s -L %(label)s'
```
Contributor guide
Assessment
This issue has not been assessed yet.