NFS SERVER SETUP ON CETNOS 6.5 / Redhat 6.5 / Fedora

In this tutorial let us see how to install and configure NFS server and how to share files between NFS server and clients. Though i have tested these steps in Cent-OS 6.5 32 bit edition, it will work on RHEL/Fedora/ 64 bit architecture.

Scenario

NFS Server Operating System : CentOS 6.5 64 bit (Minimal server install)

NFS Server Operating System  : CentOS 6.5 64 bit (Minimal server install)

NFS Client Operating System  : CentOS 6.5 64 bit (Desktop Minimal)

NFS Server IP Address              Host rackspace-nfs01: 192.168.58.152

NFS Server IP Address              Host rackspace-nfs02: 192.168.58.153

NFS Client IP Address               Host rackspace-jon: 192.168.58.154

SERVER 01

[root@rackspace-nfs01 ~]# yum install nfs* -y

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: stingray.cyber.net.pk

* extras: stingray.cyber.net.pk

* updates: stingray.cyber.net.pk

Setting up Install Process

Package nfs-utils-lib-1.1.5-6.el6.x86_64 already installed and latest version

Package 1:nfs-utils-1.2.3-39.el6.x86_64 already installed and latest version

Resolving Dependencies

–> Running transaction check

—> Package nfs-utils-lib-devel.x86_64 0:1.1.5-6.el6 will be installed

–> Processing Dependency: pkgconfig(libgssglue) for package: nfs-utils-lib-devel-1.1.5-6.el6.x86_64

—> Package nfs4-acl-tools.x86_64 0:0.3.3-6.el6 will be installed

–> Running transaction check

—> Package libgssglue-devel.x86_64 0:0.1-11.el6 will be installed

–> Finished Dependency Resolution

 

Dependencies Resolved

 

===================================================================================== Package                                                Arch                                      Version                                        Repository                               Size

=====================================================================================Installing:

nfs-utils-lib-devel                                    x86_64                                    1.1.5-6.el6                                    base                                     67 k

nfs4-acl-tools                                         x86_64                                    0.3.3-6.el6                                    base                                     43 k

Installing for dependencies:

libgssglue-devel                                       x86_64                                    0.1-11.el6                                     base                                     11 k

 

Transaction Summary

=====================================================================================

Install       3 Package(s)

 

Total download size: 121 k

Installed size: 368 k

Downloading Packages:

(1/3): libgssglue-devel-0.1-11.el6.x86_64.rpm                                                                                                                           |  11 kB     00:00

(2/3): nfs-utils-lib-devel-1.1.5-6.el6.x86_64.rpm                                                                                                                       |  67 kB     00:00

(3/3): nfs4-acl-tools-0.3.3-6.el6.x86_64.rpm                                                                                                                            |  43 kB     00:00

——————————————————————————————————————————————

Total                                                                                                                                                          143 kB/s | 121 kB     00:00

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : libgssglue-devel-0.1-11.el6.x86_64                                                                                                                                          1/3

Installing : nfs-utils-lib-devel-1.1.5-6.el6.x86_64                                                                                                                                      2/3

Installing : nfs4-acl-tools-0.3.3-6.el6.x86_64                                                                                                                                           3/3

Verifying  : nfs4-acl-tools-0.3.3-6.el6.x86_64                                                                                                                                           1/3

Verifying  : nfs-utils-lib-devel-1.1.5-6.el6.x86_64                                                                                                                                      2/3

Verifying  : libgssglue-devel-0.1-11.el6.x86_64                                                                                                                                          3/3

 

Installed:

nfs-utils-lib-devel.x86_64 0:1.1.5-6.el6                                                         nfs4-acl-tools.x86_64 0:0.3.3-6.el6

 

Dependency Installed:

libgssglue-devel.x86_64 0:0.1-11.el6

 

Complete!

 

[root@rackspace-nfs01 ~]# echo 192.168.58.152 rackspace-nfs01 >> /etc/hosts

[root@rackspace-nfs01 ~]# echo 192.168.58.153 rackspace-nfs02 >> /etc/hosts

Now Setup Hosts file on both servers

[root@rackspace-nfs01 ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.58.152 rackspace-nfs01

192.168.58.153 rackspace-nfs02

 Test Network connections  on Both Servers

[root@rackspace-nfs01 ~]# ping rackspace-nfs01

PING rackspace-nfs01 (192.168.58.152) 56(84) bytes of data.

64 bytes from rackspace-nfs01 (192.168.58.152): icmp_seq=1 ttl=64 time=0.171 ms

64 bytes from rackspace-nfs01 (192.168.58.152): icmp_seq=2 ttl=64 time=0.054 ms

 

[root@rackspace-nfs01 ~]# ping rackspace-nfs02

PING rackspace-nfs02 (192.168.58.153) 56(84) bytes of data.

64 bytes from rackspace-nfs02 (192.168.58.153): icmp_seq=1 ttl=64 time=0.899 ms

64 bytes from rackspace-nfs02 (192.168.58.153): icmp_seq=2 ttl=64 time=0.255 ms

 Now Setup SELinux

[root@rackspace-nfs01 ~]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing – SELinux security policy is enforced.

#     permissive – SELinux prints warnings instead of enforcing.

#     disabled – No SELinux policy is loaded.

SELINUX=disabled #(Please disable SE LINUX)

# SELINUXTYPE= can take one of these two values:

#     targeted – Targeted processes are protected,

#     mls – Multi Level Security protection.

SELINUXTYPE=targeted

:wq!

 Stop Iptables Firewall

[root@rackspace-nfs01 ~]# /etc/init.d/iptables stop

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading modules:                               [  OK  ]

 

 

[root@rackspace-nfs01 ~]# /etc/init.d/nfs start

Starting NFS services:                                     [  OK  ]

Starting NFS mountd:                                       [  OK  ]

Starting NFS daemon:                                       [  OK  ]

Starting RPC idmapd:                                       [  OK  ]

 

[root@rackspace-nfs01 ~]# chkconfig nfs on

 

[root@rackspace-nfs01 /]# fdisk -l

 

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00050401

 

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              64        2611    20458496   8e  Linux LVM

 

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

 

 

Disk /dev/mapper/vg_rackspacenfs01-lv_root: 18.9 GB, 18865979392 bytes

255 heads, 63 sectors/track, 2293 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

 

 

Disk /dev/mapper/vg_rackspacenfs01-lv_swap: 2080 MB, 2080374784 bytes

255 heads, 63 sectors/track, 252 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

 

Create Disk Partition for NFS Server.

[root@rackspace-nfs01 /]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x7c08daf5.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won’t be recoverable.

 

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to

switch off the mode (command ‘c’) and change display units to

sectors (command ‘u’).

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-652, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652):

Using default value 652

 

Command (m for help): p

 

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x7c08daf5

 

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         652     5237158+  83  Linux

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

[root@rackspace-nfs01 /]# mkfs.ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

327680 inodes, 1309289 blocks

65464 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1342177280

40 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736

 

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 39 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

[root@rackspace-nfs01 /]# cd mnt/

[root@rackspace-nfs01 mnt]# ll

total 0

[root@rackspace-nfs01 mnt]# mkdir VD-NFS

[root@rackspace-nfs01 mnt]# ll

total 4

drwxr-xr-x. 2 root root 4096 Jun 21 15:07 VD-NFS

 

[root@rackspace-nfs01 mnt]# mount /dev/sdb1 VD-NFS/

[root@rackspace-nfs01 mnt]# ll

total 4

drwxr-xr-x. 3 root root 4096 Jun 21 15:05 VD-NFS

[root@rackspace-nfs01 mnt]# df -hT

Filesystem                            Type   Size  Used Avail Use% Mounted on

/dev/mapper/vg_rackspacenfs01-lv_root ext4    18G  3.7G   13G  23% /

tmpfs                                 tmpfs  495M     0  495M   0% /dev/shm

/dev/sda1                             ext4   485M   34M  426M   8% /boot

/dev/sdb1                             ext4   5.0G  138M  4.6G   3% /mnt/VD-NFS

 

Add  New Partition Exntry into FSTAB for Auto Mount

[root@rackspace-nfs01 ~]# vi /etc/fstab

#

# /etc/fstab

# Created by anaconda on Sat Jun 21 11:40:09 2014

#

# Accessible filesystems, by reference, are maintained under ‘/dev/disk’

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/vg_rackspacenfs01-lv_root /                       ext4    defaults        1 1

UUID=a741a110-4272-485b-adcc-53467856dec3 /boot                   ext4    defaults        1 2

/dev/mapper/vg_rackspacenfs01-lv_swap swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

/dev/sdb1               /mnt/VD-NFS             ext4    defaults        0 2

:wq!

 Now Setup Exports on NFS Server

[root@rackspace-nfs01 mnt]# vi /etc/exports

/mnt/VD-NFS 192.168.58.152 (rw,sync,no_root_squash,no_all_squash)

 

[root@rackspace-nfs01 mnt]# /etc/init.d/nfs restart

Shutting down NFS daemon:                                  [  OK  ]

Shutting down NFS mountd:                                  [  OK  ]

Shutting down RPC idmapd:                                  [  OK  ]

Starting NFS services:  exportfs: No options for /mnt/VD-NFS 192.168.58.152: suggest 192.168.58.152(sync) to avoid warning

exportfs: No host name given with /mnt/VD-NFS (rw,sync,no_root_squash,no_all_squash), suggest *(rw,sync,no_root_squash,no_all_squash) to avoid warning

[  OK  ]

Starting NFS mountd:                                       [  OK  ]

Starting NFS daemon:                                       [  OK  ]

Starting RPC idmapd:                                       [  OK  ]

 

Next we  need to mount NFS Server exports on NFS Client.

[root@rackspace-jon ~]# mount -t nfs 192.168.58.152:/mnt/VD-NFS /mnt/

[root@rackspace-jon ~]# df -HT

Filesystem                          Type   Size  Used Avail Use% Mounted on

/dev/mapper/vg_rackspacejon-lv_root ext4    19G  3.9G   14G  22% /

tmpfs                               tmpfs  519M     0  519M   0% /dev/shm

/dev/sda1                           ext4   508M   36M  447M   8% /boot

192.168.58.152:/mnt/VD-NFS          nfs    5.3G  145M  4.9G   3% /mnt

Great we can mount successfully.

[root@rackspace-jon mnt]# mount

/dev/mapper/vg_rackspacejon-lv_root on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw,rootcontext=”system_u:object_r:tmpfs_t:s0″)

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

192.168.58.152:/mnt/VD-NFS on /mnt type nfs (rw,vers=4,addr=192.168.58.152,clientaddr=192.168.58.154)

 

Add NFS Shares on Client Machines for Auto mount

[root@rackspace-jon ~]# vi /etc/fstab

#

# /etc/fstab

# Created by anaconda on Sat Jun 21 12:15:50 2014

#

# Accessible filesystems, by reference, are maintained under ‘/dev/disk’

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/vg_rackspacejon-lv_root /                       ext4    defaults        1 1

UUID=6b1625d0-3022-4dad-adb0-d237c148ad48 /boot                   ext4    defaults        1 2

/dev/mapper/vg_rackspacejon-lv_swap swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

 

192.168.58.152:/mnt/VD-NFS /mnt/                        nfs     rw,sync,hard,intr       0 0

:wq!

Now we can reboot NFS client Machine & verify next boot time nfs Share Automatically mounted.

[root@rackspace-jon ~]# init 6

Great we have  done successfully.

 

SERVER 02

[root@rackspace-nfs02 ~]# yum install nfs* -y

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirrors.ispros.com.bd

* extras: mirrors.ispros.com.bd

* updates: mirrors.ispros.com.bd

Setting up Install Process

Package nfs-utils-lib-1.1.5-6.el6.x86_64 already installed and latest version

Package 1:nfs-utils-1.2.3-39.el6.x86_64 already installed and latest version

Resolving Dependencies

–> Running transaction check

—> Package nfs-utils-lib-devel.x86_64 0:1.1.5-6.el6 will be installed

–> Processing Dependency: pkgconfig(libgssglue) for package: nfs-utils-lib-devel-1.1.5-6.el6.x86_64

—> Package nfs4-acl-tools.x86_64 0:0.3.3-6.el6 will be installed

–> Running transaction check

—> Package libgssglue-devel.x86_64 0:0.1-11.el6 will be installed

–> Finished Dependency Resolution

 

Dependencies Resolved

 

=====================================================================================

Package                                                Arch                                      Version                                        Repository                               Size

=====================================================================================

Installing:

nfs-utils-lib-devel                                    x86_64                                    1.1.5-6.el6                                    base                                     67 k

nfs4-acl-tools                                         x86_64                                    0.3.3-6.el6                                    base                                     43 k

Installing for dependencies:

libgssglue-devel                                       x86_64                                    0.1-11.el6                                     base                                     11 k

 

Transaction Summary

=====================================================================================

Install       3 Package(s)

 

Total download size: 121 k

Installed size: 368 k

Downloading Packages:

(1/3): libgssglue-devel-0.1-11.el6.x86_64.rpm                                                                                                                           |  11 kB     00:00

(2/3): nfs-utils-lib-devel-1.1.5-6.el6.x86_64.rpm                                                                                                                       |  67 kB     00:00

(3/3): nfs4-acl-tools-0.3.3-6.el6.x86_64.rpm                                                                                                                            |  43 kB     00:00

——————————————————————————————————————————————

Total                                                                                                                                                           46 kB/s | 121 kB     00:02

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : libgssglue-devel-0.1-11.el6.x86_64                                                                                                                                          1/3

Installing : nfs-utils-lib-devel-1.1.5-6.el6.x86_64                                                                                                                                      2/3

Installing : nfs4-acl-tools-0.3.3-6.el6.x86_64                                                                                                                                           3/3

Verifying  : nfs4-acl-tools-0.3.3-6.el6.x86_64                                                                                                                                           1/3

Verifying  : nfs-utils-lib-devel-1.1.5-6.el6.x86_64                                                                                                                                      2/3

Verifying  : libgssglue-devel-0.1-11.el6.x86_64                                                                                                                                          3/3

 

Installed:

nfs-utils-lib-devel.x86_64 0:1.1.5-6.el6                                                         nfs4-acl-tools.x86_64 0:0.3.3-6.el6

 

Dependency Installed:

libgssglue-devel.x86_64 0:0.1-11.el6

 

Complete!

 

[root@rackspace-nfs02 ~]# echo 192.168.58.153 rackspace-nfs02 >> /etc/hosts

[root@rackspace-nfs02 ~]# echo 192.168.58.152 rackspace-nfs01 >> /etc/hosts

 

 

[root@rackspace-nfs02 ~]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.58.153 rackspace-nfs02

192.168.58.152 rackspace-nfs01

 

[root@rackspace-nfs02 ~]# ping rackspace-nfs01

PING rackspace-nfs01 (192.168.58.152) 56(84) bytes of data.

64 bytes from rackspace-nfs01 (192.168.58.152): icmp_seq=1 ttl=64 time=1.66 ms

64 bytes from rackspace-nfs01 (192.168.58.152): icmp_seq=2 ttl=64 time=0.275 ms

 

[root@rackspace-nfs02 ~]# ping rackspace-nfs02

PING rackspace-nfs02 (192.168.58.153) 56(84) bytes of data.

64 bytes from rackspace-nfs02 (192.168.58.153): icmp_seq=1 ttl=64 time=0.055 ms

64 bytes from rackspace-nfs02 (192.168.58.153): icmp_seq=2 ttl=64 time=0.043 ms

 

[root@rackspace-nfs02 ~]# vi /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

#     enforcing – SELinux security policy is enforced.

#     permissive – SELinux prints warnings instead of enforcing.

#     disabled – No SELinux policy is loaded.

SELINUX=disabled  #(Please disabled SELINUX)

# SELINUXTYPE= can take one of these two values:

#     targeted – Targeted processes are protected,

#     mls – Multi Level Security protection.

SELINUXTYPE=targeted

 

[root@rackspace-nfs02 ~]# /etc/init.d/iptables stop

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading modules:                               [  OK  ]

 

Make New Partition on NFS02

[root@rackspace-nfs02 ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0008ecd3

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              64        2611    20458496   8e  Linux LVM

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/vg_rackspacenfs02-lv_root: 18.9 GB, 18865979392 bytes

255 heads, 63 sectors/track, 2293 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/vg_rackspacenfs02-lv_swap: 2080 MB, 2080374784 bytes

255 heads, 63 sectors/track, 252 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

 

[root@rackspace-nfs02 ~]# fdisk /dev/sd

sda   sda1  sda2  sdb

[root@rackspace-nfs02 ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x30daeb2e.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won’t be recoverable.

 

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to

switch off the mode (command ‘c’) and change display units to

sectors (command ‘u’).

 

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-652, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652):

Using default value 652

 

Command (m for help): p

 

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x30daeb2e

 

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         652     5237158+  83  Linux

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

Create File System.

[root@rackspace-nfs02 ~]# mkfs.ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

327680 inodes, 1309289 blocks

65464 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1342177280

40 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736

 

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 30 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

[root@rackspace-nfs02 ~]# cd /mnt/

[root@rackspace-nfs02 mnt]# ll

total 0

[root@rackspace-nfs02 mnt]# mkdir HD-NFS

[root@rackspace-nfs02 mnt]# ll

total 4

drwxr-xr-x. 2 root root 4096 Jun 21 16:24 HD-NFS

[root@rackspace-nfs02 mnt]# mount /dev/sdb

sdb   sdb1

[root@rackspace-nfs02 mnt]# mount /dev/sdb1 HD-NFS/

[root@rackspace-nfs02 mnt]# df -hT

Filesystem                            Type   Size  Used Avail Use% Mounted on

/dev/mapper/vg_rackspacenfs02-lv_root ext4    18G  3.7G   13G  23% /

tmpfs                                 tmpfs  495M     0  495M   0% /dev/shm

/dev/sda1                             ext4   485M   34M  426M   8% /boot

/dev/sdb1                             ext4   5.0G  138M  4.6G   3% /mnt/HD-NFS

 

Add entry for Auto Mount of New Partition in FSTAB

[root@rackspace-nfs02 ~]# vi /etc/fstab

#

# /etc/fstab

# Created by anaconda on Sat Jun 21 11:44:34 2014

#

# Accessible filesystems, by reference, are maintained under ‘/dev/disk’

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/vg_rackspacenfs02-lv_root /                       ext4    defaults        1 1

UUID=2638509e-735f-479b-964e-e6b61806dc97 /boot                   ext4    defaults        1 2

/dev/mapper/vg_rackspacenfs02-lv_swap swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

 

/dev/sdb1               /mnt/HD-NFS             ext4    defaults        0 2

 

Great we can reboot NFS02 Server and Verify next Boot time the partition will be auto mounted.

 

Configure NFS02 Server

[root@rackspace-nfs02 ~]# vi /etc/exports

/mnt/HD-NFS 192.168.58.153 (rw,sync,no_root_squash,no_all_squash)

 

[root@rackspace-nfs02 ~]# /etc/init.d/nfs restart

Shutting down NFS daemon:                                  [  OK  ]

Shutting down NFS mountd:                                  [  OK  ]

Shutting down NFS services:                                [  OK  ]

Shutting down RPC idmapd:                                  [  OK  ]

Starting NFS services:  exportfs: No options for /mnt/HD-NFS 192.168.58.153: suggest 192.168.58.153(sync) to avoid warning

exportfs: No host name given with /mnt/HD-NFS (rw,sync,no_root_squash,no_all_squash), suggest *(rw,sync,no_root_squash,no_all_squash) to avoid warning

[  OK  ]

Starting NFS mountd:                                       [  OK  ]

Starting NFS daemon:                                       [  OK  ]

Starting RPC idmapd:                                       [  OK  ]

 

 

 

Next we can mount Second NFS Share on NFS Client.

[root@rackspace-jon ~]# mount -t nfs 192.168.58.153:/mnt/HD-NFS newmnt/

[root@rackspace-jon ~]# df -hT

Filesystem                          Type   Size  Used Avail Use% Mounted on

/dev/mapper/vg_rackspacejon-lv_root ext4    18G  3.6G   13G  22% /

tmpfs                               tmpfs  495M     0  495M   0% /dev/shm

/dev/sda1                           ext4   485M   34M  426M   8% /boot

192.168.58.152:/mnt/VD-NFS          nfs    5.0G  138M  4.6G   3% /mnt

192.168.58.153:/mnt/HD-NFS          nfs    5.0G  138M  4.6G   3% /newmnt

Great we can mount second NFS share successfully.

[root@rackspace-jon ~]# mount

/dev/mapper/vg_rackspacejon-lv_root on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw,rootcontext=”system_u:object_r:tmpfs_t:s0″)

/dev/sda1 on /boot type ext4 (rw)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

192.168.58.152:/mnt/VD-NFS on /mnt type nfs (rw,sync,hard,intr,vers=4,addr=192.168.58.152,clientaddr=192.168.58.154)

192.168.58.153:/mnt/HD-NFS on /newmnt type nfs (rw,sync,hard,intr,vers=4,addr=192.168.58.153,clientaddr=192.168.58.154)

 

We can Configure Auto mount second NFS Share.

[root@rackspace-jon ~]# vi /etc/fstab

#

# /etc/fstab

# Created by anaconda on Sat Jun 21 12:15:50 2014

#

# Accessible filesystems, by reference, are maintained under ‘/dev/disk’

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/vg_rackspacejon-lv_root /                       ext4    defaults        1 1

UUID=6b1625d0-3022-4dad-adb0-d237c148ad48 /boot                   ext4    defaults        1 2

/dev/mapper/vg_rackspacejon-lv_swap swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

 

192.168.58.152:/mnt/VD-NFS /mnt/                        nfs     rw,sync,hard,intr       0 0

192.168.58.153:/mnt/HD-NFS /newmnt/               nfs     rw,sync,hard,intr      0 0

 

Next we create Backup Shell Script.

 

[root@rackspace-jon ~]# vi /etc/cron.daily/backup-NFS1.sh

#!/bin/bash

#Purpose = Backup of Important Data

#Created on 24-June-2014

#Author = Muhammad Zeeshan Bhatti

#Version 1.0

#START

 

TIME=`date +”%d-%m-%y(%T)”`             # This Command will add date in Backup File Name.

FILENAME=”backup-$TIME.tar.gz”      # Here i define Backup file name format.

SRCDIR=”/tmp”                       # Location of Important Data Directory (Source of backup).

DESDIR=”/mnt/BACKUP-NFS1″           # Destination of backup file.

tar -cpzf $DESDIR/$FILENAME $SRCDIR

#END

:wq!

 

[root@rackspace-jon ~]#  vi /etc/cron.daily/backup-NFS2.sh

#!/bin/bash

#Purpose = Backup of Important Data

#Created on 24-June-2014

#Author = Muhammad Zeeshan Bhatti

#Version 1.0

#START

 

TIME=`date +”%d-%m-%y(%T)”`             # This Command will add date in Backup File Name.

FILENAME=”backup-NFS2-$TIME.tar.gz”      # Here i define Backup file name format.

SRCDIR=”/tmp”                       # Location of Important Data Directory (Source of backup).

DESDIR=”/newmnt/BACKUP-NFS2″           # Destination of backup file.

tar -cpzf $DESDIR/$FILENAME $SRCDIR

#END

:wq!

Next we can Create CRON Job for Automatic Backup Job Running every 4 Hours leter.

[root@rackspace-jon ~]# crontab -e

0 4,12,20 * * *  /bin/bash /etc/cron.daily/backup-NFS1.sh

0 8,16,0 * * * /bin/bash /etc/cron.daily/backup-NFS2.sh

 

Automatically backup successfully generated  on NFS1

[root@rackspace-jon ~]# ll /newmnt/BACKUP-NFS2/

total 384220

-rw-r–r–. 1 root root 393434160 Jun 22 15:56 backup-NFS2-22-06-14(16:00:01).tar.gz

 

 Automatically backup successfully generated  on NFS1

[root@rackspace-jon ~]# ll /mnt/BACKUP-NFS1/

total 384216

-rw-r–r–. 1 root root 393435154 Jun 22 18:25 backup-22-06-14(19:00:01).tar.gz

Recommended For You.

GitLab is an online Git repository manager with a wiki, issue tracking, CI and CD. It is a great way to

3 Replies to “How to install & configure GITLAB CI/CD on your own Server — Ubuntu 16.04”

  1. When I initially commented I clicked the “Notify me when new comments are added”
    checkbox and now each time a comment is added I
    get three e-mails with the same comment.
    Is there any way you can remove people from that service?
    Appreciate it!

Comments are closed.