cloud-init icon indicating copy to clipboard operation
cloud-init copied to clipboard

fstab entry for disk without filesystem

Open rjschwei opened this issue 2 years ago • 2 comments

Bug report

It is possible to get into a situation where cloud-init creates an entry in /etc/fstab for a device that has no file system.

cc_mounts automatically creates an entry in fstab when a device with ephemeral or ebs in the name is found. While the fstab entry contains nofail this does not stop the mount command from complaining:

cloud-init.log:2021-11-17 16:09:30,601 - cc_mounts.py[DEBUG]: Changes to fstab: ['+ /dev/xvdb /mnt auto defaults,nofail,x-systemd.requires=cloud-init.service,comment=cloudconfig 0 2']
cloud-init.log:Stderr: mount: /mnt: wrong fs type, bad option, bad superblock on /dev/xvdb, missing codepage or helper program, or other error.

In effect we are training users to ignore errors, which I consider a bad thing.

We have various options to look at this and handle the topic but the direction is not obvious.

1.) Do away with the automagic setup of ephemeral devices

  • This to a certain extend represents a loss of convenience and existing functionality. As such this is probably not the preferred path 2.) Only create an entry in fstab if cc_disk_setup is in the config and has a configuration for the automatically detected device 3.) Automagically create a default setup, 1 partition with a filesystem on the device

Other directions exist. There is no obvious answer and we probably need to form a consensus opinion about what the behavior should be.

Steps to reproduce the problem

Environment details

  • Cloud-init version:
  • Operating System Distribution:
  • Cloud provider, platform or installer type:

cloud-init logs

rjschwei avatar Aug 14 '23 13:08 rjschwei

Or have cc_mount check, before adding a /etc/fstab entry, that there is a filesystem there of the correct type. I.e. on Linux do blkid -s TYPE and check the result with the specified fs_vfstype value. Obviously "swap" and "auto" would be treated as special cases.

And if the fstype doesn't match, or if there is no filesystem at all, then cc_mount should give either a warning or an error.

I don't know what the BSD equivalent of ```blkid`` is but assume there must be a similar method.

dermotbradley avatar Aug 14 '23 14:08 dermotbradley

I think @dermotbradley's suggestion is the less intrusive/surprising, without change of behavior.

aciba90 avatar Aug 21 '23 10:08 aciba90