Category Archives: Linux

Create Partition on New Disk using Parted on CentOS


Scenario: Create partition and Volume Group 60GB size from 100GB disk on new disk using Parted on CentOS
System: CentOS/RHEL 6 or 7

Steps:
Show new disk:
# fdisk -l | grep sd

[root@server ~]# fdisk -l | grep sd
Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    81797119    39848960   8e  Linux LVM
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
[root@server ~]#

Continue reading

Mount Windows Folder Sharing on RHEL 6/CentOS 6

Scenario:
-Mount Windows Folder Sharing (CIFS) on RHEL 6/CentOS 6.
-Set only Linux user >> user1 that have RWX access.
-Hide sharing credentials from other Linux users.
-Mount permanent at boot.

System: CentOS 6

Steps:
1) Edit /etc/fstab
# vi /etc/fstab
Continue reading

Setup Virtual Domain Postfix

Scenario:
– Forward certain email recipient to another email address.
– Forward local Unix account email address to another email recipient because in the Postfix server don’t have mailbox.

System:
Postfix on CentOS 7/RHEL 7 (also work on CentOS 6/RHEL 6)

Steps:
– Edit main.cf
# vi /etc/postfix/main.cf
Edit the below parameter.

virtual_alias_domains = example1.com,example2.com
virtual_alias_maps = hash:/etc/postfix/virtual

Continue reading

Setup Ethernet Bonding on RHEL 6

Scenario: Configure 4 ethernet into 2 ethernet bond0 and bond1 on RHEL 6/CentOS 6.
System: RHEL 6.9

Steps:
1) Create new file bond0 (Eth0+Eth1) with IP Address = 172.16.10.70
# vi /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
IPADDR=172.16.10.70
NETMASK=255.255.255.0
TYPE=Bond
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=none
USERCTL=no
PEERDNS=yes
IPV6INIT=no

Continue reading

Command to re-read new VM disk CentOS/RHEL

System: CentOS/RHEL 6 and CentOS/RHEl 7

Case:
Added new VM disk in CentOS not showing the new VM disk when run fdisk -l.

Resolution:
Login as root, run this command to re-read the new VM disk without reboot the server.

ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done

Continue reading

Setup Banner on Console and Remote login CentOS/RHEL 6

Example add below banner.


********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Unauthorized access to this machine is prohibited                *
* Press Ctrl+D if you are not an authorized user                   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************

Continue reading

Decrease Logical Volume size in CentOS 6

Scenario: Decrease Logical Volume /home to 1GB size in CentOS/RHEL 6
System: CentOS/RHEL 6

Steps:
– Check the drive and LV Path:

[root@centos6 ~]# df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/VolumeGroup-lv_root  9.9G  1.8G  7.6G  20% /
tmpfs                            931M     0  931M   0% /dev/shm
/dev/sda1                        485M   39M  421M   9% /boot
/dev/mapper/VolumeGroup-lv_home  2.5G   68M  2.3G   3% /home
/dev/mapper/VolumeGroup-lv_opt   2.5G   68M  2.3G   3% /opt
/dev/mapper/VolumeGroup-lv_var   9.9G  199M  9.2G   3% /var
[root@centos6 ~]# lvdisplay | grep Path
  LV Path                /dev/VolumeGroup/lv_root
  LV Path                /dev/VolumeGroup/lv_swap
  LV Path                /dev/VolumeGroup/lv_var
  LV Path                /dev/VolumeGroup/lv_opt
  LV Path                /dev/VolumeGroup/lv_home
[root@centos6 ~]# vgs
  VG          #PV #LV #SN Attr   VSize  VFree
  VolumeGroup   1   5   0 wz--n- 39.51g 10.51g
[root@centos6 ~]#

got the logical volume home path is /dev/VolumeGroup/lv_home with 2.5GB size.
Continue reading