# 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:

<div class="WaaZC" id="bkmrk-1.-install-nfs-clien"><div class="RJPOee EIJn2"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CAwQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIDBAB" role="heading">**<span data-huuid="796681543540008486">1. Install NFS Client Packages:</span>**</div></div></div><div class="WaaZC" id="bkmrk-first%2C-install-the-n"><div class="RJPOee EIJn2"><div class="rPeykc" data-hveid="CAgQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQICBAB"><span data-huuid="796681543540008684">First, install the necessary NFS client packages on your Debian machine:</span></div></div></div>```
sudo apt update
sudo apt install nfs-common
```

<div class="WaaZC" id="bkmrk-2.-create-a-local-mo"><div class="RJPOee EIJn2"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CAMQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIAxAB" role="heading">**<span data-huuid="796681543540009080">2. Create a Local Mount Point:</span>**</div></div></div><div class="WaaZC" id="bkmrk-create-a-directory-o"><div class="RJPOee EIJn2"><div class="rPeykc" data-hveid="CA0QAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIDRAB"><span data-huuid="796681543540009278">Create a directory on your Debian machine where you want to mount the NFS share. </span><span data-huuid="796681543540009377">This will be the local access point for the remote files.</span></div></div></div>```
sudo mkdir /mnt/nfs
```

<div class="WaaZC" id="bkmrk-"><div class="RJPOee EIJn2"></div></div><div class="WaaZC" id="bkmrk-3.-mount-the-nfs-sha"><div class="RJPOee EIJn2"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CBsQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIGxAB" role="heading">**<span data-huuid="18330221067756522946">3. Mount the NFS Share:</span>**</div></div></div><div class="WaaZC" id="bkmrk-now%2C-you-can-mount-t"><div class="RJPOee EIJn2"><div class="rPeykc" data-hveid="CBwQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIHBAB"><span data-huuid="18330221067756523180">Now, you can mount the NFS share from the server to your local mount point. </span><span data-huuid="18330221067756521249">You'll need the IP address or hostname of the NFS server and the path to the shared directory on the server.</span></div></div></div>```
sudo mount -t nfs <NFS_SERVER_IP_OR_HOSTNAME>:/path/to/shared/directory /mnt/nfs

mount -t nfs 192.168.31.100:/ /mnt/nfs
```

<div class="WaaZC" id="bkmrk-4.-verify-the-mount%3A"><div class="RJPOee EIJn2"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CDEQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIMRAB" role="heading">**<span data-huuid="13754335637766131510">4. Verify the Mount:</span>**</div></div></div><div class="WaaZC" id="bkmrk-you-can-verify-that-"><div class="RJPOee EIJn2"><div class="rPeykc" data-hveid="CDAQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIMBAB"><span data-huuid="13754335637766130144">You can verify that the NFS share has been successfully mounted using the `df -h` command:</span></div></div></div>```
df -h
```

<div class="WaaZC" id="bkmrk-this-command-will-di"><div class="RJPOee EIJn2"><div class="rPeykc" data-hveid="CDcQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQINxAB"><span data-huuid="5524098862787974339">This command will display a list of mounted filesystems, including your newly mounted NFS share.</span></div><div class="rPeykc" data-hveid="CDcQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQINxAB"></div></div></div><div class="WaaZC" id="bkmrk-5.-mount-nfs-at-boot"><div class="RJPOee EIJn2"><div aria-level="3" class="rPeykc pyPiTc" data-hveid="CDkQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIORAB" role="heading">**<span data-huuid="1691246981484199750">5. Mount NFS at Boot (Optional):</span>**</div></div></div><div class="WaaZC" id="bkmrk-to-automatically-mou"><div class="RJPOee EIJn2"><div class="rPeykc" data-hveid="CDwQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIPBAB"><span data-huuid="1691246981484196012">To automatically mount the NFS share every time your Debian machine boots, you can add an entry to the `/etc/fstab` file.</span></div></div></div><div class="WaaZC" id="bkmrk-open%C2%A0%2Fetc%2Ffstab%C2%A0with"><div class="RJPOee EIJn2"><div class="rPeykc" data-hveid="CEEQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIQRAB"><span data-huuid="18330221067756521483">Open `/etc/fstab` with a text editor (e.g., `nano` or `vim`):</span></div></div></div>```
sudo nano /etc/fstab
```

<div class="WaaZC" id="bkmrk-add-a-line-similar-t"><div class="RJPOee EIJn2"><div class="rPeykc" data-hveid="CEUQAQ" data-ved="2ahUKEwjo__2agqWRAxXy48kDHbO8DBYQo_EKegQIRRAB"><span data-huuid="18103419185925947035">Add a line similar to the following, replacing the placeholders with your specific details:</span></div></div></div>```
<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
```