raspberry pi nas samba ntfs

Fix Raspberry Pi NAS Network Dropouts

Raspberry Pi NAS USB disconnect fix


Continuation of the article: Raspberry Pi as a Home NAS Server with an NTFS Drive (Guide)

Raspberry Pi NAS USB disconnect fix - raspberry pi nas samba ntfsRaspberry Pi as a Home NAS Server (Raspberry Pi)


When a NAS on Raspberry disconnects disks from the network by itself after a few minutes of inactivity

This applies to Raspberry Pi  but the procedure also works on Pi 3 / Pi 4 with the same issue.

(Samba + external USB disk – NTFS)

Raspberry Pi NAS USB disconnect fix:

I created two NAS systems configured this way on Raspberry, but one of them disconnects itself from the network after a few minutes of inactivity, and on the remote device the disks are not visible until the Raspberry is restarted. It is possible that this is caused by power saving of the Wi-Fi module or the disk itself. If this happens to you as well, here is a simple guide I created on how to prevent it.

This problem is very common mainly on Raspberry Pi with an external USB disk and the NTFS file system. In this article, you will find a complete and proven solution on how to disable USB power saving, correctly configure the disk, and ensure a stable NAS without dropouts.

 

Problem symptoms:

NAS works after reboot
after a few minutes / tens of minutes of inactivity:

  • it disappears from the network
  • notebook / PC reports that the share is not available
  • only a Raspberry reboot helps

Real cause

  • USB autosuspend puts the disk to sleep
  • external HDD goes to sleep or disconnects
  • Raspberry Pi 2 cannot properly wake it up
  • Samba keeps running, but the share is dead

COMPLETE SOLUTION STEP BY STEP


1.) Check USB autosuspend

cat /sys/module/usbcore/parameters/autosuspend

❌ Wrong:

2

✅ Correct:

-1

2.) Temporary fix (without reboot – test)

sudo sh -c 'echo -1 > /sys/module/usbcore/parameters/autosuspend'

Verify again:

cat /sys/module/usbcore/parameters/autosuspend

➡️ If the NAS stops disappearing after this, the cause is confirmed.


3.) Permanent fix – cmdline.txt (crucial step)

Open:

sudo nano /boot/firmware/cmdline.txt

The file must contain ONE single line only.
Use this template (edit only PARTUUID if different):

console=serial0,115200 console=tty1 root=PARTUUID=9da8a4b4-02 rootfstype=ext4 fsck.repair=yes rootwait usbcore.autosuspend=-1

Important:

  • everything on one line
  • no line breaks
  • no characters like f>

Save:

  • CTRL + O → Enter
  • CTRL + X

Reboot:

sudo reboot

4.) Check after reboot

cat /sys/module/usbcore/parameters/autosuspend

Must be:

-1

5.) Correct entry in /etc/fstab (without automount)

Open:

sudo nano /etc/fstab

❌ Do not use:

x-systemd.automount

✅ Correct entry:

/dev/sda1  /media/hdddata/movies  ntfs-3g  defaults,nofail,noatime  0  0

Activate:

sudo mount -a

Verify:

lsblk

6.) Disable disk sleep (recommended)

Temporarily:

sudo hdparm -S 0 /dev/sda

Permanently:

sudo nano /etc/hdparm.conf

Insert:

/dev/sda {
    spindown_time = 0
}

7.) Safety net: automatic Samba restart

Create script:

sudo nano /usr/local/bin/check-nas.sh

Content:

#!/bin/bash
mountpoint -q /media/hdddata/movies || systemctl restart smbd

Permissions:

sudo chmod +x /usr/local/bin/check-nas.sh

Add cron job:

crontab -e

Select:

1

Insert:

*/2 * * * * /usr/local/bin/check-nas.sh

Save:

  • CTRL + O → Enter
  • CTRL + X

Verify:

crontab -l

8.) Final test

Leave the NAS idle for 30–60 minutes
Connect from PC / notebook:

Windows:

\\IP_RASPBERRY\movies

Linux:

smb://IP_RASPBERRY/movies

The share must:

  • appear immediately
  • not disappear
  • work without rebooting Raspberry

IMPORTANT NOTE ABOUT POWER SUPPLY

If you have:

  • SSD without its own power supply, it can be powered directly from USB
  • for a classic HDD, I recommend external power, especially on Raspberry Pi 2

NAS on Raspberry Pi crashes because USB puts the disk to sleep – disabling autosuspend + correct fstab + Samba safety net turns it into a stable NAS running for days without interruption.

Posted in EN - Linux Community ☺.

Leave a Reply

Your email address will not be published. Required fields are marked *