How to Reset Forgotten Root Password on Linux RHEL 7/CentOS 7

Reset Forgotten Root Password

This article will explain the steps to reset a lost root password or to reset forgotten root password on Linux RHEL 7 or CentOS 7.

Basically, the steps will adding a “rd.break” to the end of the line with kernel parameters in Grub to stops the start up process before the regular root filesystem is mounted, hence the necessity to chroot into sysroot. Continue reading “How to Reset Forgotten Root Password on Linux RHEL 7/CentOS 7”

How to a Add and Remove User Account on RHEL 6/7, CentOS 6/7, Oracle Linux 6/7

This article will explain and share how to add and remove user account with useradd(add) and userdel (remove) from the command-line on linux RHEL 6/7, CentOS 6/7, Oracle Linux 6/7 server.

1. Adding a New User to an Linux System.

a) Get the useradd manual :

# man useradd
useradd - create a new user or update default new user information

b) To creates the new account and the /home/john home directory :

# useradd --home /home/ehowstuff ehowstuff

c) useraddd command does not set any valid password by default, and user cannot log in until a password is set.To set the password user the following command :

# passwd ehowstuff
Changing password for user ehowstuff.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

d) Verify the values in /etc/password :

# cat /etc/passwd | grep ehowstuff
ehowstuff:x:501:501::/home/ehowstuff:/bin/bash

e) Verify the values in /etc/group :

# cat /etc/group | grep ehowstuff
ehowstuff:x:501:

f) Verify email user created for id ehowstuff :

# ls /var/spool/mail | grep ehowstuff
ehowstuff

More useradd options :

-c, –comment COMMENT
Add a value, such as a full name, to the GECOS field.

-g, –gid GROUP
Specify the primary group for the user account.

-G, –groups GROUPS
Specify a list if supplementary groups for the user account.

-a, –append
Used with the -G option to append the user to the supplemental groups mentioned without removing the user from other groups.

-d, –home HOME_DIR
Specify a new home directory to a new location. Must be used with the -d option.

-m, –move-home
Move a user home directory to a new location. Must be used with the -d option.

-s, –shell SHELL
Specify a new login shell for the user account.

-L, –lock
Lock a user account.

-U, –unlock
Unlock a user account.

2. Deleting a User from an Linux System.

a) Get userdel manual :

# man userdel
userdel - delete a user account and related files

b) userdel username removes the user from /etc/passwd, but leaves the home directory intact by default. Proper command to remove the user’s account, user’s home directory and mail spool as part of the deletion process :

# userdel --remove ehowstuff

or

# userdel -r ehowstuff

Warning :
When a user is removed with userdel without the -r option specified, the system will have files that are owned by an unassigned user ID number. This can also happen when files created by a deleted user exist outside their home directory. This situation can lead to information leakage and other security issues.

 

How to Change RunLevel on CentOS 7 / RHEL 7

Old method to change the runlevel via /etc/inittab in Redhat Enterprise Linux version and CentOS server has become obsolete on RHEL 7 and CentOS 7. This latest Linux operating system uses systemd system management daemon and relies on systemctl command in order to change the runlevel. RunLevel is set with linking to /etc/systemd/system/default.target. Please make sure you have already install Gnome GUI before you proceed to change runlevel.

1. Check the current runlevel :

# runlevel
N 3

or

# systemctl get-default
multi-user.target

2. We can display the default.target by using list command :

# ll /etc/systemd/system/default.target
lrwxrwxrwx. 1 root root 37 Sep  1  2014 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target

3. For example to list all currently loaded targets :

# systemctl list-units -t target
UNIT                LOAD   ACTIVE SUB    DESCRIPTION
basic.target        loaded active active Basic System
cryptsetup.target   loaded active active Encrypted Volumes
getty.target        loaded active active Login Prompts
local-fs-pre.target loaded active active Local File Systems (Pre)
local-fs.target     loaded active active Local File Systems
multi-user.target   loaded active active Multi-User System
network.target      loaded active active Network
paths.target        loaded active active Paths
remote-fs.target    loaded active active Remote File Systems
slices.target       loaded active active Slices
sockets.target      loaded active active Sockets
swap.target         loaded active active Swap
sysinit.target      loaded active active System Initialization
timers.target       loaded active active Timers

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

14 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

4. Type the following command to change the RunLevel to Graphical-login :

# systemctl set-default graphical.target
rm '/etc/systemd/system/default.target'
ln -s '/usr/lib/systemd/system/graphical.target' '/etc/systemd/system/default.target'

5. Verify the changed runlevel :

# runlevel
N 5

or

# systemctl get-default
graphical.target

6. Reboot the server to login to GNOME gui.

redhat-banner

How to Install EPEL Yum Repository on Linux CentOS 7 / RHEL 7

Epel yum repository is an open source centos yum repository or rpm repository for developers and system administrators to perform the installation of RPM packages via yum on their virtual private server (VPS) or dedicated server.

EPEL yum repository is redhat yum repository for CentOS and additional yum repository for the existing CentOS repository.

It provides 100 % high quality software packages for Linux distributions, including RHEL (Red Hat Enterprise Linux), CentOS and Debian, and all packages maintained by Fedora repo team.

1. Prepare EPEL repository for RHEL 7/CentOS 7 64 bit (epel centos 7/epel rhel 7) :

# sudo rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
# # sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm

Example :

# sudo rpm --import https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
# sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
Retrieving https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-9                 ################################# [100%]

In CentOS 7, an alternative way to install the EPEL repo is by using the command yum :

# sudo yum install epel-release -y

2. Command to verify that the EPEL repository is enabled.

# sudo yum repolist

Sample output :

# sudo yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.linode.com
 * epel: ftp.osuosl.org
 * extras: mirrors.linode.com
 * updates: mirrors.linode.com
repo id                                                       repo name                                                                                 status
base/7/x86_64                                                 CentOS-7 - Base                                                                            9,363
epel/x86_64                                                   Extra Packages for Enterprise Linux 7 - x86_64                                            11,046
extras/7/x86_64                                               CentOS-7 - Extras                                                                            200
nginx/x86_64                                                  nginx repo                                                                                    41
updates/7/x86_64                                              CentOS-7 - Updates                                                                           438
varnish-4.1/x86_64                                            Varnish Cache 4.1 for Enterprise Linux                                                        31
repolist: 21,119

3. Install httpd package using epel repo option –enablerepo=epel :

# sudo yum --enablerepo=epel install httpd

EPEL Yum Repository

How to Remove / Uninstall Nginx on CentOS 7 / RHEL 7 / Oracle Linux 7

Nginx web server is alternative web server to Apache and Lighttpd. Nginx popularity now growing because it focuses on high concurrency, high performance while maintaining low memory usage. However, due to certain reasons webmaster or system administrator can not use Nginx on their server and decide to uninstall Nginx. Most of the webmaster, administrator and programmer still prefer to user Apache over Nginx as a web server because of the following reasons :

  • Not many webmaster, administrator and programmer comfortable with Nginx configuration
  • Apache has built-in support for a wide range of web programming languages, including Perl, PHP and Python
  • Apache languages are easy to learn and can be used to create powerful online applications
  • Apache is still the most popular web server on the Internet
  • Apache is the oldest web server, you won’t have any trouble finding people skilled in configuring it.

For the linux server platform that running on CentOS 7, RHEL 7 and Oracle linux 7, the removal step for Nginx is quite different from older version. Therefore, this article will explain the steps to remove or uninstall Nginx that was installed from source on CentOS 7, RHEL 7 and Oracle Linux 7.

Note : These steps to Remove / Uninstall Nginx has been tested on CentOS, RHEL and Oracle Linux platform and was running under root privilege.

1. Stop Nginx service and remove Nginx auto start script :

[root@rhel7 ~]# sudo systemctl stop nginx.service
[root@rhel7 ~]# sudo systemctl disable nginx.service

2. Remove Nginx user and it related directory :

[root@rhel7 ~]# sudo userdel -r nginx

3. Delete and related Nginx installation directory :

[root@rhel7 ~]# sudo rm -rf /etc/nginx
[root@rhel7 ~]# sudo rm -rf /var/log/nginx
[root@rhel7 ~]# sudo rm -rf /var/cache/nginx/

4. Remove the created nginx.service script under systemd :

[root@rhel7 ~]# sudo rm -rf /usr/lib/systemd/system/nginx.service

Uninstall Nginx

How to Grant a New User to Root Privileges on CentOS 6 / CentOS 7

One recommended way to manage virtual private server (VPS) or a dedicated linux server is not using the root account as the main access for SSH login. This is because usually the hackers will try to brute force your root password and potentially get access to your server. Instead of using the default root account, you can create a new account and assign root privileges to it and issue the sudo command line to root from it. Please make sure that the normal user account given root privileges accounts work properly before you disable the default root login access. The following command has been tested works on CentOS 6, CentOS 7, RHEL 6 and RHEL 7 VPS.

1. Create new account named skytech and set the password :

[root@vps ~]# useradd skytech
[root@vps ~]# passwd skytech
Changing password for user skytech.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

2. Grant a New User to Root Privileges

[root@vps ~]# visudo

Add the following code at the bottom of the file and save the file with the command :wq :

## Allow skytech user to run any commands anywhere
skytech    ALL=(ALL)       ALL

This will grant a root privileges to the normal user skytech.

linux-banner

How to Create LVM in Linux CentOS 7 / RHEL 7 / Oracle Linux 7

Storage technology plays a important role in improving the availability, performance, and ability to manage Linux servers.

One of the most useful and helpful technology to linux system administrator is Linux Logical Volume Manager(LVM), version 2 (or LVM 2).

LVM is a widely-used technique and extremely flexible disk management scheme for deploying logical rather than physical storage. With LVM, system administrator can easily resize and extend the logical drive when it is required.

Create Lvm

The following steps will describe how to create LVM in Linux CentOS 7 or RHEL 7 or Oracle Linux 7.

How to Create Lvm in Linux Step by Step

1. Add the new 20GB vdisk from the ESXi or vCenter :

Create Lvm

2. create a new Partiton using fdisk tool and select partition type LVM :

[root@centos7 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

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

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xfd3bf27d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    41943039    20970496   83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xfd3bf27d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    41943039    20970496   8e  Linux LVM

3. Initializes the partition /dev/sdb1 as an LVM physical volume :

[root@centos7 ~]# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created

4. Scanning for Block Devices

[root@centos7 ~]# lvmdiskscan
  /dev/centos/swap [       2.00 GiB]
  /dev/sda1        [     500.00 MiB]
  /dev/centos/root [      27.51 GiB]
  /dev/sda2        [      29.51 GiB] LVM physical volume
  /dev/sdb1        [      20.00 GiB] LVM physical volume
  2 disks
  1 partition
  0 LVM physical volume whole disks
  2 LVM physical volumes

5. Displaying Physical Volumes :

There are three commands you can use to display properties of LVM physical volumes: pvs,
pvdisplay, and pvscan.

The pvdisplay command provides a verbose multi-line output for each physical volume. It displays
physical properties (size, extents, volume group, etc.) in a fixed format.

[root@centos7 ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               29.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              7554
  Free PE               0
  Allocated PE          7554
  PV UUID               JvDOto-KDiF-gtca-TveX-ne9M-frsB-qsP1aJ

  "/dev/sdb1" is a new physical volume of "20.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               20.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               rJ8wl7-xzIN-2qqV-ov7Z-lHKe-ELge-aAV29V

The pvscan command scans all supported LVM block devices in the system for physical volumes

[root@centos7 ~]# pvscan
  PV /dev/sda2   VG centos          lvm2 [29.51 GiB / 0    free]
  PV /dev/sdb1                      lvm2 [20.00 GiB]
  Total: 2 [49.51 GiB] / in use: 1 [29.51 GiB] / in no VG: 1 [20.00 GiB]

6. Create volume group name vg_newlvm and add /dev/sdb1 partition into the group.

[root@centos7 ~]# vgcreate vg_newlvm /dev/sdb1
  Volume group "vg_newlvm" successfully created

If you have more than one partition, you can add multiple partition in single command. This command creates a local volume named vg_newlvm that contains physical volumes /dev/sdb1 and /dev/sdc1 :

[root@centos7 ~]# vgcreate vg_newlvm /dev/sdb1 /dev/sdc1

7. Creates a logical volume called centos7_newvol that uses all of the unallocated space in the volume group vg_newlvm :

[root@centos7 ~]# lvcreate --name centos7_newvol -l 100%FREE vg_newlvm
  Logical volume "centos7_newvol" created

You can see more example of lvcreate command in article “4 lvcreate Command Examples on Linux

8. Display the created logical volumes :

[root@centos7 ~]# lvdisplay
..
..
  --- Logical volume ---
  LV Path                /dev/vg_newlvm/centos7_newvol
  LV Name                centos7_newvol
  VG Name                vg_newlvm
  LV UUID                szlkNP-0lwe-f59Z-PJVU-X7pG-unBL-qN10D4
  LV Write Access        read/write
  LV Creation host, time centos7.ehowstuff.local, 2015-01-25 15:15:48 +0800
  LV Status              available
  # open                 0
  LV Size                20.00 GiB
  Current LE             5119
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

9. Use the mkfs command to format a newly created LVM :

[root@centos7 ~]# mkfs.ext4 /dev/vg_newlvm/centos7_newvol
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5241856 blocks
262092 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2153775104
160 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, 1605632, 2654208,
        4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

10. Create the mount point and mount the new LVM :

[root@centos7 ~]# mkdir -p /data
[root@centos7 ~]# mount /dev/vg_newlvm/centos7_newvol /data

11. Verify thew new disk layout :

[root@centos7 ~]# df
Filesystem                           1K-blocks    Used Available Use% Mounted on
/dev/mapper/centos-root               28260132 9191032  17610516  35% /
devtmpfs                               1935888       0   1935888   0% /dev
tmpfs                                  1941892       0   1941892   0% /dev/shm
tmpfs                                  1941892    8728   1933164   1% /run
tmpfs                                  1941892       0   1941892   0% /sys/fs/cgroup
/dev/sda1                               487634   73191    384747  16% /boot
tmpfs                                  1941892    8728   1933164   1% /var/named/chroot/run/named
/dev/mapper/vg_newlvm-centos7_newvol  20507216   45080  19397384   1% /data

Rescan SCSI Bus to Add or Remove a SCSI Devices on Linux

Rescan SCSI bus

When you need to add a hard disk or network interface cards on the new VMware virtual machine on the production server, but you are not allowed to shutdown the server or you have several related issues as below. The following quick article shows how to rescan SCSI Bus to add or remove a SCSI Devices on Linux.

This steps may work on CentOS 5/6/7 and RHEL 5/6/7.

Other related Issues

  • Is it possible to add or remove a SCSI device without rebooting a running system?
  • Can you scan a SCSI bus for new or missing SCSI devices without rebooting?
  • How can I make newly connected SCSI storage devices available without rebooting?
  • What is the Linux equivalent to the Solaris command devfsadm to add or remove storage devices?
  • I am trying to add a LUN to a live system but it is not recognized
  • I am trying to add a tape drive to a live system but it is not recognized
  • I am trying to add a disk drive to a live system but it is not recognized
  • How can I force a rescan of my SAN to find newly associated LUNs?
  • What to do if a newly allocated LUN on my SAN is not available?
  • Unable to probe for a newly allocated LUN
  • Some nodes can’t see my new storage device, how can I make it available?
  • After SAN maintenance activity, not all devices returned – devices in multipath missing or remain in failed state.
  • After SAN failover testing completed, not all devices returned to running state as expected – devices in multipath missing or remain in failed state.
  • What is the best way to remove a SCSI disk from the system

After Red Hat Enterprise Linux 5.0 (RHEL 5) and above (RHEL 6 and RHEL 7), it is possible to make changes to the SCSI I/O subsystem without rebooting.

How to Rescan SCSI Bus to Add or Remove a SCSI Devices on Linux

1. Identify host bus number :

# ls /sys/class/scsi_host/
host0  host1  host2

2. Rescan the SCSI Bus to Add a SCSI Devices :

# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "- - -" > /sys/class/scsi_host/host1/scan
# echo "- - -" > /sys/class/scsi_host/host2/scan

Reference :

How to Add a New Hard Disk Without Rebooting on CentOS 7/ RHEL 7

Normally when you have added new storage to a running Virtual machine, you probably won’t see the new storage automatically.

This is because the SCSI bus to which the storage devices are connected needs to be rescanned to make the new hardware visible.

As a system administrator, to maintain the linux server uptime is very important and it is better to add a new hard disk without reboot the server.

There is one simple command to rescan the SCSI Bus and add SCSI Devices. The command will trigger the linux rescan scsi bus device on the system.

The following steps has been tested on CentOS 7, RHEL 7 and Oracle Linux 7.

Steps to Add a New Hard Disk Without Rebooting on CentOS 7/ RHEL 7

1. Add the new 20GB vdisk from the ESXi or vCenter :

Add a New Hard Disk Without Reboot

2. Show current disk and partition :

[root@centos7 ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006b96a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    62914559    30944256   8e  Linux LVM

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

3. Identify host bus number :

[root@centos7 ~]# ls /sys/class/scsi_host/
host0  host1  host2

4. Rescan the SCSI Bus to Add a SCSI Devices :

[root@centos7 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@centos7 ~]# echo "- - -" > /sys/class/scsi_host/host1/scan
[root@centos7 ~]# echo "- - -" > /sys/class/scsi_host/host2/scan

4. Verify the disk and partiton and make sure 20GB has been added. In this case, the following line appeared “Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors” and confirmed that 20GB has been added without reboot the server :

[root@centos7 ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006b96a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    62914559    30944256   8e  Linux LVM

Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-root: 29.5 GB, 29536288768 bytes, 57688064 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

How to Prepare for Zimbra 8 Installation Prerequisites on RHEL 7/CentOS 7

Before we install Zimbra 8, I would recommend you to meet all of these requirements. Some software prerequisites should be installed first, then setup the DNS and MX records, provides internet access to and from the Zimbra server, install the latest patches on the server zimbra 8, properly configure iptables filter or firewalld service, turn off SELinux, turn off unnecessary services that can interfere with the process installation. As a guide, i have prepared a checklist or step -by-step reference to Zimbra e-mail administrator. These steps have been tested on RHEL 7/CentOS 7

1. Prepare for a fully qualified domain name ( FQDN ) for your Zimbra mail server mx record and ensure your domain is configured correctly.

2. Configure /etc/hosts and hostname.

3. Allow iptables to by-pass all zimbra ports.

4. Disabled SELINUX :

[root@centos7 ~]# vim /etc/sysconfig/selinux

Change enforcing to disabled :

# 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
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

5. Stop sendmail, postfix or any MTA service :

[root@centos7 ~]# systemctl stop postfix
[root@centos7 ~]# systemctl disable postfix
[root@centos7 ~]# systemctl stop sendmail
[root@centos7 ~]# systemctl disable sendmail

6. Make sure CentOS and RHEL is the latest :

[root@centos7 ~]# yum update -y

7. Install the required packages and libraries using the following command :

[root@centos7 ~]# yum install perl perl-core ntpl nmap sudo libidn gmp libaio libstdc++ unzip sysstat sqlite -y

How to Install Zimbra 8.6.0 on RHEL 7/CentOS 7

Zimbra 8.6.0 brings new features, improvements in Mail server and better web clients experience. Some that caught my attention was local lmtp client can communicate over ssl for mail server, better organization of shared folders for web client and the calendar now can run search on description for location or resources. You can get detailed information on this Release Notes. In this article, I will explain step by step how to install Zimbra 8.6.0 on RHEL 7 or CentOS 7. Starting with ZCS8.5 and later, there is now a DNS caching service available for installation. However, i have excluded zimbra-dnscache in the installation steps.

Prerequisites :
Prepare for Zimbra 8 Installation Prerequisites on RHEL 7/CentOS 7

1. Log in as root to the server and download Zimbra Zimbra Open Source Edition 8.6.0 using the command wget. Before that, please make sure your Zimbra server can access the internet :

wget https://files.zimbra.com/downloads/8.6.0_GA/zcs-8.6.0_GA_1153.RHEL7_64.20141215151110.tgz

2. Extract the downloaded tar file :

tar xzf zcs-8.6.0_GA_1153.RHEL7_64.20141215151110.tgz

3. cd to the directory where the extracted ZCS Open Source Edition :

cd zcs-8.6.0_GA_1153.RHEL7_64.20141215151110

4. Start the installation with the following command :

./install.sh --platform-override

Full installation steps :

./install.sh --platform-override

Operations logged to /tmp/install.log.14668
Checking for existing installation...
    zimbra-ldap...NOT FOUND
    zimbra-logger...NOT FOUND
    zimbra-mta...NOT FOUND
    zimbra-dnscache...NOT FOUND
    zimbra-snmp...NOT FOUND
    zimbra-store...NOT FOUND
    zimbra-apache...NOT FOUND
    zimbra-spell...NOT FOUND
    zimbra-convertd...NOT FOUND
    zimbra-memcached...NOT FOUND
    zimbra-proxy...NOT FOUND
    zimbra-archiving...NOT FOUND
    zimbra-core...NOT FOUND


PLEASE READ THIS AGREEMENT CAREFULLY BEFORE USING THE SOFTWARE.
ZIMBRA, INC. ("ZIMBRA") WILL ONLY LICENSE THIS SOFTWARE TO YOU IF YOU
FIRST ACCEPT THE TERMS OF THIS AGREEMENT. BY DOWNLOADING OR INSTALLING
THE SOFTWARE, OR USING THE PRODUCT, YOU ARE CONSENTING TO BE BOUND BY
THIS AGREEMENT. IF YOU DO NOT AGREE TO ALL OF THE TERMS OF THIS
AGREEMENT, THEN DO NOT DOWNLOAD, INSTALL OR USE THE PRODUCT.

License Terms for the Zimbra Collaboration Suite:
  http://www.zimbra.com/license/zimbra-public-eula-2-5.html



Do you agree with the terms of the software license agreement? [N] y



Checking for prerequisites...
     FOUND: NPTL
     FOUND: nmap-ncat-6.40-4
     FOUND: sudo-1.8.6p7-11
     FOUND: libidn-1.28-3
     FOUND: gmp-5.1.1-5
     FOUND: libaio-0.3.109-12
     FOUND: libstdc++-4.8.2-16.2
     FOUND: unzip-6.0-13
     FOUND: perl-core-5.16.3-283

Checking for suggested prerequisites...
     FOUND: perl-5.16.3
     FOUND: sysstat
     FOUND: sqlite
Prerequisite check complete.

Checking for installable packages

Found zimbra-core
Found zimbra-ldap
Found zimbra-logger
Found zimbra-mta
Found zimbra-dnscache
Found zimbra-snmp
Found zimbra-store
Found zimbra-apache
Found zimbra-spell
Found zimbra-memcached
Found zimbra-proxy


Select the packages to install

Install zimbra-ldap [Y]

Install zimbra-logger [Y]

Install zimbra-mta [Y]

Install zimbra-dnscache [Y] N

Install zimbra-snmp [Y]

Install zimbra-store [Y]

Install zimbra-apache [Y]

Install zimbra-spell [Y]

Install zimbra-memcached [Y]

Install zimbra-proxy [Y]
Checking required space for zimbra-core
Checking space for zimbra-store
Checking required packages for zimbra-store
zimbra-store package check complete.

Installing:
    zimbra-core
    zimbra-ldap
    zimbra-logger
    zimbra-mta
    zimbra-snmp
    zimbra-store
    zimbra-apache
    zimbra-spell
    zimbra-memcached
    zimbra-proxy

The system will be modified.  Continue? [N] Y

Removing /opt/zimbra
Removing zimbra crontab entry...done.
Cleaning up zimbra init scripts...done.
Cleaning up /etc/ld.so.conf...done.
Cleaning up /etc/security/limits.conf...done.

Finished removing Zimbra Collaboration Server.

Installing packages

    zimbra-core......zimbra-core-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-ldap......zimbra-ldap-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-logger......zimbra-logger-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-mta......zimbra-mta-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-snmp......zimbra-snmp-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-store......zimbra-store-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-apache......zimbra-apache-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-spell......zimbra-spell-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-memcached......zimbra-memcached-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-proxy......zimbra-proxy-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
Operations logged to /tmp/zmsetup01032015-084819.log
Installing LDAP configuration database...done.
Setting defaults...No results returned for A lookup of centos7.ehowstuff.local
Checked nameservers:
        192.168.0.70
No results returned for AAAA lookup of centos7.ehowstuff.local
Checked nameservers:
        192.168.0.70


DNS ERROR resolving centos7.ehowstuff.local
It is suggested that the hostname be resolvable via DNS
Change hostname [Yes]
Please enter the logical hostname for this host [centos7.ehowstuff.local] mail.example.com
No results returned for A lookup of mail.example.com
Checked nameservers:
        192.168.0.70


DNS ERROR resolving mail.example.com
It is suggested that the hostname be resolvable via DNS
Re-Enter hostname [Yes]
Please enter the logical hostname for this host [centos7.ehowstuff.local] mail.example.local


DNS ERROR resolving MX for mail.example.local
It is suggested that the domain name have an MX record configured in DNS
Change domain name? [Yes]
Create domain: [mail.example.local] example.local
        MX: mail.example.local (192.168.0.70)

        Interface: 127.0.0.1
        Interface: ::1
        Interface: 192.168.0.70
done.
Checking for port conflicts

Main menu

   1) Common Configuration:
   2) zimbra-ldap:                             Enabled
   3) zimbra-logger:                           Enabled
   4) zimbra-mta:                              Enabled
   5) zimbra-snmp:                             Enabled
   6) zimbra-store:                            Enabled
        +Create Admin User:                    yes
        +Admin user to create:                 admin@example.local
******* +Admin Password                        UNSET
        +Anti-virus quarantine user:           virus-quarantine.fsbv7fj6r0@example.local
        +Enable automated spam training:       yes
        +Spam training user:                   spam.7xlmrmrh3@example.local
        +Non-spam(Ham) training user:          ham.rt_1on1o@example.local
        +SMTP host:                            mail.example.local
        +Web server HTTP port:                 8080
        +Web server HTTPS port:                8443
        +Web server mode:                      https
        +IMAP server port:                     7143
        +IMAP server SSL port:                 7993
        +POP server port:                      7110
        +POP server SSL port:                  7995
        +Use spell check server:               yes
        +Spell server URL:                     http://mail.example.local:7780/aspell.php
        +Enable version update checks:         TRUE
        +Enable version update notifications:  TRUE
        +Version update notification email:    admin@centos7.ehowstuff.local
        +Version update source email:          admin@centos7.ehowstuff.local
        +Install mailstore (service webapp):   yes
        +Install UI (zimbra,zimbraAdmin webapps): yes

   7) zimbra-spell:                            Enabled
   8) zimbra-proxy:                            Enabled
   9) Enable VMware HA:                        no
  10) Default Class of Service Configuration:
   s) Save config to file
   x) Expand menu
   q) Quit

Address unconfigured (**) items  (? - help) 6


Store configuration

   1) Status:                                  Enabled
   2) Create Admin User:                       yes
   3) Admin user to create:                    admin@example.local
** 4) Admin Password                           UNSET
   5) Anti-virus quarantine user:              virus-quarantine.fsbv7fj6r0@example.local
   6) Enable automated spam training:          yes
   7) Spam training user:                      spam.7xlmrmrh3@example.local
   8) Non-spam(Ham) training user:             ham.rt_1on1o@example.local
   9) SMTP host:                               mail.example.local
  10) Web server HTTP port:                    8080
  11) Web server HTTPS port:                   8443
  12) Web server mode:                         https
  13) IMAP server port:                        7143
  14) IMAP server SSL port:                    7993
  15) POP server port:                         7110
  16) POP server SSL port:                     7995
  17) Use spell check server:                  yes
  18) Spell server URL:                        http://mail.example.local:7780/aspell.php
  19) Enable version update checks:            TRUE
  20) Enable version update notifications:     TRUE
  21) Version update notification email:       admin@centos7.ehowstuff.local
  22) Version update source email:             admin@centos7.ehowstuff.local
  23) Install mailstore (service webapp):      yes
  24) Install UI (zimbra,zimbraAdmin webapps): yes

Select, or 'r' for previous menu [r] 4

Password for admin@example.local (min 6 characters): [SBmeBXtA] password

Store configuration

   1) Status:                                  Enabled
   2) Create Admin User:                       yes
   3) Admin user to create:                    admin@example.local
   4) Admin Password                           set
   5) Anti-virus quarantine user:              virus-quarantine.fsbv7fj6r0@example.local
   6) Enable automated spam training:          yes
   7) Spam training user:                      spam.7xlmrmrh3@example.local
   8) Non-spam(Ham) training user:             ham.rt_1on1o@example.local
   9) SMTP host:                               mail.example.local
  10) Web server HTTP port:                    8080
  11) Web server HTTPS port:                   8443
  12) Web server mode:                         https
  13) IMAP server port:                        7143
  14) IMAP server SSL port:                    7993
  15) POP server port:                         7110
  16) POP server SSL port:                     7995
  17) Use spell check server:                  yes
  18) Spell server URL:                        http://mail.example.local:7780/aspell.php
  19) Enable version update checks:            TRUE
  20) Enable version update notifications:     TRUE
  21) Version update notification email:       admin@centos7.ehowstuff.local
  22) Version update source email:             admin@centos7.ehowstuff.local
  23) Install mailstore (service webapp):      yes
  24) Install UI (zimbra,zimbraAdmin webapps): yes

Select, or 'r' for previous menu [r] 21

Version update destination address: [admin@centos7.ehowstuff.local] admin@example.local

Store configuration

   1) Status:                                  Enabled
   2) Create Admin User:                       yes
   3) Admin user to create:                    admin@example.local
   4) Admin Password                           set
   5) Anti-virus quarantine user:              virus-quarantine.fsbv7fj6r0@example.local
   6) Enable automated spam training:          yes
   7) Spam training user:                      spam.7xlmrmrh3@example.local
   8) Non-spam(Ham) training user:             ham.rt_1on1o@example.local
   9) SMTP host:                               mail.example.local
  10) Web server HTTP port:                    8080
  11) Web server HTTPS port:                   8443
  12) Web server mode:                         https
  13) IMAP server port:                        7143
  14) IMAP server SSL port:                    7993
  15) POP server port:                         7110
  16) POP server SSL port:                     7995
  17) Use spell check server:                  yes
  18) Spell server URL:                        http://mail.example.local:7780/aspell.php
  19) Enable version update checks:            TRUE
  20) Enable version update notifications:     TRUE
  21) Version update notification email:       admin@example.local
  22) Version update source email:             admin@centos7.ehowstuff.local
  23) Install mailstore (service webapp):      yes
  24) Install UI (zimbra,zimbraAdmin webapps): yes

Select, or 'r' for previous menu [r] 22

Version update source address: [admin@centos7.ehowstuff.local] admin@example.local

Store configuration

   1) Status:                                  Enabled
   2) Create Admin User:                       yes
   3) Admin user to create:                    admin@example.local
   4) Admin Password                           set
   5) Anti-virus quarantine user:              virus-quarantine.fsbv7fj6r0@example.local
   6) Enable automated spam training:          yes
   7) Spam training user:                      spam.7xlmrmrh3@example.local
   8) Non-spam(Ham) training user:             ham.rt_1on1o@example.local
   9) SMTP host:                               mail.example.local
  10) Web server HTTP port:                    8080
  11) Web server HTTPS port:                   8443
  12) Web server mode:                         https
  13) IMAP server port:                        7143
  14) IMAP server SSL port:                    7993
  15) POP server port:                         7110
  16) POP server SSL port:                     7995
  17) Use spell check server:                  yes
  18) Spell server URL:                        http://mail.example.local:7780/aspell.php
  19) Enable version update checks:            TRUE
  20) Enable version update notifications:     TRUE
  21) Version update notification email:       admin@example.local
  22) Version update source email:             admin@example.local
  23) Install mailstore (service webapp):      yes
  24) Install UI (zimbra,zimbraAdmin webapps): yes

Select, or 'r' for previous menu [r] r

Main menu

   1) Common Configuration:
   2) zimbra-ldap:                             Enabled
   3) zimbra-logger:                           Enabled
   4) zimbra-mta:                              Enabled
   5) zimbra-snmp:                             Enabled
   6) zimbra-store:                            Enabled
   7) zimbra-spell:                            Enabled
   8) zimbra-proxy:                            Enabled
   9) Enable VMware HA:                        no
  10) Default Class of Service Configuration:
   s) Save config to file
   x) Expand menu
   q) Quit

*** CONFIGURATION COMPLETE - press 'a' to apply
Select from menu, or press 'a' to apply config (? - help) a
Save configuration data to a file? [Yes]
Save config in file: [/opt/zimbra/config.23920]
Saving config in /opt/zimbra/config.23920...done.
The system will be modified - continue? [No] yes
Operations logged to /tmp/zmsetup01032015-084819.log
Setting local config values...done.
Initializing core config...Setting up CA...done.
Deploying CA to /opt/zimbra/conf/ca ...done.
Creating SSL zimbra-store certificate...done.
Creating new zimbra-ldap SSL certificate...done.
Creating new zimbra-mta SSL certificate...done.
Creating new zimbra-proxy SSL certificate...done.
Installing mailboxd SSL certificates...done.
Installing MTA SSL certificates...done.
Installing LDAP SSL certificate...done.
Installing Proxy SSL certificate...done.
Initializing ldap...done.
Setting replication password...done.
Setting Postfix password...done.
Setting amavis password...done.
Setting nginx password...done.
Setting BES searcher  password...done.
Creating server entry for mail.example.local...done.
Setting Zimbra IP Mode...done.
Saving CA in ldap ...done.
Saving SSL Certificate in ldap ...done.
Setting spell check URL...done.
Setting service ports on mail.example.local...done.
Setting zimbraFeatureTasksEnabled=TRUE...done.
Setting zimbraFeatureBriefcasesEnabled=TRUE...done.
Setting TimeZone Preference...done.
Initializing mta config...done.
Setting services on mail.example.local...done.
Adding mail.example.local to zimbraMailHostPool in default COS...done.
Creating domain example.local...done.
Setting default domain name...done.
Creating domain example.local...already exists.
Creating admin account admin@example.local...done.
Creating root alias...done.
Creating postmaster alias...done.
Creating user spam.7xlmrmrh3@example.local...done.
Creating user ham.rt_1on1o@example.local...done.
Creating user virus-quarantine.fsbv7fj6r0@example.local...done.
Setting spam training and Anti-virus quarantine accounts...done.
Initializing store sql database...done.
Setting zimbraSmtpHostname for mail.example.local...done.
Configuring SNMP...done.
Setting up syslog.conf...done.
Starting servers...done.
Installing common zimlets...
        com_zimbra_proxy_config...done.
        com_zimbra_mailarchive...done.
        com_zimbra_attachmail...done.
        com_zimbra_url...done.
        com_zimbra_phone...done.
        com_zimbra_date...done.
        com_zimbra_ymemoticons...done.
        com_zimbra_clientuploader...done.
        com_zimbra_srchhighlighter...done.
        com_zimbra_tooltip...done.
        com_zimbra_webex...done.
        com_zimbra_bulkprovision...done.
        com_zimbra_email...done.
        com_zimbra_adminversioncheck...done.
        com_zimbra_cert_manager...done.
        com_zimbra_viewmail...done.
        com_zimbra_attachcontacts...done.
Finished installing common zimlets.
Restarting mailboxd...done.
Creating galsync account for default domain...done.

You have the option of notifying Zimbra of your installation.
This helps us to track the uptake of the Zimbra Collaboration Server.
The only information that will be transmitted is:
        The VERSION of zcs installed (8.6.0_GA_1153_RHEL7_64)
        The ADMIN EMAIL ADDRESS created (admin@example.local)

Notify Zimbra of your installation? [Yes] no
Notification skipped
Setting up zimbra crontab...done.


Moving /tmp/zmsetup01032015-084819.log to /opt/zimbra/log


Configuration complete - press return to exit

5. Start zimbra services :

su - zimbra
zmcontrol start