Vsftpd notes, ftp transfer speed? USB flash write speed?

Just wanted to post some notes regarding setting up vsftpd on my recently-flashed LEDE router (wr1043nd v. 2) and ask a couple of questions. Thus, this thread.

First, a description of the task. Since my router, which acts as gateway and DHCP server for my LAN, has a USB port, and since I recently found a 16GB USB drive, I decided I should set up the router to act as an ftp server for my little LAN, using the USB drive as the file repository. So I formatted the drive ext4, stuck it into the router's USB port and rebooted, checking to ensure the USB drive had been found and mounted: it was found and got mounted at /dev/sda1. So I loaded the vsftpd package onto the router and set about configuring it.

My aim was to have the ftp server available only to LAN clients, and to allow anonymous logins that would include permissions to both read and write. It was a bit of a challenge to get things set up for that. Though it now works pretty closely to how I'd hoped it would, there is a slight hitch: on logging in to ftp, I have to stipulate, in addition to the IP, the path to a directory that has the needed read/write permissions, since the ftp server will not dump me into that directory on log-in if I stipulate only the IP (think this is related to chrooting, which vsftp uses for security, as explained at

In any case, after appropriately editing /etc/vsftpd.conf, discovering that I'd need to create a sub-directory with the needed read/write permissions as well as stipulating the path to that directory (after the fashion ftp -p, I was able to conduct some reading and writing tests. Those worked fine, although deleting files as an anonymous user was not working. Further searching turned up another option I could place in the configuration file which, after being added, resulted in anonymous users being able to delete files also.

What I believe are the salient portions of my currently-working vsftpd.conf file look as follows:

ftpd_banner=Welcome to my FTP service.
anon_other_write_enable=YES #added to allow anonymous user to delete files

Now, to some testing questions. I created a 100mb file for copying over ftp to the USB drive connected to the router. From a machine on my LAN that hooks to the router by a 20' ethernet cable, it takes about 25 seconds for that file to copy to the USB drive hooked to the router. While I don't foresee that speed causing me problems, it does seem a lot slower than I'd expected: it's much slower than both rated optimal speed for gigabit networks as well being quite a bit slower than optimal write-speed ratings for USB 2 devices (the drive is a USB 2 flash drive). I did repurpose a pretty old cat5 cable for this project and have wondered whether that could affect the ftp transfer speed. My reading indicates that should slow things down a little. Any input here on whether a an ftp transfer speed of 4 megabytes per second seems exceptionally slow under the scenario described? Thanks

1 Like

I think you're confusing megabytes per second with megabits per second...

USB 2.0 is much slower than USB 3.0, so not a good choice for running an FTP server, unless it's just for your own private LAN.

Otherwise, you would be better off purchasing NAS.

See this article on troubleshooting slow FTP speed...

I admit to being a pretty lousy mathematician and to not understanding very well the megabytes/megabits distinction. So I could well be suffering under some fundamental confusions. But under the conditions I described, taking out of the equation for the moment the disk write speed, how long should it take on a network such as that described (gigabit network connections and a 20 foot cable), to transfer a 100 MB file?

If I'm reading correctly information contained at the article at http://news.jpy.com/kbase/support-articles/2015/9/7/calculating-network-data-transfer-speeds and if the information there is trustworthy, the speed I've seen so far in my tests (4 megabytes per second) is about half what I should be expecting to see--not on a gigabit network--but on a 100mb/s network. On a gigabit network, it looks from that article as though the transfer speed should be getting up toward 100 megabytes per second.

As to the USB 2.0 thumb drive, according to this article https://www.pcworld.com/article/2360306/usb-3-0-speed-real-and-imagined.html it might be capable of a write speed as high as 40 megabytes per second though it might lower. The USB drive could certainly be a bottleneck on a transfer getting anywhere near the 100 megabyte per second capability such as this network could be theoretically capable of attaining. But certainly the USB write speed would not be 10 times lower than the rather generous 40 megabyte per second quoted in that article, thus being the source of the 4 megabyte per second write speed I've seen here, would it?

the bottleneck is the router. it isnt made for high speed data transfers via usb.

1 Like

Add to that the USB thumb drive itself.

The type of flash memory and controller factors in to how fast it can read/write data, and can vary widely among manufacturers.

1 Like

Test each part separately.

  1. Start be testing the read and write speed of the USB drive when it is connected to your PC directly. Your PC is going to be able to max out the speed the drive more easily than the router.

  2. Then setup your ftp server to an anon root of /tmp and and test uploading (write) and downloading (read) a file there that doesn't exceed the available memory ( leave some spare ) .

Then compare with your earlier results.

But both @rj-45 and @jwoods are correct, don't expect a router to perform at the speed of dedicated NAS.

1 Like

Thanks for the input here. I'm not really looking to set up a NAS and, like I said, I can live with the quite paltry speeds I've reported from my initial tests. Of more concern to me is whether the unusually low speeds I seem to be seeing might be indicative of some misconfiguration. Everything works as it's supposed to from what I can see so far, except that file transfer speed is lower than I'd expect it to be. If it's unlikely that is because of some misconfiguration, I'll probably just live with it. Though it would be interesting to test separate components as suggested to see whether any hardware bottlenecks might be discovered. Someday when I'm bored and have nothing else to do I may follow up on that.

Re-read the posts by @rj-45 and myself...those are the reasons.

If you think access over the LAN is bad, wait until someone tries to use it remotely.

If you do get a NAS, do your due diligence and understand what you're getting (diskless means you provide the drives for the NAS cabinet).

Also, understand the security implications of exposing a NAS device to the outside world.

If you want to test the speed of the USB from the router directly you can do this from a SSH session

My Results

Writing 100MB = 21secs
Reading 100MB = 5secs

Log of test using USB2 Portable HDD.

root@LEDE:/mnt/sda1# cd /mnt/sda1/
root@LEDE:/mnt/sda1# time dd if=/dev/zero of=testfile count=200k
204800+0 records in
204800+0 records out
real    0m 21.15s
user    0m 1.42s
sys     0m 16.76s
root@LEDE:/mnt/sda1# time dd if=testfile of=/dev/null count=200k
204800+0 records in
204800+0 records out
real    0m 4.96s
user    0m 0.82s
sys     0m 3.22s
root@LEDE:/mnt/sda1# ls -lh
-rw-r--r--    1 root     root      100.0M Mar  3 17:51 testfile

Note: count=200k, is 100MB for me adjust as necessary

And that was without any overhead using FTP, so...

Yes, I was trying to demonstrate that USB2 is no speed demon. Plus 20% overhead for FTP test it seems

The other reason is in efficient use of block size, the default block size is too small ( 512 bytes)
On my USB2 HDD test , the optimal block size is 8K. Using 8K blocks doubled the write speed , 10.7MB/sec. I'm not sure how to configure block size under LEDE or vsftpd, but this test explains why your only getting half the expected speed.

root@LEDE:/mnt/sda1#  time dd if=/dev/zero of=testfile count=25k bs=4k
25600+0 records in
25600+0 records out
real    0m 9.73s
user    0m 0.30s
sys     0m 6.46s

root@LEDE:/mnt/sda1# ls -lh 
-rw-r--r--    1 root     root      104.0M Mar  3 18:50 testfile

Once you find an optimal block size try reformatting using mke2fs with -b option

root@LEDE:/mnt/sda1# mke2fs
Usage: mke2fs [-c|-l filename] [-b block-size] [-C cluster-size]
        [-i bytes-per-inode] [-I inode-size] [-J journal-options]
        [-G flex-group-size] [-N number-of-inodes] [-d root-directory]
        [-m reserved-blocks-percentage] [-o creator-os]
        [-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
        [-O feature[,...]] [-r fs-revision] [-E extended-option[,...]]
        [-t fs-type] [-T usage-type ] [-U UUID] [-e errors_behavior][-z undo_file]
        [-jnqvDFSV] device [blocks-count]

Had to adapt the path of the ftp user in /etc/passwd to get the anomymous login going.
Lede 17.01.4

1 Like