Fstab Missing from Proxmox Container

Okay, so you're using an LXC Container within the Proxmox virtual environment and you notice, for some reason, that your /etc/fstab file isn't right. It's blank, lacking even a mount point for your virtual hard drive. Strange? Not really!

Think about it: a mount point for a VM would logically be with the host, right? Since the VM doesn't have a real hard drive, it can't have a mount point in /etc/fstab.

This method is applicable in one of three use cases. I may document the other two later, but not at this time.

Objective:

Mount an NFS share within an LXC container.

Problem:

No fstab file is available to mount the NFS directory on boot, and the 'mount -a' command fails.

Solution:

   Mount the share on the Host, not the Guest.

   Passthrough the directory to the Guest.

How-To:

First, create a directory on the host to hold the files from the NFS share. Log in and issue:

bash

mkdir /media/myshare

The last part should mimic the name of the actual share to keep things simple, but you may choose your own method.

To have the share mounted on boot, you need to edit another file. I use the nano file editor for this:

On the host machine, issue:

bash

nano /etc/fstab

Then add the following line:

bash

yourip:/your/path  /media/path  nfs     defaults        0       0

Next, update fstab:

bash

systemctl daemon-reload

Now, mount the share on the host. This step is crucial before sharing it:

If all goes well, let's move on to sharing this NFS share within the LXC environment, which is why you're here!

After noting the VMID of your virtual machine (the number next to its name), power down your container. Once done, we can add the share.

On the host, issue the command:

bash

pct set VMID -mp0 /your/path,mp=/path

Remember, this needs to be based on your environment, not mine. So, consider the above steps objectively.

THE END