User Tools

Site Tools


This documentation applies only Turris OS 3.x that is no longer present in newly sold routers. The new documentation is located at https://docs.turris.cz/.

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:

  • The table called Mounted file systems shows which devices are currently connected to the OS and which you can process data from.
  • The table called Mount Points shows the items, which are in the saved configuration and under certain circumstances also other items, which the OS found (in that case you can in the next step use the button edit next to the given record.)

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

  • Check Allow this mount point.
  • Inside Devices fill out the name you want to give to the given unit. If you decide to add the device through its UUID, leave the field blank and fill out the field UUID instead.

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

  • In the tab Advanced Settings in the field Filesystem fill out the type of the mount system. There are two significant exceptions to this:
    1. drives with NTFS. See the next section.
    2. Sometimes the options etx2, ext3, ext4 do not show up in the dropdown menu. In that case select –custom– and fill in ext2/ext3/ext4. The drive will however not mount immediately, you first need to reboot the router.
  • Check the box Run filesystem check
  • Confirm the changes by clicking Save & Apply.

Shares settings

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

Basic Settings:

  • You can give your home NAS a fitting name by filling out Description and Hostname, eg. TurrisNAS :-)
  • We recommend to set Share home-directories to 0.
  • The Workgrouprefers to the identification in Windows networks. if you don't have specific requirements, leave this field set to the default.
  • Click Save & Apply.

Now it's time to set up the shares.

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

  • Name – sets how the share is going to appear in the network. For example: if you call the share multimedia, Windows OS users will connect to \\192.168.1.1\multimedia
  • Path – the folder, which will appear in the shares. For example: /mnt/nas.
  • Allowed usersleave blank, this field falls under Advanced shares settings
  • Read-only – here you can select if the directory is read-only or if it can also be used for uploading contents.
  • Allow guests – If the field Allowed users is blank, then this must be checked.
  • Leave the remaining fields blank and click Save & Apply

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:

  • Create a directory, which you will mount the drive to:
mkdir /mnt/nas
  • Change the directory to /etc/init.d :
cd /etc/init.d/
  • Write the following data into the file called nas. There are two details to be adjusted: Firstly, /dev/sda1 is the name of the drive – change this according to your needs. Second, /mnt/nas is the directory, which the drive should mount to – change this according to your needs and requirements, but it has to correspond to the directory created in the first step.
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
  • Give the file the rights to run:
chmod +x nas
  • Enable the created nas service either in LuCI, like other services, or using the command:
/etc/init.d/nas enable
  • Using ls -l /etc/rc.d/S99nas you can check, if the service has really been enabled. After running the command, you should see the following output:
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
  • After enabling, you have to activate the service. You can do this in LuCI just like with other services, or type the following command into the console:
/etc/init.d/nas start
  • If you have done all that is described above in Setting up the NAS, with the modifications described here, then the shares you have set up should be accessible from your home network.

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:

  • Sign into the router through SSH.
  • Add the user to the operating system. This is what the command useradd is for. Use the following command, instead of newuser type the name you want to assign to the new user:
useradd --home-dir /var --gid 65534 --no-create-home --shell /bin/false newuser
  • At this point the user exists in the operating system. For security reasons, he doesn't have a password to the operating system, so he cannot sign in (eg. through SSH). A NAS user deosn't need a password to the OS and it isn't recommended to give it to him/her. The user does need a password to samba. This password is set by the command smbpasswd -a newuser, which is followed by a request to repeat the password for this user. (Don't be confused by that fact that no character appear while you type.) The whole process looks something like this:
root@turris:~# smbpasswd -a newuser
New SMB password:
Retype SMB password:
  • Creating the user is now done. The user can now be specified in the Shares settings as has been describe above.