How to mount NFS volume via preseed

Hi,

The curtin preseed provides config to curtin (the installer) not to cloud-init; The config you’re specifying is for cloud-init. curtin does not support ‘mounts’ like you’ve defined. The set of top-level config keys curtin supports is here:

https://curtin.readthedocs.io/en/latest/topics/config.html

For curtin to mount things during the install (and in the target) you will need to add entries to the
‘storage’ config provided, specifically a ‘type: mount’ entry

https://curtin.readthedocs.io/en/latest/topics/storage.html#mount-command

I’ve not tested an ‘nfs’ mount before, but this is the format curtin would accept, it would need to be added to the storage config list.

- id: nfs1
  fstype: "none"
  options: "auto,nofail,noatime,nolock,intr,tcp,actimeo=1800,user,suid"
  path: "/mnt/nfs"
  spec: "00.00.00.00:/path"
  freq: "0"
  passno: "0"
  type: mount

This would generate the following entry in /etc/fstab

# /mnt/nfs was on 00.00.00.00:/path during curtin installation
00.00.00.00:/path /mnt/nfs nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800,user,suid 0 0

I would suggest that you add ‘_netdev’ to the options list, as this tells systemd that the mount point requires networking to be up. It may already do that for fstab ‘spec’ entries which look like IP or hostnames, but just in case, we add ‘_netdev’ when mounting iscsi volumes.

If you instead would like to have cloud-init issue this mount on first boot, you need to
have curtin write out cloud-config file to the target system like so:

write_files:
  nfsmnt:
     - path: /etc/cloud/cloud.cfg.d/99-nfs-mount.cfg
       content: |
         #cloud-config
         mounts:  
           - ["00.00.00.00:/path", "/mnt/nfs", "nfs", "auto,nofail,noatime,nolock,intr,tcp,actimeo=1800,user,suid", "0", "0"]
1 Like