Debian Jessie USB drive problem

I recently bought a BBG for use as a tiny NAS and print server. I installed a Debian Jessie image (for BBB) and ran updates. All X stuff was removed to save space and Samba installed.

When I plug in the external USB disk it is recognised and /dev/sda1 appears. I added this to /etc/fstab:

UUID=F250C93950C904F7 /mnt/usbdrive ntfs-3g exec,noatime,nofail 0 0

This seems to work, the drive is mounted at boot time:

/dev/sda1 on /mnt/usbdrive type fuseblk (rw,noatime,user_id=0,group_id=0,allow_other,blksize=4096)

However, after a random period of time and without touching the USB bus, the drive suddenly switches to /dev/sdb1. This is while the drive is online and an IP camera is continuously recording to it. Needless to say, it all comes to a sudden halt, as /dev/sda1 disappears.

This must be something I am doing wrong. I have some experience running Linux systems as servers, but never had to deal with USB. I thought that perhaps the drive going to sleep when idle was a problem, so I hooked it up to my laptop and turned the sleep function off. It didn’t help.

Thanks for any light you may be able to shed on my problem.

Kind regards,
Peter.

What is the reason for the nofail option in /etc/fstab?

Any reason you can’t format the drive as ext4? I’ve seen articles claiming serious performance benefits for USB drives as ext4 instead of ntfs.

I’m doing similar on a Raspberry Pi2 with Jessie and have had no such issues, but I have a weird one in that the system immediately crashes back to “emergency” mode if I try to run it headless (no mouse/keyboard).

Is the USB drive powered separately or from the USB bus? It could be a power glitch issue as I don’t think the Beaglebones can supply a lot of USB power.

One more thing, since you are mounting by UUID why/how does the code writing to the drive “know” its sda1? As long as its mounted at /mnt/usbdrive it shouldn’t matter if its sda1 or sdb1. you could try mounting /dev/sda1 instead of UUID=. Have you verified that the usb/drive is really mounted at /mnt/usbdrive after it “switches” to /dev/sdb1?

What is the reason for the nofail option in /etc/fstab?

Without it the boot process hangs if the drive is not plugged in.

Any reason you can't format the drive as ext4?

I would have to buy another drive to backup the data first.
Performance is adequate, the bottleneck is the 100Mb/s ethernet i/f.

I'm doing similar on a Raspberry Pi2 with Jessie and have had no such issues, but I have a weird one in that the system immediately crashes back to "emergency" mode if I try to run it headless (no mouse/keyboard).

I don't know what emergency mode is. The BBG has no video output, so
it's always headless.

Is the USB drive powered separately or from the USB bus?

Yes, it has its own power brick. I have also a USB printer connected
to the same hub and it doesn't seem to have this problem.

One more thing, since you are mounting by UUID why/how does the code writing to the drive "know" its sda1? As long as its mounted at /mnt/usbdrive it shouldn't matter if its sda1 or sdb1. you could try mounting /dev/sda1 instead of UUID=. Have you verified that the usb/drive is really mounted at /mnt/usbdrive after it "switches" to /dev/sdb1?

It is because the uuid is nothing but a symlink:

root@beaglebone:/dev/disk/by-uuid# ls -l
total 0
lrwxrwxrwx 1 root root 10 Jun 8 10:35 F250C93950C904F7 -> ../../sda1
lrwxrwxrwx 1 root root 15 Jun 8 08:54
c1d24650-2c0c-4272-8762-56158468bbfb -> ../../mmcblk0p1

The only code using the device file is mount.ntfs (I think that is a
hard link to ntfs-3g). mount.ntfs runs as a background process,
keeping the device file locked. As far as the file system is
concerned, the drive stays mounted on /dev/usbdrive, but any attempt
to access it gives an I/O error.

I have been banging my head against a wall, trying to write a udev
rule. Then I realised that udev is not the problem: the /dev/sdx block
dev files are managed by the kernel. This means that even if I
uninstall udev, ntfs-3g and try to mount it as ntfs the kernel will
still change the dev files.

I have since found this topic:
http://www.nslu2-linux.org/wiki/FAQ/DealWithAutoSpinDownOnSeagateFreeAgent

I have connected the drive to my Windows laptop and used Seagate's s/w
to disable sleep mode. It can't be that, either.

My unix experience dates back to the days of floppy disks and parallel
ports. This has me stumped.

Thanks for trying to help, Wally.

Regards,
Peter.