Ir al contenido principal

NFS Server

Servidor:

  nfs-server:
    image: itsthenetwork/nfs-server-alpine:latest-arm
    container_name: nfs-server
    privileged: true                  # Necesario para NFS
    restart: unless-stopped
    # network_mode: "host"              # Exponer directamente el puerto 2049
    ports:
      - "2049:2049/tcp"               # Puerto NFS
      - "2049:2049/udp"               # Puerto NFS
    environment:
      TZ: America/Mexico_City
      SHARED_DIRECTORY: /nfsshare     # Directorio que se comparte por NFS
      # READ_ONLY: "true"            # Opcional: solo lectura
      # SYNC: "true"                 # Opcional: modo síncrono
      # PERMITTED: "192.168.1.*"    # Opcional: restringir IPs
    volumes:
      - /mnt/nas/backups/jellyfin:/nfsshare # Carpeta a compartir
      # - ./config/nfs/exports:/etc/exports:ro # Permisos avanzados
      

Cliente:

1. Install NFS Client Packages:
First, install the necessary NFS client packages on your Debian machine:
sudo apt update
sudo apt install nfs-common
2. Create a Local Mount Point:
Create a directory on your Debian machine where you want to mount the NFS share. This will be the local access point for the remote files.
sudo mkdir /mnt/nfs
3. Mount the NFS Share:
Now, you can mount the NFS share from the server to your local mount point. You'll need the IP address or hostname of the NFS server and the path to the shared directory on the server.
sudo mount -t nfs <NFS_SERVER_IP_OR_HOSTNAME>:/path/to/shared/directory /mnt/nfs

mount -t nfs 192.168.31.100:/ /mnt/nfs
4. Verify the Mount:
You can verify that the NFS share has been successfully mounted using the df -h command:
df -h
This command will display a list of mounted filesystems, including your newly mounted NFS share.
5. Mount NFS at Boot (Optional):
To automatically mount the NFS share every time your Debian machine boots, you can add an entry to the /etc/fstab file.
Open /etc/fstab with a text editor (e.g., nano or vim):
sudo nano /etc/fstab
Add a line similar to the following, replacing the placeholders with your specific details:
<NFS_SERVER_IP_OR_HOSTNAME>:/path/to/shared/directory /mnt/nfs_share nfs defaults

192.168.31.100:/      /mnt/nfs     nfs    defaults,noatime,_netdev,x-systemd.automount      0     0