2

I have recently built a small homeserver, that I want to use as a NAS besides other applications like hosting VMs etc. The disk space should be accessible via NFS, SAMBA (and SSHFS), but that's not part of the question. One of the reasons to start this project was that I have had left over a bunch of HDDs. Because these HDDs are of different models and sizes, I don't want to use them as part of a [software] RAID or use them to create LVM.

My first attempt was to create a folder named share as a subfolder of /mnt where I mount all the HDDs like this:

/mnt
    /share
        /disk_a
        /disk_b
        /...

Afterwards the share folder should be made accessible via NFS and SAMBA.

After reading the NFS article from the ArchWiki, where the --bind option of mount was mentioned, I changed the directory structure to make the shared folder independent from the mounting points:

/mnt
    /disk_a
    /disk_b
    ...

/nas
    /disk_a     # mount --bind /mnt/disk_a /nas/disk_a
    ...

In this solution the /nas folder would be shared.

My question is, what's the best directory structure for sharing these disks? Are there any other best practices to know, when setting up such a network storage?

  • Why don't you want to use LVM? That would have been my first recommendation to throw them all into one volume group and go from there. – casey Dec 17 '13 at 20:03
  • I want to have control over what is saved on which disk. Also i don't know if it's a good idea to combine these different disks to an LVM. If one of them breaks, the whole LVM is broken. – klingt.net Dec 17 '13 at 20:07
2

Your strategy for naming seems fine. In my department at university, disks are exported similarly as:

/machine-name/s0
/machine-name/s1
/machine-name/s2

to all other local machines. This is essentially the same naming scheme you propose.

One thing you'll have to consider if you want to access you NAS from multiple machines is consistency of userid across machines. Samba can take care of this for windows clients but for the linux clients you'll probably want to synchronize userids across the boxes. My experience with that is to use NIS but there are other (LDAP, manual merging of passwd/shadow/group, etc) ways.

2

If LVM is nothing for you, why don't you use an aufs (overlay) filesystem.

It works like this:

user@host:~# mount -t aufs -o br=/mnt/disk1:/mnt/disk2 none /nas/share/

The mount command, specifies it is going to union mount /mnt/disk1/ and /mnt/disk2/ under /nas/share/. The directory /nas/share/ will have the content of both /mnt/disk1/ and /mnt/disk2/.

See the following listing:

user@host:~# ls -l /mnt/disk1/
-rwxr--r--   1 root root  267386880 May  1  2013 file_on_disk1
user@host:~# ls -l /mnt/disk2/
-rwxr--r--   1 root root 1325274146 Aug 31 23:29 file_on_disk2
user@host:~# ls -l /nas/share/
-rwxr--r--   1 root root  267386880 May  1  2013 file_on_disk1
-rwxr--r--   1 root root 1325274146 Aug 31 23:29 file_on_disk2

aufs is highly configurable and customizable. You can configre on which partition the filesystem should write new files when accessing it. For example one filesystem can be mounted readonly and the other readwrite, so the aufs mount command can be configured to write only on the readwrite partition.

The advantage whould be you can have one big directory to share via NFS or Samba. See here for all mount options.

  • First time I hear about aufs, I will read about it and maybe give it a try. – klingt.net Dec 17 '13 at 20:59
  • The server is running arch, which doesn't support aufs since kernel version 3.x – klingt.net Dec 22 '13 at 10:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.