Building a fileserver

From JaxHax
Revision as of 11:36, 18 March 2015 by Dan (talk | contribs) (Created page with "This is a WIP, please excuse my mess -drb 3/18/15 =Building a Fileserver= This wiki assumes you already have a debian system built, on the network, and have several disks at...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a WIP, please excuse my mess -drb 3/18/15

Building a Fileserver

This wiki assumes you already have a debian system built, on the network, and have several disks attached to it. Most content here will translate readily to other flavors of linux.

Disks

Generally in a file server, you will be dealing with spinning-type hard disk drives (HDD). If you are dealing with sata, scsi or sas your disks will be designated with the beginning 'sd' and then a letter 'a-z'. For example sda, sdb, sdc If you are dealing with pata (parallel ata) your disks will be designated with 'hd' and then a letter. This is less common/rare now-a-days.

Viewing Disks using fdisk:

# fdisk -l
...
Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 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/sdc: 1.8 TiB, 2000398934016 bytes, 3907029168 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/sdd: 1.8 TiB, 2000398934016 bytes, 3907029168 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/sde: 1.8 TiB, 2000398934016 bytes, 3907029168 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/sdf: 1.8 TiB, 2000398934016 bytes, 3907029168 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
...

Partitions

While you can build a raid using just raw disks, it is generally unwise to do so. You generally want to use a partition, in this case we generally use type 'fd' for linux raid autodetect.

Building a raid partition on a blank disk:

# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xbae456f2.

Command (m for help): p
Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 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: 0xbae456f2



Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-3907029167, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-3907029167, default 3907029167): 

Created a new partition 1 of type 'Linux' and of size 1.8 TiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.

Command (m for help): p
Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 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: 0xbae456f2

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdb1        2048 3907029167 3907027120  1.8T fd Linux raid autodetect


Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

Raid

Redundant Array of Inexpensive Disks or now commonly refered to as "Redundant Array of Independent Disks". The type of raid we will be discussing here will be a linux software raid managed by mdadm.

Filesystems

You can put most types of filesystems and file structures on top of your raid. We will be discussing BTRFS, XFS and EXT3/4.

BTRFS

XFS

EXT

Services

Now that we have a file structure to store files, now we need to put that to use. There are many services we can deploy to use the file structure we have built. The ones we will discuss today are NFS (Network File System), SAMBA (CIFS/Windows File Sharing), FTP (File Transfer Protocol)

NFS

SAMBA

FTP