Search This Blog

Thursday, February 21, 2019

OpenBSD USB transfer speed woes, and a hack to get around that

One of the major problems with OpenBSD is how slow file transfers are to non-openbsd file systems. It has ports of various file system adapters, like ntfs-3g (which is based on FUSE) for reading/writing to NTFS formatted media. However, these have known speed issues that no one has bothered to fix yet.

As a test, I tried to copy files from the internal HDD to an external 8TB USB 3.0 HDD formatted NTFS. In Windows and various Linux distros, the sustained write speed is 70 MB/s+. In Openbsd, I plugged it into a confirmed usb 3 port (usbdevs -v), mounted it with ntfs-3g /dev/sd2j /mnt/usb1, and then tried to copy a large (>1GB) file to it with cp or rsync. Rsync has a progress option which shows write speeds. cp wasn't much if any faster. I couldn't get over 2.2 MB/s write speed with a USB 3.0 port, or over 1.6 MB/s with a USB 2.0 port. I tried the ntfs-3g mount options noatime and big_writes, but they had no affect on write speed. Openbsd's port doesn't have an async option. I also tried a USB 3.0 flash drive, also formatted NTFS, that can get higher write speeds than the external HDD in Windows, but it's even slower on the Openbsd laptop.

From what I've read online, there's literally nothing you can do unless you feel like re-writing ntfs-3g or something like that.

I found a hack around this limitation. I setup a ftp server (ftpd) on the openbsd computer and added the following pf firewall rules in an anchor:

pass in on $ext_if proto tcp from $lan_net to port 21
pass in on $ext_if proto tcp from $lan_net to port > 49151

I then enabled and started the ftpd service. I connected the USB HDD to my Windows machine (on same LAN as the openbsd computer), and did "add network location" in windows, ftp://xxx.xxx.xxx.xxx (IP of my openbsd computer) and logged in with the user account on the openbsd computer. This allowed me to browse files on the openbsd computer. I copied (ctrl+c ctrl+v) a large (>1GB) file from the openbsd computer to the usb hdd. Interestingly, window's transfer time estimate was too long...calculating speed from that, it was estimating ~2 MB/s. However, the actual average transfer speed was ~8.5MB/s. Thus, it's about 4x faster to transfer files from openbsd->FTP->Windows->USB HDD than openbsd->USB HDD. I didn't attempt any ways to speed this up, and the openbsd laptop's network adapter is limited to 100Mbps, so it might be possible to get higher transfer speeds.

Update: Hit ~13 MiB/s (12 continuous) running 2 file transfers with the filezilla client in windows. That's right at the upper limit of the 100 Mbit/s ethernet port on the openbsd machine. It could probably handle much faster with a gigabit connection.

If the X windows system didn't convince me, this example really showcases why openbsd is meant to be a server OS, and not a personal computer OS.

No comments:

Post a Comment