CentOS 5: File Server Essentials

What powers a file serving environment? In this tutorial, we'll begin to learn the skills required to install an enterprise grade operating system and discover the power and simplicity that makes CentOS the robust and reliable solution trusted by professional throughout the world. No previous experience of this operating system is assumed and during this presentation we will build on the process of a 'basic server installation' in order to get you up and running in no time at all.


Before We Begin ...

...Some basic requirements and a few assumptions will be made.

  • This tutorial is intended to be an introduction to CentOS during which we will build a typical server installation without a GUI. No prior knowledge or experience of this operating system is assumed but a basic familiarity with the console environment, downloading and burning a CD/DVD image are assumed.
  • In this instance we will be concentrating on the 32bit version using IPv4 but unless otherwise stated you may assume the 64 bit version is similar with very little modification required (you may need to remove some 32bit applications). IPv6 will not be discussed.
  • All administration tasks will be achieved directly via the console (or a secure shell environment) and you will be shown how to configure the operating system, partition your hard disks, install a file-sharing environment, manage users and maintain a firewall. Additional options (including Apache, PHP/Perl, Virtual Hosts, MySQL, BIND etc ... ) will be discussed in a future tutorial.
  • CentOS will run on almost any hardware but for the purpose of this tutorial we will be using the computer system described below. Screenshots have been provided (where possible) to support the main body of text together with reasoning and related notes; and as I am from the UK you should be aware that my writing and examples will carry a harmless 'anglophile' bias.
  • Throughout this tutorial I have used the text editor 'nano' due to its simplicity for new users but do change this to your preferred editor as and when required.
  • This tutorial is considered to be a guide and there is no guarantee that a replication of the following instruction will work for you without making the necessary changes to suit your needs (i.e. computer name, user names, ip addresses etc ...) whilst performing additional steps (based on your network topology) that are beyond the scope of this document.

I hope that this tutorial proves to be useful. So let's get started!


The Example System

CentOS will work with virtually all common hardware and as you can see, the computer system I will be using throughout this tutorial is quite straightforward. :

  • AMD 64bit Processor.
  • Standard motherboard with a single network interface.
  • 3GB RAM.
  • 3 SATA Hard Disks (see below).
  • Standard Router.
  • Generic Mouse (only used during the installation process).
  • Keyboard.
  • Generic Display/Monitor.

As stated above, I will be using the 3 hard disks in the following manner.
Where the first two drives listed are integral to our general server configuration, drive 3 is considered to be optional and will not form part of the original installation. We will return to 'Drive 3' at a later time in this tutorial in order to illustrate one of the many ways you could expand your system at a later date and for this reason it should remain disconnected from the motherboard until required.

  • Drive 1: 1 x 80GB
    disk will be used for the system files (active, connect to the motherboard at start-up).
  • Drive 2: 1 x 500GB disk for the user files (active, connect to the motherboard at start-up).
  • Drive 3: 1 x 500GB disk for backup (inactive, disconnect this drive until required).

Don't worry if your hard disks are different sizes or whether you are using old or new hardware or at this stage but if you wish to manage your CentOS installation remotely (or from your current desktop computer via a secure shell environment) then you may need to download and install Putty or similar software for use on your Windows-based desktop.


Download CentOS

First of all we want to download a copy of the CentOS 5 operating system.

So simply point your browser at http://isoredirect.centos.org/centos/5/isos/i386/, and download either:

  • The single DVD package called
    'CentOS-5.6-i386-bin-DVD.iso' or
  • The seven CD based packages called CentOS-5.6-i386-bin-1of7.iso, CentOS-5.6-i386-bin-2of7.iso, CentOS-5.6-i386-bin-3of7.iso, CentOS-5.6-i386-bin-4of7.iso, CentOS-5.6-i386-bin-5of7.iso, CentOS-5.6-i386-bin-6of7.iso, CentOS-5.6-i386-bin-7of7.iso

Do not mix and match the chosen installation media.

For the purpose of this tutorial I have downloaded a single DVD-Rom version called 'CentOS-5.6-i386-bin-DVD.iso'.

When you have finished downloading your chosen installation media simply burn the iso(s) to the relevant disc type (700MB CD or 4GB DVD), place the disk in your intended server and boot from the CD/DVD drive.

Go to Stage 1 to continue ...


Stage 1: Installation

A) Booting from the installation media.

We will install CentOS in graphical mode so press <ENTER> when you see the following screen:


The next screen will ask if you want to test the integrity of your installation media.

By using the (left and right) arrow keys to make your selection:

  • Should you wish to test the integrity of your installation media, choose <OK>.
  • If you do not wish to test the integrity of your installation media, choose <SKIP>.
  • When ready, hit the <ENTER> key to proceed.

When writing this tutorial it was decided not to test the integrity of the installation media as this can take a substantial amount of time.


The welcome screen will now appear.
Using your mouse, choose <Next> to proceed:


Choose your language. Simply highlight your preference and choose <Next> to proceed:


On the next screen, as shown below use the same process to choose the appropriate keyboard settings for your system:


The next screen may vary so if neither of the following are applicable to your circumstances then simply jump to the next step. However,

  • If you installing CentOS 5.6 on a fresh system (new hard disks), you may be asked to 'initialize the relevant drive(s)' so reply with a <Yes> when you are asked this question - "Would you like to initialize this drive, erasing ALL DATA?"
  • If the installer detects an existing copy of CentOS then you will see the following screen. If you do, choose <Install CentOS> to proceed.

B) Partitioning your hard disks.

"A discussion about the benefits of LVM is beyond the scope of this tutorial but in simple terms, it is a technology that allows the administrator of any system to re-size, move and add new hard disks during the operational lifetime of a given computer system. There are many advantages to this approach, particularly in a larger networking environment as this gives you much more flexibility in allocating storage to applications and users without changing the entire system or build new. So the best thing to remember is, any decisions made now can be modified further down the road."

CentOS uses Logical Volume Management (LVM) by default. You can of course use more or less hard disks and vary this part of the tutorial substantially but for the purpose of this tutorial and based on the specification of the Example System (described above) my intention is to use two SATA-based hard disks in the following way: the installer has detected an 80GB primary SATA drive (sda) and a 500GB secondary SATA drive (sdb) and where the former will hold the 'root files, the latter will be used to store all 'home' files.

With this in mind I will now show you how to use Disk Druid to partition your disks.

Based on the screenshot below and given that CentOS is the only operating system on this computer, your choices are:

If you have multiple hard disks:

  • In the first drop down list, select 'Remove linux partitions on selected drives and create default layout'.
  • Make sure the boxes next to your hard disk(s) are checked (i.e sda & sdb).
  • Check the box marked 'Review and modify partitioning layout'.
  • Choose <Next> to proceed.

If you have a single hard disk only:

  • Select 'Remove linux partitions on selected drives and create default layout' in the first drop down list.
  • Make sure the boxes next to your hard disk(s) are checked (i.e sda & sdb)
  • Do not mark the check box marked 'Review and modify partitioning layout' unless you want to override the default settings and customise your partitions.
  • Choose <Next> to proceed and skip to the next section.
  • If you have chosen not to 'Review and modify partitioning layout', then go to Section C (below).
  • If you have chosen to 'Review and modify partitioning layout' and thus customise your partitions, then keep reading :-)

If your hard disks contain data you may see the following notice "Warning, You have chosen to remove all partitions (ALL DATA) on the following drives":

  • If you do and you are happy to proceed , choose <YES> then click <NEXT> to proceed.
  • If you do but you are not happy to proceed, choose <NO> and return to the previous step to make the necessary changes.

The next screen will now enable you to create your partitions, but don't worry, we will do this together, step by step. On the other hand, if you are confident that you know how to do this, then simply make your changes and jump to the next (section C).

As previously mentioned, CentOS uses LVM by default and my Example System is using two SATA based hard disks - an 80GB primary SATA drive and a 500GB secondary SATA drive. Identified by the device name as SDA and SDB respectively, where the former will be used to contain our system, the latter will be used to store all user based data.

With this in mind, from the following screenshot you will notice that the installer has already created the Logical Volume Group:


We will now rename this group to something more 'user friendly'.

Naturally, you may want to use different names than those suggested by this tutorial so please experiment as required (but stick to lower case alpha numerics and do not use spaces).

So as you can see from the following screenshot, (using your mouse) highlight the row labelled 'VolGroup00' and choose <EDIT> to proceed:


As the next screenshot illustrates, you will now be presented with a pop-up window called 'Edit LVM Volume Group: VolGroup00'.

So let's begin ...

  • In the field titled 'Volume Group Name' - change this to 'MainGroup00' or something you prefer - i.e. vg_computername.
  • Leave 'Physical Extent' alone. This value is automatically chosen by the installer and is usually a good estimate of your systems capabilities.
  • As we want to use both hard disks make sure that both physical volumes are selected with a tick in the box next to the relevant device name.

"The values 'Used Space' and 'Total Space' simply shows a total of the 'Physical Volumes to Use' in MB whereas the use of '00' in our naming policy is only a numeric reference just in case you ever wanted to add a new LVM group at another time in the future. So you could always create a new LVM called MainGroup01 etc.. etc..."


Let's turn our attention to building the swap space.

"Swap space is used by the computer to assist RAM based operations. Linux divides your computers RAM into chucks of memory called pages. The action of 'swapping' describes a process in which a page of memory is freed from the physical RAM by copying it to a space on the hard disk called 'swap'. Based on this you will now realise that the combined sizes of both, the physical memory and the swap space is the amount of virtual memory available to your system. Technically speaking, you don't need to know how to calculate the value as CentOS will do that for you but for those who want to know (bearing in mind that there is no definitive rule) it is best to work on an estimate of your computers total (physical) RAM and multiplying it by a value between 1.7 and 2. Consequently a machine with 3GB RAM will have a swap space of between 5-6GB space, whereas a machine with 2GB RAM may require between 3-4GB space etc... etc..."

As shown in the following screenshot, we will customise our 'swap space' by selecting the row labelled 'LogVol01' and choose <EDIT> to proceed.


In response to this you will be presented with a new pop-up window called 'Edit Logical Volume: LogVol01' like so:


In the new pop-up window called 'Edit Logical Volume: LogVol01' simply:

  • Modify the field titled 'Logical Volume Name' and change this to 'swap'.
  • You can use the field titled 'Size (MB)' to adjust the size of the swap partition but the installer should have already picked the optimal size.
  • Choose <OK> when complete.

Remember if you think you have made a mistake at any time, choose <Cancel> and repeat the previously described steps above.


Having finalised the above step you will notice that the Logical Volume Name 'swap' now appears in the window called 'Edit LVM Volume Group: VolGroup00' thereby giving us the chance to turn our attention to the other partitions and to complete our partitions

So let's recap:

  • The Example System has two SATA hard disks with a total disk space of 553120MB - 1 x 80GB (identified as device name SDA) and 1 x 500GB (identified as device name SDB).
  • It is intended that we want to place all the system files (including the swap space) on disk SDA (76192MB) whilst allowing the users to put their data on SDB (476928MB).
  • The system files will be installed on my 'root partition'.
  • We have just completed the steps required to create a 'swap' partition totalling 5056MB thereby leaving me with a system disk (SDA) size of 71136MB.
    Calculated as 76192MB - 5056MB = 71136MB.
  • We now need to create the 'root' partition that will utilise the remaining space (71136MB) on device name SDA.

"If your hard disks are of a different size or order, simply vary the calculations I have made to create your own partitions"

To create the 'root' partition, simply:

  • Select the row 'LogVol00' and choose <EDIT> to proceed.

You will now see a pop-up window called 'Edit Logical Volume: LogVol00':


From the screenshot below you will see the resulting pop-up window called 'Edit Logical Volume: LogVol00'.

Based on our calculations simply:

  • Modify the field titled 'Logical Volume Name' and change this to 'root'.
  • Change the field called 'Size (MB)' to a value representative of the remaining space on device name SDA. For the Example System we have previously calculated this as 71136MB (Total size of disk SDA - Swap Space = 71136MB).
  • Choose <OK> when complete.

This will close the window called 'Edit Logical Volume: LogVol00'


On our return to the window called 'Edit LVM Volume Group: VolGroup00', you will notice we have

  • A partition called 'swap' on device name SDA.
  • A partition called 'root' on device name SDA.
  • And 476928MB of space free for user data. For the Example System, this is the total disk space available for device name SDB.

Our user data will be installed on this free space, so let's finalise our partition scheme.

  • From the logical volumes list, where you will find three buttons <ADD>, <EDIT>, <DELETE>.
  • Choose <ADD>.
  • As shown below you will be presented with a new window called 'Make Logical Volume'.

Fill in the details as shown below:

  • For Mount Point, choose '/home' from the drop-down menu.
  • For 'File System Type', choose 'ext3' from the drop-down menu.
  • For the field 'Logical Volume Name', type 'home'.
  • For the field 'Size (MB)', use a value equal to the remaining free space available. Based on our previous calculations this was 476928MB.
  • Choose <OK> when complete.

Well done. We have now finalised our partition scheme and you should see something similar to the following screenshot. Remember, your values may be different depending on your disk size and preferred approach to naming your volumes etc ... etc ...

"As we know, over-sized log files can crash your server and the easiest solution to to avoid this scenario would be based on creating a a separate partition for VAR. 'Var' is where your log files are kept and depending on on the needs of your server (for additional security and performance) it could be worth considering the need to reduce the potential risk associated with malicious attacks that attempt to exploit the size of your log files. All you need to do is modify your calculations for your 'root' partition and create a new logical volume called VAR . As you have seen, it isn't a very complicated to use Disk Druid, so simply reserve some space from your 'root' partition (or use another hard disk) and vary the instruction given to create an isolated partition for VAR."

When you are ready, choose <NEXT> to proceed.


Nearly done ...

To finalise our partitioning you will now be asked where we should install the 'GRUB' boot loader; and looking at the screenshot below the installer would have already set the correct values automatically.

Choose <NEXT> to proceed.


C) Network Settings

The partitions are set and you will be asked to confirm your networking choices.

Remember, if you are intending to the system as a server, then you should not use DHCP.

So simply choose the <EDIT> button to proceed.


As you can see from the following screenshot. Simply complete the pop-up window titled 'Edit Interface' with your required values but remember to deselect 'Enable IPv6 support' if it is not required:

"You can populate the 'Manual Configuration' by simply checking the 'Dynamic IP configuration (DHCP)', un-checking 'Enable IPv6 support', and by giving your network card a static IP address. As an example, a typical IP address would be 192.168.1.100 and the required subnet mask for this value would be 255.255.255.0"

Choose <OK> when complete:


Returning to our previous screen you will now need to supply the following information but because CentOS can be used as both, a server or desktop we will re-visit them later on this tutorial to ensure that everything is correct. So any decisions made now can be modified later-on:

  • Hostname - i.e servername.serverdomain.lan or server1.server.com etc ...
  • Gateway - the IP address of your router.
  • Primary DNS - typically this could be the IP address of your primary DNS server.
  • Secondary DNS - typically this could be the IP address of your secondary DNS server.

"Remember, the actual values you choose are dependant on your networking conditions and purpose. If you are on the world-wide web a hosting provider should supply this information, but for a local 'home or office server' that does not run independent DNS servers you could use those values shown below by completing it with a secondary DNS equal to your routers IP address. For those who want a local server (home or office) to be accessible to the world-wide web, you will need a static IP address or a dynamic DNS hosting service with appropriate access to the relevant ports."

Choose <NEXT> to finalise this process:


D) Time Zone/Location & Setting Your Root Password

Select your time zone/location using the interactive map or drop-down list; but as stated above, because CentOS can be used as both, a server or desktop we will re-visit them later on this tutorial to ensure that everything is correct. So any decisions made now can be modified later-on:

Choose <NEXT> to proceed:


And finally, elect an appropriate password for the root user and choose <NEXT> to proceed:


F) Package Selection & Install

As the Example System is to concentrate purely on a server based role, in this tutorial we will not be installing a desktop GUI. For this reason our initial software choices are going to be minimal.

  • As shown in the screenshot below, clear all the check boxes in the software selection area.
  • Then check 'Customize now', and click on <Next> to proceed.

Having chosen to customise our installation we will be able to pick what packages we need.

From the following screenshot you will notice that a list of categories can be seen in the left-hand column with a subsequent list of related package groups (particular to each category) in the right-hand column.


As shown in the screenshot below choose the DEVELOPMENT category and mark the individual check boxes for both:

  • Development Libraries.
  • Development Tools.

Now choose the BASE SYSTEM category and unless you need it, clear the individual check box for

  • Dialup Networking Support.

And finally, if necessary, choose the LANGUAGES category and mark the individual check box for your preferred language.

This will complete our package selection.

So when you are ready, choose <NEXT> to continue:


As you can see from the following screenshot the installer will now want to qualify our dependencies for the desired packages.


On completion of this process the installer will confirm that it is ready to go.

Choose <NEXT> to proceed.


During the following few minutes the installer will begin to:

  • Format the hard drives and then
  • Install the system and selected software packages.

"If you are using a CD as your installation media of choice you may need to change discs when prompted."


Finally, when the installation is complete you will be asked to remove your installation media from the computer and reboot.

When you are ready, choose <REBOOT> to proceed.



Step 2: Configuration

First Boot

If the installation has gone well, after a brief re-start you will be presented with the'Setup Agent' and from this point onwards you will be working in console mode. Your opportunity to use a secure shell environment will be apparent shortly but for purpose of this tutorial we will refer to this initial phase as the 'first boot'.

From the screenshot found below it is noticeable that the'Setup Agent' allows us to access and configure many elements of the operating system. We will return to these features later but as this stage we are only concerned with the process of activating the systems Firewall.

To do this we will:

  • Use the (up/down) arrow keys to choose 'Firewall configuration'.
  • Use the TAB key to activate the red buttons, choose 'Run Tool' with the (left/right) arrow keys and hit the <RETURN> key to proceed.

By using the arrow keys and as shown in the screenshot below we will now disable SELinux and enable our Firewall.

To do this we will:

  • Make sure the 'Security Level' is set to 'Enabled' by toggling a star symbol with the <SPACE BAR>.
  • TAB down to 'SELinux' and use the arrow keys to select 'DISABLED'.
  • TAB down to the red buttons and use the arrow keys to choose 'Customize'.
  • Hit the <RETURN> key to proceed.

"SELinux or Security Enhanced Linux was originally developed by the NSA to provide hardened security policies that can even affect the administrator of the system. As a result, SELinux is not only considered to be a very big subject, but for the same reason it is generally accepted that most administrators will disable it (particularly if you intend to install other applications). So don't worry, we are only following convention and if you intend to master and use SELinux at a later date you can always access this screen at any time by typing 'setup' at the command prompt."


Our intention is to open a select number of firewall ports, and so, by using the arrow keys, simply highlight the relevant ports and mark them as active by using the <SPACE BAR> to toggle a star symbol in the following areas:

  • SSH
  • Telnet (if required)
  • Samba

Please use the following screen shot as a guide and feel free to open any additional ports you may require.
For example, in 'Other Ports' you could type 'mysql:tcp domain:udp' to open MySQL and BIND on ports 3306 and 53 respectively.

When complete, use the TAB key to highlight <OK> and hit the <RETURN> key to confirm and exit this screen.


And as the screenshot found below indicates, by using the TAB key to highlight the <Exit> button you may leave the 'Setup Agent'.

When selected, hit the <RETURN> key to proceed.


As the following screenshot now indicates, the 'Setup Agent' will now close and you will be given access to the console.

At the command prompt, login as 'root' to proceed:


Some basic commands

Before we reboot our computer to activate the security features we have just applied let's take this opportunity to make a few tweaks to some basic functions.

To read any file, use the following command at any time throughout this tutorial:

To make a back-up of any file, use the following command at any time throughout this tutorial:

To read any file, use the following command at any time throughout this tutorial:

To edit any file in the text editor , use the following command (choosing Nano or VI) at any time throughout this tutorial:

To see how much RAM is being used, use the following command at any time throughout this tutorial:

For the Example System, this command responds with:

The above simply tells us that the computer is running 3042MB physical RAM and is currently wanting to use a maximum value of 179MB RAM. Otherwise, to see how much disk space is being used, use the following command at any time throughout this tutorial:

For the Example System, this command responds with:

To review your LVM setup, use the following command at any time throughout this tutorial:

For the Example System, this command responds with:

Manage your Firewall

To check your Firewall, otherwise referred to as IPTables, use the following command at any time throughout this tutorial:

For the Example System, this command responds with:

"IPTables run in a sequence, so when editing your IPTable rules make sure that the important stuff is near the top of the page."

To edit your Firewall (IPTables) at the command prompt type:

Example 1: To reduce the ferocity of SSH attacks with iptables, add the following to your rules:

This will force a visitor or bot to wait 60 seconds before they are allowed to try again after having failed 4 login attempts.

Example 2: To allow only a specific IP addresses to connect to SSH (where XXX.XXX.XXX.XXX is the IP address concerned), add the following to your rules:

Example 3: To block a specific IP addresses (where XXX.XXX.XXX.XXX is the IP address concerned), add the following to your rules:

Remember, if you have made any changes to your IPTables, always save/close the file and then restart the service by typing:

Set LVM Filters (optional)

In many respects this is entirely optional and only needs to be referred to if you would like to remove your CD-Rom from the LVM boot routine. Should you wish to do this you will need to complete the following tasks.

At the command prompt type:

Find and comment the following lines like so:

And add the following line instead:

So it looks like:

Then close and save the file. And now type:

And delete any reference to the device named 'hda'. Then close and save the file.

Log File Configuration (optional)

For most people the standard log file rotation scheme will be enough, but let's say you want your logs to rotate on a daily basis for 30 days (compressing the old logs). To do this, simply open up the following file and make the necessary changes:

Background Services

CentOS, like all operating systems runs background services. Some of them are important whereas many others are obviously not necessary and simply waste resources. So with this in mind lets take a few moments to switch on or off the following services, by doing this we will stop these services from starting-up at the next reboot..

To proceed simply copy/paste or type the following command into your console - one line at a new time.

You should have typed "chkconfig bluetooth off", and as a result you will see something similar to the following in your console window:

Congratulations, and as a consequence of this you have now switched off the blue tooth service which will save a lot of resources.

Now, let's complete this routine and make sure the following services are turned off. Like before we will simply copy/paste or type the following commands into your console - one line at a new time. In this example I will be switching off IP6TABLES (IPv6 Firewall) as the system we are building will not be using them.

To proceed, type these commands one line at a time:

And now, let's make sure the following services are turned on:

And finally, to check which services are running, use the following command at any time throughout this tutorial:

So, let's reboot the computer so that changes to can be applied.

Networking - Part 1

The networking capabilities of your server are essential, and even though we configured these during the installation process we need to make a final visit to make sure that they are running perfectly and that we remove any excess resources they do not need.

RHEL based servers generally keep all the networking files in '/etc/sysconfig/' where you will find subsequent folders such as '/etc/sysconfig/network-scripts/' and '/etc/sysconfig/networking/'. We will restrict our attention to the first two, but before we begin and just to be on the safe side it is always a good idea to make a 'backup' of these files. So, as described above, we shall use the copy command to replicate these files in an easy to remember backup format (notice the .bak extension).

Consequently, if you ever make a mistake can simply call the following command to restore your original file.

So let's begin ...

The example server for this tutorial features a single ethernet connection known as 'ifcfg-eth0'. So let's open that file in our favourite text editor like so:

And if your server is using the suggested 192.168.1 addressing schema you will want to finalise the settings so they look similar to the following but remembering to change the network values in order to match your own settings:

For example, the IPADDR and HWADDR lines should reflect the chosen IP address you wish to use for this server whereas the latter should show the same MAC address as was originally found. Should you ever make a mistake and lose your network card's MAC address, simply type the following in to the console (ignoring the hash):

Which should respond with something as follows:

The sequence of hexadecimal digits that appears to the right of eth0 HWAddr (i.e. 00:17:31:B2:80:99) is your network card's MAC Address.

Add a second IP address to eth0 (optional)

This section is optional and need only be used by those who need more than one IP address on a single interface. If you only need a single IP address then simply skip this section and go to Networking - Part 2.

As described above, if we assume our primary network interface is configured correctly we will need to copy these settings to a new, virtual network interface called 'eth0:0' like so:

And if your original IP address is 192.168.1.100 you will want to finalise the settings in our virtual interface so it looks similar to the following:

As you can see, we have removed the HWADDR line as this will be a replica of that on the main interface. We have used a new IP address (192.168.1.101) and simply renamed the DEVICE handler (to eth0:0).

On completion we have to restart the network like so:

This will respond with something similar to the following:

And we can confirm our settings like so:

Again, this will respond with something similar to the following:

Networking - Part 2

Now we want to edit our hosts file. So let's open it up in our favourite text editor like so:

And make it look like so, remembering to customise the settings to match your needs:

Now we want to edit our hosts file. So let's open it up in our favourite text editor like so:

Simply change the contents of '/etc/hosts' to look as follows but remembering to customise the settings to match your needs:

As you will remember from our installation procedures the example computer called 'servername.serverdomain.lan' is not using IPv6. If you have configured multiple IP addresses then remember to use your primary address in this file.

Now we want to edit our resolve.conf file. So let's open it up in our favourite text editor like so:

Simply change the contents of '/etc/resolve.conf' to look as follows but remembering to customise the settings to match your needs:

To confirm the above 'hosts' and 'resolve.conf' settings we do this:

Both 'hostname' and 'hostname -f' should respond with your full computer name (i.e 'servername.serverdomain.lan') whilst the result from 'nslookup' would look as follows:

If everything responds correctly, and in order to optimise our system resources to finish off we will remove the Network Manager (which is a feature generally associated with desktop-based installations that may use DHCP). At the command prompt type:

Confirm the request to remove Network Manager and then, having completed the following steps it is always simpler to reboot the entire system:

Post Network configuration checks

Having re-started your machine and returned as the 'root user' we want to make sure that our networking started correctly.

To do this we simply re-visit some of our previous steps like so:

As before, if everything reports without any issues then we can proceed to the next step ...

Time, Language and Location

First of all, we will want to confirm that the language file is using the correct settings. By using the following command we will open up the language file in our favourite text editor:

Most systems will automatically default to the US language but if you remember from the original installation the example machine is UK based so it should look similar to the following ...

We simply replaced 'en_US.UTF-8' with 'en_GB.UTF-8'. Now save the file and enter the following command to confirm our localisation settings:

If entered correctly it should respond with something similar to the following:

At the prompt simply type in a number that refers to your location::

As you can see, I have selected number '8' for 'Britain (UK)' and the console responds as follows:

Choose '1' to confirm these settings or '2' to cancel and choose another location.

If you have confirmed the current settings the console will respond in the appropriate manner detailing your location information like so:

If you want to have the system clock synchronized with an external NTP server simply install the NTP software and switch the service on at boot:

To confirm our NTP software simply type the following:

Which should respond with the correct date and time like so:

Yum Updates

Let's update the system ...

Accept any updates that are made available to you and reboot to complete this stage.


Step 3: Additional Hard Disks, Directories, Printing & Backups

Based on the original specification of the Example Server described at the beginning of this tutorial we will now turn towards the task of adding an additional hard disk. This section is entirely optional so if you have no additional hard disks to add to your computer, simply jump to Stage 4 below.

First of all we will need to switch off our computer and attach our additional hard disk.

So login is as the 'root user' and type:

Let's recap on what we said at the outset of this tutorial:

  • In the original specification I have an additional drive called 'Drive 3'
  • The purpose of this hard disk to act as a back-up to the activity of file sharing.
  • We will not be adding this to the LVM for one very good reason. If the LVM fails it is quite an ordeal to rebuild it, so for simplicity (as we all like simplicity) the third drive will be mounted as an EXT3 formatted drive in a suitable location on our system (i.e. /backup). This will ensure that the data on this hard disk is not affected by any failure of the main system. An LVM failure is not expected, but 'never say never ... and always be prepared' as LVM failures are arguably hardware related.

Connect your third hard drive following the instructions on your motherboard's user manual and switch your computer back on - when you are able to do so, login as the root user and let's change our identity to the 'super user' with the following command:

And use the following command to display all hard disks with their relevant device names:

The response could look similar to the following:

From the consoles response you will notice a number of disks listed, each with a relevant device name (as listed on the left-hand side of above read-out). Where both '/dev/sda' and '/dev/sdb' are used by LVM to form the base system the disk we have just added should be listed as '/dev/sdc'.

By taking a closer look we can see that device name '/dev/sdc' is currently un-formatted and thus the console reports the following information:

Format your new hard disk

By referencing the correct device name type (replacing 'sdc' with the correct value) use the following command:

The response will look similar to this:

As it states on the console, simply type 'm' for help but these are the main commands you will need to know/use:

If your disk is like mine, un-formatted, then jump to the section titled 'create a new partition on your hard disk'.
Otherwise, if your is pre-formatted with existing data, read on ...

Delete/Blank all existing data on your hard disk

If you need to delete any data on your hard disk, use the following routine (typing one line at a time):

In the above example we initially used 'd' to delete the partition and then 'w' to replace the partition table on the disk.
When finished, you will exit from the fdisk feature, therefore you will need to re-open your disk with:

And confirm the disk is blank by typing:

The 'p' command will print the current hard disk partition table and you should see a blank partition table. To quit fdisk type:

Having created a partition table on your hard disk you should now read-on and learn how to 'create a new partition on your hard disk'.

Create a new partition on your hard disk

To make the disk useful to us, first of all we need to create a partition - i.e. sdc1. This is very simple to do but be very careful not to target the wrong disk, this action cannot be undone - like all actions described in this Step 3.

So by replacing 'sdc' with the correct value follow this routine (one line at a time):

Type 'n' like so:

The response will look similar to this:

Choose 'p' and then elect number '1' when asked for a partition number like so:

During the next step, simply accept the default values as shown and hit the <RETURN> key:

And again, when asked simply accept the default values as shown and hit the <RETURN> key::

Confirm your instruction by typing:

The 'p' command will print-out your intended plan to create a new partition table (i.e depending on the device name you will see a partition table called sda1 or sdb1 or sdc1 etc .. etc ...) like so:

If you have made a mistake at this stage simply type 'q' and start again, but if you are happy to proceed then type:

The computer will now write the partition table to the disk and when complete the console will respond with a similar message to that as follows:

Format your hard disk

To format your hard disk using the EXT3 format, simply type the following (replacing 'sdc1' with the correct value):

The subsequent operation will look similar to this:

When complete the console will respond appropriately and you can re-check your work with:

The above command should show all your hard disks (including the new disk) with a valid partition and file format or you may use the following 'human-friendly' command:

Mount your hard disk

We now need to mount your new hard disk.

Mount points are like directories or folders and that are very simple to create and should always be created as the 'root user' like so:

or

So, for the Example System, let's create a mount point in the root of our drive called 'backup' like so:

And that's it, now we must modify 'fstab' in order that we can automatically mount our drive at start-up.

However, because 'fstab' is a very important file, before we begin, let's back it up:

So if your computer fails to boot, all you need to do is jump into rescue mode and replace the recently edited file with the back-up file like so:

Now, let's open /etc/fstab file, with:

It could look something like this:

And append like so:

Use the <TAB> key to create the relevant spaces, then save and close the file.
And finally, to complete this stage, simply reboot your computer and if all goes well you can now decide to create some working folders or jump to Step 4 below ..

How to create working folders

Creating working folders on CentOS is exactly the same as any other Linux based distribution. So, let's assume we want to add some working directories to our new partitioned and formatted backup drive located at /backup. Simply create a folder like so:

Having created our folder as a the 'root user' it is always good practice to change the permissions for accessibility by other accounts. So decide what permissions you would like to grant to this folder (based on its purpose) and simply run the following command:

In the above command we simply changed the permission of 'my-new-folder' to 0755.

Rsync

Based on the format of this tutorial you will discover that RSYNC is installed by default. You can confirm this by typing:

YUM Priorities & Rsnapshot (optional)

RSNAPSHOT is not available through the standard YUM repositories so we will need to install the EPEL repository and YUM priorities.

To install the EPEL repository we need to type the following command:

Following this, we need to install YUM priorities with the following command:

We should now confirm YUM priorities is installed correctly with the following command:

The console should respond as follows:

Now you need to review all your repositories and give them a priority number from 1-99 the repositories with the lowest number get the highest priority, so it would be advisable to set all the CentOS repositories to 1.

Open the CentOS-Base.repo file like so:

It will look similar to this but I have already made the relevant changes (compare them to see if you can see what I have done):

Did you notice the additional statement 'priority=X' under every 'gpgkey' location regardless of whether the source was enabled or not?
So simply make the relevant changes and save/close this file.

We now need to make a similar change to the EPEL file but by giving it a higher number like so:

And make it resemble the following:

To finish off installing YUM priorities you should also give all other references a priority number of 2 or more with the exception of 'epel-testing.repo' which should share the same value used by the 'epel.repo' above.

So open each of the following files in order and make the necessary changes:

When complete, to proceed we can install Rsnapshot like so:

Now open the following file, to begin making the relevant changes you need to customise your RSNAPSHOT settings:

When complete, simply save and close the file. You have now installed rsnapshot.

Create an SSL certificate (optional)

Use the following instruction to create a typical SSL Certificate. However, if you are intending to use an SSL certificate for business purposes then you should purchase an SSL certificate from a suitable provider.

And then type (filling in the required details when asked):

Now type, filling in the required details when asked:

Now type (filling in the required details when asked):

Now type (filling in the required details when asked):

Followed by:

And finally:

Print Support with CUPS (optional)

At the beginning of this tutorial we originally disabled CUPS. However, if you would like to re-instate the CUPS printing service then read on. We will not be discussing drivers for individual printers or web access, but the following instruction will give you a starting point on which to build your very own print server..

Install CUPS like so:

And in order to begin making the necessary changes, simply edit the following file as required:

This should get you started:

Now edit the following file:

And un-comment:

Now run:

The console should respond as follows:

And finally switch the service back on at boot:


Step 4: User Management & Samba

Well done ... We now have a fully functioning base system so let's turn CentOS into a standalone file server and add some users.
At the following screen, login as the root user:

Samba Server

Update YUM:

Accept any available updates then install Samba with:

Now we will need to modify our smb.conf file, but before we do - let's back it up:

And then begin editing like so:

Make following basic changes, customising the relevant values to suit your needs and using any other features as required:

Now start the Samba Server like so:

Activate the Samba Server at start-up like so:

Users

In order to finalise our installation we need to add some users, create relevant folders for them and give them the required permissions to work in a file-sharing environment..

Do this like so, remembering to customise the 'username' as required and to provide a password when requested:

Repeat the above steps for each user on your network.

When complete, we now need to add these users to our Samba server like so, providing a password when requested:

Repeat the above steps for each user on your network.

When complete, just complete a final reboot ...

And that's it ... well done :-)


Supplementary: Gnome Desktop & Updates

And just before anyone asks, (if you really want one) in order to install a desktop interface simply complete the following step:

When the installation is complete, type:

Login as root in the usual way and type:

To install an easy to use graphical package manager (also known as Yum Extender):

Should you wish to remove the Gnome Desktop environment at any time, use:

To keep your server up to date use:

To shutdown your server use:

And that's it ... well done :-)

In the next tutorial, we will look at CentOS as a comprehensive web server, supporting Apache Virtual Hosts, Bind, MySQL, PHP5.3, Webmin, Third Party Repositories and much, much more.

Tags:

Comments

Related Articles