Installing openwrt-18.06 on espressobin

My 300M I designated specifically as a travel router. Traveling around Latin America, it happens that many of the low budget hotels have wifi only in the lobby so I carry with me a PVC yagi connected to an ALFA AWUS036NHA 802.11n Wireless-N Wi-Fi USB Adapter High Speed Atheros AR9271 and I downloaded the driver for the AR9271 and it performs relatively well picking up distant signals for the 300M which rebroadcasts or repeats I guess I should say, into the hotel room. Many people say that the Alpha with the AR9271 and/or the driver is unstable as well but I've discovered that this adapter is power hungry and needs a 22 AWG USB cable and a powered USB hub and it seldom goes to sleep like it does when connected with typical 26 AWG USB cables and long ones at that.

Otherwise today was the first sunny day in many weeks so I had some outside work to do. Plus I ran 3 14 hour days in a row trying to get my brain around this EspressoBIN board which hasn't been easy, at least when tossing in the bad experience of this new recommended Alpha wifi adapter. So the shorter answer is I am taking a short break but that's because all this is overwhelming and each time I pull out OpenWRT, a console and start trying to load packages and do this and that, I have to learn it all over again, which is not-much by the way. I'll probably start again tomorrow. Thanks for checking by the way.

OK, I took a break due to insanity induced by Openwrit and the Alpha wi-fi card. I will work on that project another day (maybe).

I still would like to try to use this Espressobin card in some capacity so I am planning to add a drive to it so I can get some type of NFS up and working. At the moment all my components are stuffed in a plastic bag waiting for my patience to return. I need to start with acquiring a hard drive. Is a 6TB USB3 external USB drive OK?

What is the largest drive I can attach? I am thinking of a 6TB USB3 from Seagate or WD and partition it with Linux for exclusive use on the Espressobin making it the heart of a NFS. I'd like to choose if possible a fast file system that I can also access in an emergency using some type of tool or special driver on Windows should an emergency come up.

btrfs is really a good filesystem for this stuff. Especially useful is the snapshot features. For an emergency I'd recommend grabbing a bootable USB drive with a linux OS supporting btrfs on it so you can boot your windows machine to linux and copy the files in an emergency. Since it's just an emergency situation you don't need a day-to-day solution, though WinBTRFS exists...

Thank you! I am not well versed in Linux but can you tell me will there be any issues with using a 6TB USB3 drive on this Espressobin device? If there are no issues with using the drive, then are there any quirks I should be aware of when setting up a 6TB drive?

I doubt there would be issues. the main thing is to use a modern filesystem, btrfs will work well with large drives. The only thing to be aware of is you need to use a GPT type partition table. You can do that with parted or gdisk.

A 2017 post in the link, but is this still relevant? Didn't get a good feeling at Btrfs and I wonder if I'm not going bleeding edge again just for the pain that really won't help me much. BTRFS file system I don't really want all those levels of security and having to learn them and set them up. I want simply Windows-level micky mouse security on my network and then super security from the router blocking anything out of my server on the local network. Maybe I need to better outline my objectives ......

a) don't want to start a career in Linux, I simply want a small profile media server and Samba server running on this espressobin and new 6TB drive. I have all the parts spread out on the table but don't know where to begin. I finally managed getting the Espresobin booted up with an SD card so even that took a couple of weeks.

b) want to cheat, plagiarize or downright steel a step by step method of setting up this 6TB drive I just purchased as my network server. I would just use the NTFS system but the last time I tried to add a NTFS drive to a OpenWRT router, I think the write speed was about 2 bits per minute.

c) want to do a windows share only on my local LAN and start copying data from my only computer these days, a Windows 7 laptop and all the lifetime of media from other drives I have stored for decades over to this one new drive The server on the local LAN can even be anonomous if that would make things easier.

d) and once I get brave enough I want to set up a media server and try to access it with this new MiCool, Corelec and KODI that by some miracle I now have up and running only without any kind of data source yet

e) I want to totally block my network server from the outside world (WAN). Note that the espressobin will just be a device on my local LAN and not the router..

I would highly advice you to avoid f2fs, it's broken and buggy as it is right now.

The "best" options as far as file systems for storage goes are Btrfs, ext4 and ZFS/ZoL however the last not being available on OpenWrt right now. These are pretty much transparent in terms of "regular" usage however both Btrfs and ZFS/ZoL are considered more "robust" when it comes to failure. None of these filesystems are really "portable" to Windows as in attacing your drive natively but you can possibly get around this by using FUSE but don't count on it. As far as MacOS goes ext4 and ZFS are you best bets as both have either FUSE support or kernel modules although I don't know how well ZFS runs on MacOS. If you want the "best" compatibility with Windows exFAT is probably what you want to use however there are no filesystem tools available on OpenWrt so if you need to format or repair the file system you need to attach it to another system.

So, cutting it short my recommandation would to use snaphosts either the precompiled ones or compile your own.

If using snapshots:

  • Burn image to SD card (use ext4 variant as squash enforces f2fs, this can be overridden if you compile your own image)
  • Setup so the device has access to Internet unless you manually want to download all needed packages
  • Install the following packages (this should pull in all needed deps)
    fdisk, kmod-fs-btrfs, btrfs-progs, samba4-server, nano (optional), blockd (optional), nfs-kernel-server-utils, smartmontools (optional)
  • Partition the HDD using fdisk
    Optional: You might want to add a small swap partition as a precaution (1Gbyte will to more than enough)
  • Format it to btrfs
  • Set anon_swap and anon_mount to 1 in /etc/config/fstab
    Note: You can specify specific partitions but we're doing the lazy non tinfoil-hat approach using mount-block functionality, which requires the blockd package.
  • Setup Samba to share your storage partition
  • Export (NFS) your storage partition via /etc/exports
  • Done

Note NFS might be broken right now:

For USB wifi I think these packages will pull in everything you need:
kmod-mt76-usb, wpad

Thank you, I will start to work on it. Another criteria I have (which I forgot) is which FS is most tolerant to power drop outs. I will be killing the power to my media system when I don't need it to preserve battery life since I am running exclusively on battery and solar for charging. I plan to try the spin down tool as well and hopefully the drive will have spun down when the power is cut but you never know.

Don't use spindown tools, they do more harm than good. However, I would highly recommend you to properly power down (ie run halt) than just just kill it as you will run into file system corruption by not doing so irregardless of file system. You can easliy hack together a web page that will do this for you if you don't want to use ssh. You can possibly do a macro if you have a ssh client installed on your phone. I don't know if the espressobin has any buttons which you could map.

don't kill the power, shutdown properly. I can't say that enough. ssh in and execute shutdown so you can be sure. also ok to Cron shutdown at specific time then use a digital lamp timer to kill power in automated way. make sure you leave at least 3 mins between shutdown and power down to be sure

also btrfs is trivial, just format and mount.

Regarding creating a swap file, I just upgraded a laptop and removed a 128GB M.2 SATA memory card (has the B + M edge connectors). Can I add this via the following adapter:


and can I expect OpenWRT to support this memory?

And could I use then connect this adapter to the espressobin and use it for the boot and swap file?

I would expect the SATA adapter to work like a SATA drive. But I think the espressobin only has the one SATA connector, so I think you'll want to have the big 6TB drive on there. I'd just put all the boot and swap and data on separate partitions on the spinning disk drive. Keep things simple.

Yes, that would be the "sane" solution :slight_smile:

What's the opposite of a sane solution LOL? I was going to use the larger drive as external USB because I would conceivably remove it at some point in time to do file management or as a backup if something went awry with the espressobin. I've already purchased the big drive as external USB. Considering that, still no benefit to using a SSD for boot and swap?

Another thing to go wrong in my opinion. Not much benefit to be had.

Given that you only have one SATA port which it to be preferred over USB solutions any day of the week it makes little sense as you probably or at least preferably wont touch swap much at all. As @dlakelan mentioned it also adds more "unneeded" complexity, while the Espressobin is relatively fast it'll have very little use of the speed of a SSD compared to a HDD when during file sharing operations. The reason why I suggested a swap partition/file in the first place is because some operations can use quite a bit of memory temporarily.

Swap partition or file won't interfere even if you attach it to other systems.

Is Samba36-server what I am looking for (said samba4....) ???

****Looks like samba36-server on opktools is actually 3.6 so I am assuming you mean to use a more modern version but I don't know where that is located or how to side load packages.

I guess it still somewhat works (haven't used it in years and it's EoL) but you want to use Samba4 preferably. If you're on 18.06.X it should be still available. Package name is samba4-server

I see a OpenWrt samba4 version on Github but it is not in the OpenWrt package repository:

root@OpenWrt:~# opkg install samba4-server
Unknown package 'samba4-server'.
Collected errors:
 * opkg_install_cmd: Cannot install package samba4-server.
root@OpenWrt:~#

Also I added these packages:
opkg install block-mount e2fsprogs kmod-fs-ext4 kmod-usb-storage kmod-usb2 kmod-usb3

When I used this command I got this:

 -----------------------------------------------------
 OpenWrt 18.06.2, r7676-cddd7b4c77
 -----------------------------------------------------
root@OpenWrt:~# ls -al /dev/sd*
brw-------    1 root     root        8,   0 Jan  1  1970 /dev/sda
brw-------    1 root     root        8,   1 Jan  1  1970 /dev/sda1

So I have never used fdisk on Linux (only windows). How would I set up my USB drive like has been suggested here?

*** Update: I was able to use the fdisk -l command:

For more details see fdisk(8).
root@OpenWrt:~# fdisk -l
Disk /dev/mtdblock0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mmcblk0: 14.9 GiB, 15962472448 bytes, 31176704 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x15488508

Device         Boot Start    End Sectors   Size Id Type
/dev/mmcblk0p1 *     2048  35327   33280  16.3M 83 Linux
/dev/mmcblk0p2      36864 561663  524800 256.3M 83 Linux


Disk /dev/sda: 5.5 TiB, 6001140957184 bytes, 11720978432 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 365FDBBF-A67F-4B06-8899-191501B20E33

Device     Start         End     Sectors  Size Type
/dev/sda1   2048 11720976383 11720974336  5.5T Microsoft basic data
root@OpenWrt:~#

...this will wipe your HDD

fdisk pretty much works the same as on Windows/DOS
fdisk /dev/sda

  • Delete all partitions
  • Create a new GPT partition table
  • Add a new partition of 1Gb (or whatever you prefer) and use type 82 (82 labels it as swap)
  • Add another parition of the remaining space and use type 83 (labels it Linux (data))
  • Quit and write your changes to the HDD (w)
  • Format data partition mkfs.btrfs /dev/sda2 (just make sure that sda2 is your data partition first)
  • Done

If you enabled anon_swap and anon_mount OpenWrt will pick it up next reboot.