Porridge from an ax or NAS based on Asus RT-N56U

image
In short, what happened:
  • ADSL 2+ Internet Connection
  • Two home WiFi 802.11g / n networks - 2.4Ghz and 5Ghz with a speed of more than 100 megabits / s
  • Gigabit cable connection
  • 6TB NAS, in the form of four 2 x 2TB and 2 x 1TB disks with an autonomous torrent client
  • SMB / CIFS server with stable write / read speed of 12-14 megabytes / s
  • NFS server with write / read speed of 9-10 or 15-18 megabytes / s (TCP / Windows or UDP / Linux)
  • UPNP / DLNA server with a reading speed of 8-10 megabytes / s
  • 46-inch LED TV with built-in WiFi 802.11n, capable of working with network storage and itself capable of distributing content via SMB / CIFS from your USB drive
  • Old 42-inch TV with a connected BD player with Ethernet and DLNA support, working with network storage
  • 4 home computers, including Macs and 4 mobile phones that work with all of the above, including mobile servers and DLNA clients

Who cares what rake I stepped on, why there is a pillow and how it all works, I ask for a cat.

Background


For many years in a row, I never really thought about my home network. About eight years ago, a dude from an Internet provider came to me and stuck a modem with a built-in WiFi access point in the ADSL telephone jack. Then he wrote me a long WEP password and left so that he would never remind himself of himself again. But the box remained:
So that it would not get underfoot, I threw it on a cabinet in the corridor, threw a network cable from it to my workplace and safely forgot about it. After some time, devices requiring WiFi began to appear. Therefore, I had to open the modem, change it to a new firmware, rename the network, change WEP to WPA, and so on. However, nothing significant has changed topologically and technologically.
I must say that for several years, like most, I have accumulated a bunch of all kinds of computer junk, including several external USB drives ranging in size from 160GB to 3TB, where I merged everything “acquired by overwork”. If you are not a pedant and not complete neat, then I will understand. There were tons of family photos, videos, lots of movies and music downloaded from the Internet, software, databases, and the like. At some point, it became quite annoying, because all this information was spread evenly between different media, computers, cameras, video cameras, phone memory cards and it was hard enough to say where, what and how is located. For the same reason, deleting anything from some medium at some point in time was very dumb, because without checking the remaining ten it was impossible to understand is there a backup or not. But it didn’t even begin with this ...
It all started when my wife and child went on vacation and I dragged an old TV and a simple BD player with a USB port into my bedroom to watch movies in the evenings before bedtime, without getting out of bed. Out of habit, I dragged my 500-gigabyte external USB drive with movies between a laptop, a new TV and a bedroom, until I found an Ethernet port in the player. And then I remembered about my “home network”. But the network was mostly wireless and Ethernet was not suitable for this role, and I did not have the required length of the network cable.
So I blew the dust off a gifted horse called D-Link DIR-300 , I flashed it DD-WRT (another story as I did for HW revision A1), put it in Client Bridge mode, connected it and after some time I could already watch movies from my laptop via the network using the built-in DLNA client in the player.
As usual, several problems arose from one problem. Since the network hardware was older than my child and the maximum could only work with 802.11g, then movies with a high bit rate (not to mention HD) were simply not chewed by them. Another problem was that using your laptop as a DLNA server was not a good idea for various reasons. Well, in addition, all this did not save me a dozen flash drives and external drives, with all that it implies.
So I was ripe for the purchase of a mega-device that would improve everything at once - both network speed and connection to TVs, and I solved the problem with a bunch of different carriers.

Router


Thoughts on the topic of mega-device brought me to a store where, like a ram, I stood in front of a long shelf with routers, access points, modems, etc. I needed something that could work as a modem, understand 802.11n and have a USB port. But most of what is available met my unpretentious requirements. Therefore, I surfed the Internet and after some time settled on the Asus RT-N56U , for 90 euros. There were models more powerful and smarter, but more expensive. Maybe someone needs some kind of 802.11ac at 450 megabits with ten antennas, a built-in SATA 6Gb interface and a touch info panel (there were some), but from my budget point of view, Asus for 90 euros fit perfectly.
Yes, I decided to give a damn about the built-in DSL modem. Common sense told me that on ADSL I still would not get more than 48 Mbit. And the Internet said that a community of firmware like DD-WRT or OpenWRT with DSL support is almost unrealistic. And something there called "intuition" said that for my purposes, most likely I would have to mess with WRT / Optware. In short, I spat and put the old Zyxel into bridge mode, chopped off his WiFi and forgot about it, like a few years ago.
Regarding the drives, I stupidly took the two largest ones that I had - 3TB and 1TB. Потом, подумав, я купил еще один пользованный 3х терабайтник на местном аукционе за очень смешные деньги и воткнул его в старую SATA<->USB коробку. And he put the whole thing together to look and think what to do next:

image

Common sense told me again that it would be better to buy a separate NAS and I agreed with him. But there was no money and desire to go to the store again, so I postponed the purchase of NAS indefinitely. Yes, yes, I completely agree that individually Modem + Router + NAS is always better than all in one, and three heads are better than one (or two). However, my feet were already itching to walk on a rake and I went.

3TB Rake


First of all, I changed the firmware on the router. I took the newgui firmware from Padavan and easily and simply flashed it. NEWGUI it just means that there are old and new web interfaces. Since I never saw the old, I did not bother.
Then I connected via wire to the router and stuck a 3TB disk into it. And the disk showed up! And it all seemed to work. I tried to drive the files back and forth and what I saw did not please me. The first rake happened . The speed was no more than 2 megabytes / s. Therefore, I had to climb into the router logs. The logs told me that:
a) Although the total disk space is 2794.517 GB, it’s free -416.321GB (just like that, with a minus sign)
b) Some software in the router periodically could not read blocks with an index above some value.
The above described led me to think of a 2TB limit. So I sat down to split the disk into two sections. Since there was already information on the disk, I decided not to change the NTFS file system on it. Then the second rake happened .
After I resized the partition to the minimum possible, while saving the data, Windows 7 drew an oil picture for me:

image

I hardly imagined how to work with two Unallocated partitions, so having unsuccessfully tormented myself with Diskpart and trying to degenerate something in GPT (which, as it turned out in Diskpart, does not work with external disks), I gave up. And then I went to dig towards converting the disk to Ext3, which turned out to be fundamentally wrong.
In order to dot, I will indent and write this. Despite the opinion of the majority of advisers from the forum on iXBT, I did not install Ext3. I don’t have a single Linux computer at home, and the likelihood that you will have to disconnect external drives from the router at some point and connect to the computer is very high (yes, I know about the Ext2FS driver, but ...). Therefore, in the end, I returned to NTFS and I see no difference, to be honest, on the contrary. For some reason, the speed of writing and reading in NTFS is even slightly higher than Ext3, I do not know what this is connected with.
The rake with partitions was fixed using Paragon Hard Disk Manager 11 , which without any problems created two partitions for me, 2TB and 1TB, and in my opinion even without GPT. Be that as it may, here happened third rake .
Both Windows and MacOS saw both sections perfectly, but not the router. So I started smoking Ext3 again in different combinations until I saw that both sections are Primary. Remembering my youth and MS-DOS, I created the second partition as Extended and already made a second disk in it, as in the good old days. Paragon HDM allowed it and it worked!
In the web interface of the router, it all looks something like this:
In this example, we used a 3TB drive with two partitions and a 1TB drive, but I assure you that 2 3TB drives work absolutely adequately.

Intermediate conclusions:

- In the case of the Asus RT-N56U with firmware 1.1.2.2-006 from Padavan , the largest partition size on the attached USB drive is 2Tb.
- If the disk is larger than 2TB, then it must be split into two using Primary and Extended partitions.

UPD: I don’t know what the rake was, but two Primary partitions on the external drive eventually worked, so Extended is optional.

- Standard utilities in Windows 7 carry a lot of hemorrhoids for USB drives larger than 2 TB, so it’s better to use Paragon Hard Disk Manager

Rake with miniDLNA


Since I needed DLNA to watch movies on TVs and a player, the Padavan firmware seemed like some kind of miracle in which there was everything at once. It is worth noting that I turned on DLNA support immediately after the firmware and as long as I was engaged in other rakes, I did not touch it. It looked like this:
Remember the first rake ? So, when I turned off UPnP Media Server, the write and read speeds instantly jumped from 2 to 12-13 megabytes / s! However, the prospect did not please me. Either I have SMB with a more or less normal speed, or DLNA support.
Experts from the iXBT forum again said their "fi" about NTFS and the fact that now it is absolutely necessary to install Ext3. And I even believed them at some point. Because a virgin blank disk with Ext3 really worked without problems with miniDLNA turned on. But as soon as I rolled my honestly stupid films from the Internet on him, at some point he dropped the speed up to 2 megabytes / s. And I started smoking the terminal.
Frankly, I'm not very friendly with Linux, but some basic knowledge has remained since the time when I ported XML libraries to embedded QNX. The router is miniDLNA developed by NetGear under the name ReadyNAS. A simple experiment showed that the speed of file transfer over the network drops only at the moment when miniDLNA parses metadata from video / audio / pictures. This is also easy to see in the web interface, as the processor is loaded at 100%.
It also turned out that miniDLNA holds all its parsed data in the /.dms/files.db file, which is nothing but a SQLite database. Again, it was experimentally found that miniDLNA parses less than half of the files and then leaves in the astral, forever loading the processor to 100%. Through the database viewer, I found the last parsed file, after which the process paused and deleted the next file after it by typing. And it all worked!
It turned out to be a specific AVI file, which apparently suspends the miniDLNA parser. Well, nothing concrete can be advised besides the fact that if suddenly the time for parsing metadata approaches infinity, then you need to look inside /.dms/files.db for the subject of “hanging”. Which file hangs miniDLNA? And the next one in the file system, after the last entry in the “PATH” column, is the “OBJECTS” table. In addition, the parsing process can be observed from a web browser by going to the address: http: //my.router: 8200 . This produces information of the form:
MiniDLNA status
Audio files: 329
Video files: 781
Image files: 17221

If miniDLNA does not freeze, then the numbers will change when the page is refreshed at a speed of about once every 3-5 seconds (depending on the size of the file that is being parsed), but if it freezes, they won’t.
Well, the gad file has been eliminated, and everything seems to have gone. But here we get acquainted with the fourth rake . This rake is called - why the heck is so much garbage to me in DLNA?
Here's the thing. By default, the point at which the file search for miniDLNA begins is / media. All disks are mounted there in the form AiDisk_xY, where x is the number of the physical disk and Y is the logical one. Accordingly, the "Media File Source Path" initially causes miniDLNA to parse absolutely all your disks. As you might guess, in the end, everything falls there that I would not want to share on the whole apartment. For example, covers from audio books, audio books themselves, unpacked graphic resources from programs, porn, photos from a drunkard and all other garbage that is recognized by the parser as audio / video.
To fix this rake, I personally made one folder on the very first disk and changed the default path, in my case to / media / AiDisk_a1 / Media. ­­ There are more advanced paths, such as fixing the miniDLNA configuration file in /etc/minidlna.conf, but I honestly did not want to mess around, so I just put everything on DLNA into one folder in the root of the disk. Two questions are brewing:
And if there are several folders on different disks? Then you have a direct road to minidlna.conf.
Why / AiDisk_a1? Because the first disk connected to the first USB port will always get exactly that name and index. The second partition on the same physical disk, for example, gets the identifier / AiDisk_a5 for me. I don’t know why this is happening, maybe there are more intelligent people who can explain this. Again, the first drive in the second USB port will receive the identifier / AiDisk_b1, so options are possible.

UPD: Smart people were found. Quote from un_def : “The first four digits are reserved for the main sections, and the logical numbering always starts with five.” .

Intermediate conclusions:

- If the file data transfer speed dropped sharply when UPnP Media Server was turned on, the router processor is constantly 100% loaded and media parsing is in place (see progress at http: //my.router: 8200 ), then this hangs up miniDLNA. It is necessary to turn off the UPnP server, throw out the file on which the parser hangs and start the server again.
- By default, miniDLNA will parse all files on all available disks and partitions. This is a fairly long process. Therefore, if you want to limit it to one folder, change the “Media Files Source Path” in the UPnP Media Server settings.

Rake with Samba


While I was struggling with the first rake , I managed to reconsider my approach to watching movies on TV. The first thing I thought about was this. DLNA loads the router 100% with all the consequences. But without DLNA, SMB remains and if you want NFS. Is it possible to somehow connect your disks over the network, exactly the same external USB drive? It turned out you can. It's no secret that most modern TVs are spinning under Linux. And it is no secret that enthusiasts have found a way for some of them to gallop, steal and put there what they like. Fortunately for me, I turned out to be the TV of that particular brand over which a community called SamyGO is working hard . So, I sat down picking my Samsung UE46D7000 .
Omitting unnecessary details, it turned out that my latest firmware was installed on my TV, in which the local exploit needed for the SamyGO package to work does not work. Samsung also does not work fools and track the path of unauthorized changes and interference in the work of their official firmware. In addition, as in most household devices, the ability to roll back to the old firmware version in CE (Customer Edition) versions of these is disabled. It would be a good idea, but the guys from SamyGO have found a way to roll back by spoofing and emulating the official Samsung firmware server.
Following the instructions, I rolled back to the old version and following the other instructions put SamyGO. He didn’t seem to be okay. Exhaled.
Briefly about how the SMB and NFS client work in Samsung TVs (more precisely in SamyGO). SamyGO installs the driver of the virtual USB drive, and already under it emulates the file system using network resources. Therefore, from the point of view of the user, everything looks exactly the same as if you connected a regular USB flash drive or external drive. From the point of view of settings, everything is more complicated, but not so much so. You just need to substitute your parameters in the scripts from init.d /, then we smoothly drove into the fifth rake . But all in order.
So we installed SamyGO, activated it, and we can safely go via FTP to our TV. Depending on the model init.d / scripts may be located in different directories. In my case, they are located at ftp: //192.168.Moy.TV/mtd_rwcommon/widgets/user/SamyGO/SamyGO/etc/init.d/.
Three files are of most interest to us:
03_03_djmount.init
03_03_nfsmount.init
04_04_samba.init.dis
The first one is a file system emulator based on UPnP / DLNA. By default, it is enabled. But my TV already has a built-in DLNA client that does not require SamyGO or dancing with a tambourine, so we turn it off by renaming it to 03_03_djmount.init.dis.
The second is an NFS based emulator. We will come back to him later.
And finally, here she is, the fish of my dreams. A disk emulator based on SMB / CIFS or later for simplicity, Samba. First you need to make the script executable by renaming it from 04_04_samba.init.dis to 04_04_samba.init.
In theory, this is enough for the emulator to show us all the nodes and balls,
but it’s not for nothing that I wrote about a rake - it doesn’t show either the server or the balls. We wonder, “why?” We smoke inside the script 04_04_samba.init:
...
##### CHANGE MEEEEE !!! ######
USER = ""
PASSWD = ""
PERM = "rw" # can be ro or rw
##### CHANGE MEEEEE END ######
SERVER = ""
# SERVER = "10.0.0.1" # if you want a fixed server
SHARES = ""
FR_NAME = "Samba Server"
...
Obviously, it would be necessary to fill Fields USER, PASSWD and SERVER / SHARES would be nice not to get confused in any Windows NETBIOS and HomeGroup resources that are usually found in home computers (and I have 4 of them). However, this is the ambush. Nothing to fill in USER / PASSWD. I don’t have a password for Samba on the router, well, I didn’t set it, nafig. Without a password it does not work, with an empty password too.
As a result, I was not able to get the Samba SamyGO client to work in the event of a complete absence of USER / PASSWD. Can someone tell me how to do this?

UPD : They suggested that see below in the intermediate outputs, you must specify USER = "guest", the password is empty.

Well, let's try with a password. Asus RT-N56U offers such an interface for controlling Samba balls:
By default, I set full access without an account. In the Windows network client, it looks like this:
Now let's try switching to an account with a password. We start the user and see something like this:
With the naked eye you can see that there is an account and it is possible to assign any read-write permissions to the first-level directories. And what is happening here in Windows? And here is what:

image

Oppa! Disks disappeared, first-level catalogs came out in their place, and collected from all disks at once. Note that folders with the same name on different drives are supplemented by a number in brackets. This is entirely justified, given the above logic of the router for access rights, but for me personally it is inconvenient. However, there is one plus - SamyGO now works!
Since it is easier for me to work with the entire network drive from under Windows than with a dozen individual folders, the only option for me in this configuration is to transfer all the root folders to one that will be shared with the password for the accounts. Perhaps I will do so later, but so far I don’t really want to mess with this. We smoke further towards NFS:
And with NFS everything is even very simple, take the script 03_03_nfsmount.init:
...
##### YOU CAN CHANGE ME HERE ######
SERVER = ""
# SERVER = "10.0.0.1" # if you want a fixed server
SHARES = ""
# SHARES = "Video Music Photo" # if you won't all your shares, but then set SERVER too !!!
##### CHANGE ME END ######
...
We register the IP address of our router in SERVER. You can stop here, but as I already mentioned, I don’t really like the idea of ​​making all discs available on the TV accessible, so I limit SHARES to one folder: SHARES = "/ media / AiDisk_a1 / Media". Another point. Since NFS can work not only over TCP but also over UDP, and for reading the video stream that we are going to watch on the TV, the retransmission is not as relevant as for example when recording (that is, if some packet disappears during transmission, then figs with it ), then we will add such options here:
M_OPTS = "soft, udp, async, nolock, rsize = 32768, wsize = 8192"
In other words, we will work over UDP, with an asynchronous cache and make the read buffer larger. I haven’t measured it exactly yet, there is no Linux machine, but with these parameters, the read speed approaches 15-18 megabytes / s, which allows us to play HD 1080p over the network without problems. We start, everything works:
It seems there is no rake. We turn off the samba on the telly as unnecessary. On the router, we return back access without a password and account.

Intermediate conclusions:

- Asus RT-N56U with firmware 1.1.2.2-006 from Padavan, by default, shares entire disks without a password and account. It’s not very clear how to configure the SMB / CIFS client in SamyGO so that it works with such balls. An empty username and password in the configuration file, as well as the absence of these parameters do not help.
- Samsung TV works fine with miniDLNA on the router through an integrated client called AllShare.
- If miniDLNA / AllShare does not suit you, or there is no built-in DLNA client and you want to dig deeper into the giblets of the TV, then install SamyGO and connect network drives via a USB emulator.
- The scripts SamyGo UPnP (djmount) and NFS (nfsmount) with a router work without visible problems.
- SamyGO SMB client works without problems only if access to the router with account and password is set.

UPD: Answer from the author of the firmware: "... I’ll immediately answer him about the Samba problem of passwordless access from Linux devices (for example, from a TV with SamyGO firmware). On the client, you need to specify the user name guest, the password is empty ..." Thanks again Padavan!

Rake with noise


As already mentioned, setting up NFS on the TV, I then repaired the miniDLNA on the router. Therefore, I don’t know why I need SamyGO and NFS, but maybe I have not stepped on some sort of rake, such as the incompatibility of codecs that are very common in DLNA, judging by the noise.
Yes, about the noise. So the moment came when everything worked wonderfully for me, two 3TB drives were connected and the whole thing was pushed back to a large and tall cabinet in the corridor:

image

Remember the pillow mentioned at the very beginning of the post? So, both external disks, when placed on a solid wooden surface, make such an unpleasant hum due to natural vibration. I don’t know how anyone, but it annoys me very much. Since my daughter grew up and uses bedding of a completely grown size, I adapted her “Lala” pillow as a vibration damper. Stupidly put the wheels on it and the rumble disappeared. The aesthetic aspect is of little concern to me, because the cabinet is more than two meters high and nothing is visible from below.

Rake with built-in torrent client


But not them. The built-in client uses Transmission daemon. Again, the community strongly advises using Ext3 as the file system for it. I do not presume to say anything, but everything works fine for me on NTFS.
In order to configure Transmission, you need to create an empty directory with the name “transmission” on the first disk in the root and enable the client on the router:
And that’s it. Well, to feel the fullness of the picture, you must of course put what will be controlled by it, that is, the Transmission Remote application:

image

All that it downloads, look for on the disk in the directory / transmission / downloads. Since the client works autonomously and after downloading it doesn’t leave the distribution, do not forget to set speed limits, because without restrictions the router may well clog all traffic in both directions.

Conclusion


At the end, a couple of screenshots with numbers:
Record on Samba:
Read on Samba:
Asus RT-N56U is quite popular and revered piece of iron and those who wish can dig up a lot of information on it on the iXBT forum . Information on the SamyGO project to expand the minds of Samsung TVs is on the community website .

Special thanks to Padavan for the cool firmware and for using it I didn’t have to tinker with Optware and thanks juriz28 for the great work on SamyGO.

P.S. Про запись телепрограмм с телевизора на сетевые диски и про расшаривание дисков телевизора напишу как нибудь потом. This has little to do directly with this router and network drives ...