16
CentOS NAS Project For CentOS 6.3 Version 4.0

NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

  • Upload
    vonga

  • View
    227

  • Download
    3

Embed Size (px)

Citation preview

Page 1: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

CentOS NAS Project

For CentOS 6.3 Version 4.0

Page 2: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

1.   PROJECT  GOALS  .......................................................................................................................................................  3  1.1.   !  IMPORTANT  NOTE  ABOUT  THIS  PROJECT  !  ........................................................................................................................  3  1.2.   VERSION  CHANGE:  .....................................................................................................................................................................  3  1.3.   SOFTWARE  ...................................................................................................................................................................................  3  1.4.   HARDWARE  SELECTION  ............................................................................................................................................................  3  1.5.   ASSUMPTIONS  .............................................................................................................................................................................  4  1.6.   DOCUMENT  CONVENTIONS  .......................................................................................................................................................  4  1.7.   INSTALLATION  SCRIPTS  ............................................................................................................................................................  4  Certain  conventions  have  been  used  in  preparing  these  scripts  .....................................................................................  4  

1.8.   WHAT  THESE  SCRIPTS  INSTALL/  MANAGE  ............................................................................................................................  4  1.9.   WHAT  YOU  DO  FROM  HERE  IS  REALLY  UP  TO  YOU  ................................................................................................................  5  

2.   INSTALLING  CENTOS  .............................................................................................................................................  6  2.1.   POST  INSTALLATION  STEPS  ..................................................................................................................................................  10  

3.   SCRIPT  INSTALLATION  ......................................................................................................................................  11  3.1.   RUNNING  THE  0_PREP  SCRIPT  ..............................................................................................................................................  11  3.2.   INSTALL  YOUR  STORAGE  ARRAY  -­‐  ZFS  ................................................................................................................................  12  3.3.   CREATING  A  STATIC  IP  ADDRESS  FOR  YOUR  NIC  ..............................................................................................................  14  3.4.   SETUP  HOME  DIRECTORIES  ..................................................................................................................................................  14  

4.   NAS  MENU  ..............................................................................................................................................................  15  4.1.   ADDING  A  USER  ........................................................................................................................................................................  16  4.2.   SHARE  MANAGEMENT  ............................................................................................................................................................  16  

Page 3: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

1. Project  Goals  

1.1. !  Important  Note  About  This  Project  !   This project was originally designed to quickly prepare two small NASs, identically configured for the purposes of a backup server using Ubuntu. The scope of this project has significantly changed. It should be noted that there may be errors within this document and the corresponding scripts which may refer to the previous specifications and conventions. If you read something, and it refers to a convention that doesn’t make sense, it’s probably a mistake that needs correcting and it would be lovely if you could point it out by emailing the contact information included in the document control section of this document.

1.2. Version  Change:   The scripts have been completely rewritten to accommodate CentOS. While previous versions of this project (since CentOS 6.1) have existed, this documentation refers to the build written around CentOS 6.3 and is referred to as version 4. Introduced with this version is an update from Netatalk 2 to Netatalk 3. This is a fairly significant update which has introduced a new config file and format. Share management has moved from samba or netatalk to a combined share management script.

1.3. Software   CentOS 6.3 installed via the Live CD (USB) and includes the Desktop GUI.

1.4. Hardware  Selection  The hardware selected was essentially the cheapest possible way to build the NAS with at least 4 x sata ports (for future expansion) and an onboard gigabit ethernet card. A sturdy Micro ATX case was favoured due to the fact that these systems were to be moved offsite weekly. Since the project’s move towards general NAS functionality, the HP Microsever (NL40) has become the choice for this project due to it’s low power requirements, reasonable specification and low price point. http://h10010.www1.hp.com/wwpc/us/en/sm/WF05a/15351-15351-4237916-4237918-4237917-4248009.html?dnr=1

Page 4: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

1.5. Assumptions   This document assumes a basic understanding of CentOS (RedHat), installation and configuring basic services like network and storage. While there is an installation section, it is preferred that you have at least a basic working system. Installing CentOS from a live USB is well documented.

1.6. Document  Conventions   Occasionally you will see the following in this document:

These are points which are generally necessary to read. They point out something that may have changed, an option that doesn’t work or a concept you need to understand.

1.7. Installation  Scripts   Initially started as a way of speeding up the process, several scripts were created to handle installation and to present a basic system with the idea that once installed, webmin would be able to handle the general configuration. What was found was that in some cases, webmin couldn’t handle functions as efficiently as bash and, mostly for reasons of insanity, the scripts were expanded well and truly beyond their original intention. Managing Users, Groups and Shares from the scripts will ensure that changes are synchronised. By all means go your own way once installed but keep in mind the consequences of moving away from the scripts.

Certain conventions have been used in preparing these scripts The scripts generally assume that files are located in a directory called /nas. A group will be created called “nas”. This group will be assigned to both the created installation directory as well as the volume used for time machine. A folder /nas will be created with the contents of the scripts and packages being copied there. Some packages will be installed via yum, some packages will be installed (and are included) in the /nas/packages folder. The scripts will create a small txt file (/nas/db/nas.txt). Scripts will refer to the contents of this file. As Home Directories are rather redundant for a simple backup storage array, they are treated as a special entry into the nas.txt file recording their path and if they are enabled or disabled. Netatalk and Samba will both refer to this file to enable or disable home shares. User management will only create a user with a home directory if this has been set in the nas database file and will also refer to the path set here.

1.8. What  these  scripts  install/  manage  

Page 5: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

Standard: Webmin Samba Optional: Netatalk Rsync SSH VNC PPTP VPN DYNDNS Transmission (Bittorrent client) freePBX plex Mediaserver Hardware: Networking UPS Disk management

1.9. What  you  do  from  here  is  really  up  to  you   By the end of this project, a user following the instructions and looking through the installation scripts should be able to modify and expand upon the scope of this project. For the most part, you should be able to edit most of the config files from the script menus or if not, look at the scripts to see where they are writing to and go from there. Webmin is also a very good way to expand this project.

Page 6: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

2. Installing  CentOS   NOTE: The following method is only indicative of the process followed when installing CentOS for use with these scripts. There are other methodologies that may be preferable and would possibly have no bearing on the effectiveness of the scripts. Download the latest CentOS 6.3 iso http://mirror.internode.on.net/pub/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveCD.iso Download the Universal USB installer http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/ Run the installer. Select Install to Hard Drive

When requested, select basic storage devices As you are starting from scratch, it’s presumed you don’t want to retain the data on the disks you are using.

Leave the hostname as live.centos – changing this here doesn’t seem to do anything and the scripts will take care of the name change later.

Page 7: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

Pick your timezone. Give your system a good, secure root password Select Create Custom Layout

If you are using a HP Microserver, bays 1 – 4 will show up as sda, sdb, sdc and sdd respectively. If you have gone to the effort of flashing your BIOS and have mounted drives on the secondary sata port or the esata port, they will be on sde or sdf. Choose the drive you want to install to (we will use sda for this example) and create a new standard partition.

Page 8: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

Create a partition for /boot at 500MB

Create a swap partition – size is usually at least as big as your RAM size. For 8GB RAM you would set to 8192MB.

Lastly, use the remainder of the drive for a / partition.

Page 9: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

Your partitioning should like like the following.

The partitioning setup above is assuming one drive for the OS and installed packages leaving the balance of storage for a zfs pool. Allow CentOS to format the drives. Ensure the bootloader is installed to the Hard Drive which you are booting off. CentOS will usually pick the first drive by default which is sda. If you are booting off a different drive, make sure it’s selected.

CentOS will now install. Once finished, shutdown the computer and reboot.

Page 10: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

2.1. Post  Installation  Steps   Upon first boot, CentOS will request you add a user account. This is an account which can be important later depending on what services you have installed. Use an account such as “sysadmin” rather than your username. It helps when creating user accounts later.

Select Time Synchronisation over network Enable Kdump at which point you will need to reboot. After reboot, select “OTHER” as the login option and login as ROOT – ignore the warning that CentOS presents. Head to Applications -> System Tools and terminal Type: yum update –y This may take some time to update packages. Once done however, reboot as there will most likely be kernel patches that will influence some packages such as ZFS. Login again as ROOT.

Page 11: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

3. Script  Installation  

3.1. Running  the  0_prep  script   The first script that needs to run is 0_prep.sh Copy/ download the scripts to a location on the hard drive and go back to terminal. If you have them included on a USB you can find your USB stick in /media. If you have saved the scripts to Root’s desktop the line would be: Sh /root/Desktop/CentOS_6.3_V4.0/0_prep.sh The script performs the following functions:

• Creates a group called nas • Adds a designated user as the administrator account for the nas - you will most likely use the account

you created on installation • Creates default directories and sets permissions • Copies files • Downloads various packages that are required. • Allows the user to change the system name. • Installs Samba • Installs webmin

Ensure you type in the name of the account you entered during installation. Do not use root. When prompted about changing the system name, ensure you keep the .localdomain extension as CentOS can get funny about believing there isn’t a relevant fully qualified domain name present.

Page 12: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

Once finished, you will be presented with a menu.

3.2. Install  your  storage  array  -­‐  ZFS   Run option 3. – Disk Utilities then option 8. – ZFS ZFS will offer to install itself – accept and wait. This can take some time to complete.

This script will create either a mirror or a raidz1 pool. Anything else will require you to investigate yourself the zpool commands from bash. For the purpose of this exercise, we’ll select option 4 – Create Raidz pool

Page 13: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

The script will prompt you to add drives to the pool – a minimum of 3 drives must be selected for a raidz1. Once the minimum level is reached, the script will prompt you if you want to add additional drives.

CAUTION: While the script attempts to omit the drive containing /boot directory (and therefore your OS drive), it is entirely possible that a drive you wouldn’t normally want to select may appear. Be certain to select drives only that you know are correct for your to select the drive that contains your CentOS installation. Be careful not to select

That’s it! Your zfs pool will now be mounted as /tank.

Page 14: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

3.3. Creating  a  static  IP  address  for  your  NIC   The next thing you probably want to do is set a static IP address for your NAS. This is important for remote access and web access. Select option 6. – Run Network Utility and then option 3. – Run Network Interface Utility .

Selecting option 1 to disable the network manager (which you need to do if you are configuring a static IP address this way) will also prompt you to setup a default adaptor.

NOTE: You do not have to use the script to set a static IP address for your network adaptor. You can use network manager from the GUI.

Go through the steps and verify your information is correct. You can look through the other options here (installing netatalk is a good step to do now if you intend to have native OS X connectivity). Once you are finished, quit this menu.

3.4. Setup  Home  Directories   If you are planning on offering your users home directories, it’s worth creating them before you add users. You can create root directory for home directories to be created off by simply typing: mkdir –p /tank/home “home” of course could be anything you like; users, homes …

Page 15: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

4. NAS  Menu   After the 0_prep script is completed and you have exited the menu, exit terminal as well. Open up terminal again and from any location the NAS Menu can be invoked by simply typing nasmenu.

Some, if not all of the options presented in the 0_prep menu will be found here. The first thing you probably want to do is setup at least one user. Before going any further, it’s worth ensuring that, if you created a home directory folder, that you tell the scripts where it’s located. Option D. – NAS Database Maintenance will allow you to do this.

Page 16: NAS CentOS 6.3 v - Tech, Photography, Lifemimojo.net/web_stuff/nas/NAS_CentOS6.3_V4.pdf · 1.5. Assumptions* This document assumes a basic understanding of CentOS (RedHat), installation

4.1. Adding  a  user  

Adding a user is pretty straight forward. If Home Directories are enabled in the NAS database, it will also prompt you on a per user add basis if you would like to give that particular user a home directory. These will be created under the “root path” you assigned in the previous step. By default, any user added via this script will join the group “nas”. The script does however allow you to create additional groups via option 6. This will be useful when creating a share later.

4.2. Share  Management   Selecting option 2. from the main menu will bring you to share management.

If Netatalk is installed, creating a share or removing a share will update both the smb.conf file as well as aft.conf simultaneously.