NAS file system layout

File system layout on the QNAP TS 439 PRO II+

NOTE: The file system layout may be different on other models or versions.

The QNAP NAS won't start without a disk. This means, that important system data is stored on the installed disk(s). This data is not stored in the same place as the user files. Each disk has several partitions, and many raids are present after boot.

The following results are from a four-disk configuration running RAID-5.

Devices and file systems

When the NAS is running, some file systems are mounted, while others may be present but not mounted. Three interesting commands:

 

[~] # df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/ramdisk            139.5M    111.8M     27.7M  80% /
tmpfs                    32.0M    108.0k     31.9M   0% /tmp
/dev/sda4               310.0M    156.4M    153.5M  50% /mnt/ext
/dev/md9                509.5M     47.5M    462.0M   9% /mnt/HDA_ROOT
/dev/md0                  4.0T      1.2T      2.8T  30% /share/MD0_DATA
tmpfs                    32.0M         0     32.0M   0% /.eaccelerator.tmp

[~] # cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath]
md0 : active raid5 sda3[0] sdd3[3] sdc3[2] sdb3[1]
      4390708800 blocks level 5, 64k chunk, algorithm 2 [4/4] [UUUU]
     
md4 : active raid1 sdd2[2](S) sdc2[3](S) sdb2[1] sda2[0]
      530048 blocks [2/2] [UU]
     
md13 : active raid1 sda4[0] sdd4[3] sdc4[2] sdb4[1]
      458880 blocks [4/4] [UUUU]
      bitmap: 0/57 pages [0KB], 4KB chunk

md9 : active raid1 sda1[0] sdd1[3] sdc1[2] sdb1[1]
      530048 blocks [4/4] [UUUU]
      bitmap: 0/65 pages [0KB], 4KB chunk

unused devices: <none>

[~] # fdisk -l

Disk /dev/sdd: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1          66      530125   83  Linux
/dev/sdd2              67         132      530142   83  Linux
/dev/sdd3             133      182338  1463569693   83  Linux
/dev/sdd4          182339      182400      498012   83  Linux

Disk /dev/sdc: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          66      530125   83  Linux
/dev/sdc2              67         132      530142   83  Linux
/dev/sdc3             133      182338  1463569693   83  Linux
/dev/sdc4          182339      182400      498012   83  Linux

Disk /dev/sdb: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          66      530125   83  Linux
/dev/sdb2              67         132      530142   83  Linux
/dev/sdb3             133      182338  1463569693   83  Linux
/dev/sdb4          182339      182400      498012   83  Linux

Disk /dev/sda: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          66      530125   83  Linux
/dev/sda2              67         132      530142   83  Linux
/dev/sda3             133      182338  1463569693   83  Linux
/dev/sda4          182339      182400      498012   83  Linux

[~] # 

Each of the four disks (of same size) have identical partition tables. One large for the user files, and three small for system purposes.

  • The large partition with user files is partition 3 in the partition table.
  • The large partition is RAID-5, because that's how it was set up. It could also have been another raid type.
  • All the other partitions are RAID-1, so they are mirrors. Capacity won't increase with the number of disks.
  • Partition 1 of all drives are combined into /dev/md9.
    It is mounted under /mnt/HDA_ROOT and contains system configuration files.
  • Partition 2 of all drives are combined into /dev/md4.
    This is the memory manager swap partition.
  • Partition 3 of all drives are combined into /dev/md0.
    It is mounted unter /share/MD0_DATA and contains user files.
  • Partition 4 of all drives are combined into /dev/md13.
    It is not mounted.

Partition 1 and 3 can easily be verified - they are mounted. Partition 2 can be verified by issuing

[~] # cat /proc/swaps 
Filename                Type        Size    Used    Priority
/dev/md4                                partition    530040    1444    -1
[~] #

which shows, that md4 (consisting of partition 2 of all drives) is used for swap space.

Partition 4 is not easily verified - it may be used as reserved space for the last unused sectors.

[~] # mount /dev/md13 x
mount: special device /dev/md13 does not exist
[~] #

However, the mount command reveals, that /dev/sda4 is mounted under /mnt/ext, and many symlinks in /usr/local pointing there. This may be optware-related.

[~] # mount | grep sd.4
/dev/sda4 on /mnt/ext type ext3 (rw)
[~] # ls /mnt/ext/
addon_flag  debug_flag  lost+found/ opt/
[~] # ls -l /usr/local/
drwxr-xr-x    2 admin    administ     1024 Mar 30 23:00 amazons3/
lrwxrwxrwx    1 admin    administ       19 May 19 18:44 apache -> /mnt/ext/opt/apache/
drwxr-xr-x    3 admin    administ     1024 Mar 30 23:00 bin/
drwxr-xr-x    4 1011     1011         1024 Mar 30 22:57 etc/
drwxr-xr-x    2 1011     1011         2048 Mar 30 23:00 lib/
drwxr-xr-x    2 admin    administ     1024 Mar 30 23:04 modules/
lrwxrwxrwx    1 admin    administ       18 May 19 18:44 mysql -> /mnt/ext/opt/mysql/
lrwxrwxrwx    1 admin    administ       18 May 19 18:44 samba -> /mnt/ext/opt/samba/
drwxr-xr-x    3 1011     1011         1024 May 19 19:42 sbin/
drwxr-xr-x    2 admin    administ     1024 Mar 30 22:54 share/
drwxr-xr-x    6 admin    administ     1024 Aug  5  2008 ups/
[~] #

 

This means, that everything needed is mounted, there is no hidden things, all that is necessary is to identify the interesting files correctly. Most changeable configuration files are found in /mnt/HDA_ROOT with symlinks in the local file system pointing to them.

The roor file system ((all programs and libraries etc) is on a ramdisk. This ramdisk contains many symlinks to the harddisks.

 

Symlinks and locations of things

The first place to look is /etc/config. It shows the symlinks pointing from ramdisk to harddisk:

[~] # ll /etc/config
lrwxrwxrwx    1 admin    administ       21 May 19 19:42 /etc/config -> /mnt/HDA_ROOT/.config/
[~] #

The leading dot in .config indicates a hidden file/directory.  There is also a (mnt/HDA_ROOT/.conf file, which is not interesting, and probably shouldn't be touched.

[~] # cd /mnt/HDA_ROOT/.config/
[/mnt/HDA_ROOT/.config] # ls
BOOT.conf                      mdadm.conf                     smb.conf
MACHINE.SID                    mt-daapd.playlist              smb.conf.cksum
Model_Name.conf                my.cnf                         smbpasswd
NetLinks.conf                  nfssetting                     smbusers
Qraid1_conf_exclude.conf       nvrd.xml                       sms_config.conf
Qraid1_share_exclude.conf      nvrstat.xml                    snmpd.conf
TZ                             passwd                         ssh/
acpi.conf                      passwd-                        ssh_key.fla
apache/                        php.ini                        ssmtp/
clock                          printcap                       storage.conf.bak
crontab                        proftpd.conf                   stunnel/
cups/                          qget/                          system.map.key
def_share.info                 qnapddns.conf                  torrent/
dhcpd.conf                     qpkg.conf                      twonkyvision-mediaserver.ini
dhcpd.leases                   qsync/                         twonkyvision-mediaserver6.ini
esata_share_mapping            raidtab                        uLinux.conf
external_storage.conf          raidtab.bak                    udev.conf
group                          rssdoc/                        upnpc.conf
grp_quota.conf                 rsync_schedule.conf            ups/
ipsec.conf                     rsyncd.conf                    ups_snmptrapd.conf
ipsec_allow.conf               rtc_last_save                  usb_share_mapping
ipsec_deny.conf                schedule_boot_setting          usb_share_setting
iscsi-init.conf                secrets.tdb                    usr_quota.conf
iscsi.conf                     set_home_directory             vaultServices/
iscsi_trgt.conf                shadow                         virtual_share_mapping
localtime                      shadow-                        volumeStatus.conf
logo/                          smart.conf                     wfm2.conf
mDNSResponderPosix.conf        smartd.conf
[/mnt/HDA_ROOT/.config] #


This list shows, that a lot of interesting configuration files are round here.  They are stored on a reserved filesystem with limited space, but symlinks across filesystems work fine.
Also note, that changes to the crontab are permanent, because the crontab is located on the harddisk. Consider backup of your changes, as this stored seperately from the user files.

Optware

If you installed optware, you will want to look at:

[~] # ls -l /opt
lrwxrwxrwx    1 admin    administ       29 May 19 18:45 /opt -> /share/MD0_DATA/.qpkg/Optware/
[~] # ls /opt/
Optware.sh* i686-unknown-linux-gnu/ lib/ sbin/
bin/ include/ libexec/ share/
doc/ info/ local/ tmp/
etc/ ipkg-j5oNmz/ man/ var/
[~] #

The optware package needs information stored on the harddisk, and this is stored on the filesystem that contains user data.

 

Apache configuration

The apache webserver for user websites is controlled with the script

/etc/init.d/Qthttpd.sh {start|stop|restart}

It specifies the configuration in /etc/config/apache, where /etc/config is a symlink to /mnt/HDA_ROOT/.config, so the apache configuration files are located on the harddisk. The next thing to do is to look in the apache configuration file for DocumentRoot:

[~] # cat  /etc/config/apache/apache.conf | grep DocumentRoot
DocumentRoot "/share/Web"
[~] # ls -l /share/Web
lrwxrwxrwx    1 admin    administ       12 May 19 18:43 /share/Web -> MD0_DATA/Web/
[~] # ls /share/Web/
cgi-bin/      images/       index.php     istat@        js/           transmission@
[~] #

If you can't get the cgi scripts to work with your configuration, then check the web server configuration file, and if necessary add something like this

<Directory "/share/Web/cgi-bin">
    AllowOverride None
    Options +ExecCGI
    Order allow,deny
    Allow from all
</Directory>

Note, that the DocumentRoot and directories below it are located on the harddisk, by the fact that /share/Web is a symlink to the user data folder /share/MD0/Web.

 

MySQL configuration

Optware has a mysql package, and the NAS has a mysql package. Be sure that you use the correct one each time, and that the PATH environment variable includes the correct one first.

The most important thing to set is the location of the database files.