Friday, 13 March 2020

freeNAS as a RAID-Z / iSCSI file storage server

freeNAS web interface for storage management.
FreeNAS is a free and open-source network-attached storage operating system based on FreeBSD and the OpenZFS file system. 

Using the e.g. the Dell PowerEdge RAID Controller H310 (but flashed to IT mode).

Install freeNAS

Download the ISO image file from the FreeNAS website and burn it to a CD. Put the CD into the server as well as the flash disk and switch it on. Make sure that the BIOS is set to boot from CD. If it isn’t, you need to enter into the BIOS and configure it to boot from CD. Follow install steps and select the flash drive that you want to install freeNAS on. You will be prompted to set a password for the "root" user.
Once installation is complete take the CD out and reboot the system.

Initial boot

When you boot into FreeNAS the Console Setup will appear at the end of the boot process. This Console Setup menu can be used to administer the system should the web interface be inaccessible.
NOTE: you can access the Console Setup menu from freeBSD by typing /etc/netcli from shell. You can disable the Console Setup menu by unchecking the “Enable Console Menu” in System ‣ Advanced settings in the freeNAS web interface.

Set a static IP address

From the Console Setup menu:
  • Select "Configure Network Interfaces" (1)
  • Select "bce0" (1)
  • Select n (for "Remove the current settings of this interface?...)
  • Select n (for "Configure interface for DHCP")
  • Select y (for "Configure IPv4")
  • Enter the Interface name:bce0
  • Enter the IPv4 Address: 10.140.79.211
  • Enter the Netmask: 255.255.255.0
  • Select n (for "Configure UPv6")

Access freeNAS web interface

Use web browers: https://10.140.79.211 or https://hostname e.g. where hostname = freenas

Enable SSH connection to server

NOTE: It is important to use the GUI (or the Console Setup menu) for all configuration changes. FreeNAS uses a configuration database to store its settings. While it is possible to use the command line to modify your configuration, changes made at the command line are not written to the configuration database. This means that any changes made at the command line will not persist after a reboot and will be overwritten by the values in the configuration database.
The terminal can be access via the web interface but to use SSH:
Open /etc/rc.conf and insert this at the end sshd_enable="YES" 
    run /etc/rc.d/sshd start
    Type a full line of junk as requested to generate the keys
    OK sshd is now running but you won't be able to login into it with just a user name and password
    nano /etc/ssh/sshd_config
    change the line "PasswordAuthentication no" to PasswordAuthentication yes and remove the # at the start of line
    If you want to login as root PermitRootLogin yes
    Restart sshd by running /etc/rc.d/sshd restart
    Check status with /etc/rc.d/sshd status
This can be done by logging into freeNAS in web browser (username: root) and selecting "Shell" in the left hand menu.

Configure for use

Access the web interface.

1. Set up a Storage Pool and RAID

  • Select Storage > Pools > ADD > Create new pool > CREATE POOL
  • Enter a Pool name (e.g. "MedPhysStore" and add the available disks by selecting with check box and using the right arrow to move them to Data VDevs.
  • Under this select Raid-z (Note: RAIDZ1: requires at least three disks, RAIDZ2: requires at least four disks, RAIDZ3: requires at least five disks). RAID-Z is similar to RAID 5 but "faster": https://en.wikipedia.org/wiki/Non-standard_RAID_levels#RAID-Z
  • Select "CREATE" (Note: a Warning will pop up about the contents of all disks being erased, check "Confirm" and click "CREATE POOL") and the pool is created. It should indicate HEALTHY with 0% Used.

2. Set up an iSCSI share


Create a Zvol

  • After you create your pool, click on the 3 dots next to it and select “Add Zvol”.
  • It’s recommended to not exceed 50% of your storage size for your iSCSI share so for a pool of size X (e.g. HEALTHY: Y KiB (0%) Used / X TiB Free) make the iSCSI share X/2 TiB.
  • Enter the Zvol name (e.g. MedPhysStore) and Size (i.e. X/2 GiB) for this zvol and Save

Create a Portal

  • Enable the iSCSI service: Click on Services and enable iSCSI and check "Start Automatically".
  • Go to Sharing > Block Shares (iSCSI) > Portals and click ADD.
  • Select the IP addresses to be listened on by the portal. The address 0.0.0.0 can be selected to listen on all IPv4 addresses (the default iSCSI TCP port number is 3260)
  • SAVE

Add a Target

  • Click on Targets and ADD.
  • Enter a Target Name (e.g. medphystarget) and Portal Group ID (e.g. 1) and SAVE.

Add an Extent

  • An Extent is a storage unit shared through iSCSI. You can use a physical device or a file as Extent.
  • Select "Extents" and "Add Extent".
  • Enter an "Extent name" and select the "Device" as the Storage pool/Zvol created above and check "Enabled" and SAVE.

Add Associated Targets

  • Click on Associated Targets and ADD.
  • Select the Target and Extent created above and SAVE.

Access the iSCSI share from a Window PC

  • Open Control Panel\All Control Panel Items\Administrative Tools\iSCSI Initiator
  • Enter the Target IP of the freeNAS controller (e.g. 10.140.79.211) and click "Quick Connect...".
  • The available iSCSI share should appear in the "Discovered targets" box.
  • Go to the Volume and Devices tab and click Auto Configure.
  • Open "Computer Management" and expand Storage and click on "Disk Management"
  • A "Initialize Disk" pop-up will appear. Select GPT and "OK".
  • Right-click the disk volume for the share, select a drive letter (e.g. F) and then choose a volume formatting option.
  • The disk should now be available for use from within Windows File Explorer.

No comments:

Post a Comment