Table of Contents

Home NAS

NAS (Network Attached Storage) can be used to share data with the entire home network. You can have your multimedia data saved on it and access them from anywhere – through the home multimedia center, from any computer within the network, but also from a tablet or other mobile devices.

If you decide to set up the home NAS, Turris will play the role of the server. This naturally means that a data storage device has to be connected to the router. (The internal storage is for one too small for being able to share a reasonable amount of data and it is also not in the interest of the user to overload the flash storage, because of its durability.) Turris Omnia has 2 USB connectors (one in the back and one in front) and it is possible to connect a flash disk to it or an external drive with any given storage size.

Setting up the NAS

Creating a home NAS requires the following steps:

Mounting the drive

There is an exception for disks which are formated as NTFS, which you can read about in the next passage. Despite this, you will also find a lot of relevant information in this chapter and so it is recommended to also go through it.

You first need to “mount” the attached drive, that is to tell the operating system, which directory it should attach the contents of the drive to.

For the following method, we assume that you know the name or UUID of your drive and the type of the file system, which it is formated to.

Advice for beginners

For the next step you will need to know, which drive and partition you are looking for. If you have no idea what to do in this situation, it's hard to give one specific piece of advice. Nevertheless:

The Linux OS uses the following indicators: sda is the first attached drive, sdb is the second attached drive and so on. The first partition on the first drive will be called sda1, the second sda2 and so on.

It is important in which order you connect the drives. If you connect two devices, it is not possible to garantee that a given drive will carry the same name after a complete reboot.

The solution is easy, if you are connecting a single drive, which contains only one partition – in that case you will use sda1 for the following configuration.

Advice for beginners II. – File system

A file system is a method, which physically saves files to the drive. There are several types, which are characteristic of the Windows OS, some apply to Linux OS and some are considered transferable. Flash drives are usually formated to FAT32, big flash drives sometimes to NTFS and external harddrives usually to NTFS.

You can find out which file system you are dealing with with the help of the program blkid, which is described in the following box. You can also try to connect the drive to your computer – most file managers provide the information about its type – for example by having a look at properties.

UUID

Because the names of disks can sometimes be ambiguous, as was described above, it is wiser to use UUID, which are obtainable with the use of blkid.

You will need SSH access to the router. It is enough to write the command and you will find out about the required identificators. The whole process can look for example like this:

root@turris:~# blkid 
/dev/sda1: UUID="1F66D63324CF371C" TYPE="ntfs" 
/dev/sda2: UUID="DA22-0AA1" TYPE="vfat" 
/dev/sda3: UUID="1c200843-7db6-4e38-aa20-e5409c989125" TYPE="ext4" 
/dev/sda4: UUID="bbbba732-20e3-4634-8511-d2f20e4bac46" SEC_TYPE="ext2" TYPE="ext3" 
root@turris:~#

Mounting the drive can be done in the adminitration interface LuCI in the tab System / Mount Points. There you can see two tables:

Now, by clicking Add we will add a new mount point. In the form, which appears:

It is standard to mount all devices to the directory /mnt.

Shares settings

Network Shares can be set in the tab Services / Network Shares.

Basic Settings:

Now it's time to set up the shares.

In the table Shared directories click the button Add. Available fields have the following functions:

Idle regime

During normal home regime, the drive does not need to run constantly. Hd-idle serves to allow the disk do go into idle mode during times of inactivity.

It can be set up under the tab Services / hd-idle. On this page, by checking Allow, you allow control of the mounted drive Disk. The time, after which the drive may go into idle, can be set according to your needs. The default value is 10 minutes.

Enabling services

It is necessary to enable and activate, the services hd-idle and samba.

An overview of services available for the router can be found in the tab System / Startup. The name of the service can be found in the column Initscript, if one of the services is not enabled, clicking Disabled will enable it. Clicking Start will activate the service you have just enabled.

Setting up the Home NAS with an NTFS disk

Using a drive, which is formatted to NTFS (the default format, for most external drives and also the main file system for Windows OS) is a little more complicated, because of an error in the kernel module, which the developers of OpenWRT (that is the system, which the Turris firmware is based on) haven't fixed yet.

The main problem is that the kernel module ntfs is not capable of mounting the disk. This job can be done by the program ntfs-3g, which you will find in your router, but which doesn't have an configuration interface, so you have to write your own initscript for it – one could say that you have to write your own service.

For the next steps, you will have to know the name of your drive – the notes from section Mounting the drive apply, just leave out the actual settings in the tab System / Mount points.

Also the sections Shares settings, Idle regime and Enabling services apply here.

Now let's write our own service. That is the so called initscript, which is basically a regular text file, which is placed in the directory /etc/init.d. Connect to your router through SSH and go through the following steps:

mkdir /mnt/nas
cd /etc/init.d/
cat > nas <<EOF
#!/bin/sh /etc/rc.common

START=99
STOP=99

start() {
	ntfs-3g /dev/sda1 /mnt/nas
}

stop() {
	umount /mnt/nas
	hd-idle -t sda
}
EOF
chmod +x nas
/etc/init.d/nas enable
root@turris:/tmp# ls -l /etc/rc.d/S99nas 
lrwxrwxrwx    1 root     root            13 Mar  3 17:37 /etc/rc.d/S99nas -> ../init.d/nas
/etc/init.d/nas start

Advanced shares settings

If you don't want all the users in your network to be able to read (or write inside) your NAS, then you can do some finer settings.

The rights, as they have been set in the section Shares settings , allow you to choose, if the given share can be written into or if it's read-only. However, this setting only applies for an unregistered (anonymous) user, that means anybody who is inside the network. The rights to some directories can be set by users who have a password. How to do this that the topic of this section.

The user must first exist within the operating system, then he is assigned a password to the samba service and only then can he be added as Enabled user. After that you can add this user in Allowed users as has been described in Shares settings. Then you can uncheck the field Allow guests. A share which is set up this way will only be visible to the relevant user, who signs in with the right password.

How to add a user and assign a password:

useradd --home-dir /var --gid 65534 --no-create-home --shell /bin/false newuser
root@turris:~# smbpasswd -a newuser
New SMB password:
Retype SMB password: