rhel 67 – shrink expand lvm partition

the default rhel 6.7 partition, “/” partition only have 50GB and the “/home” get the rest

if you only have 90GB for rhel, it would split  / to 50GB and /home 40GB. but if you have TeraByte space / get 50GB and /home get TeraByte

problem when you use / for default database storage, which store the data in / partition, 50GB so small for database.

the advantage using lvm partition, you can shrink the partition, and give the free space for other partition

i will try reduce /home space and add it to

# test
[root@rhel67 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_rhel67-lv_root
 50G 1.9G 45G 4% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 477M 41M 411M 10% /boot
/dev/mapper/vg_rhel67-lv_home
 45G 52M 43G 1% /home

[root@rhel67 ~]# pvs
  PV         VG        Fmt  Attr PSize  PFree
  /dev/sda2  vg_rhel67 lvm2 a--  99.51g    0 

[root@rhel67 ~]# vgs
  VG        #PV #LV #SN Attr   VSize  VFree
  vg_rhel67   1   3   0 wz--n- 99.51g    0 

[root@rhel67 ~]# lvs
  LV      VG        Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home vg_rhel67 -wi-ao---- 45.63g                                                    
  lv_root vg_rhel67 -wi-ao---- 50.00g                                                    
  lv_swap vg_rhel67 -wi-ao----  3.88g
  
# step to reduce
[root@rhel67 ~]# umount /home

# check system error
[root@rhel67 ~]# e2fsck -ff /dev/mapper/vg_rhel67-lv_home
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vg_rhel67-lv_home: 11/2992416 files (0.0% non-contiguous), 233857/11962368 blocks

# now cut the space
[root@rhel67 ~]# resize2fs /dev/mapper/vg_rhel67-lv_home 20G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/vg_rhel67-lv_home to 5242880 (4k) blocks.
The filesystem on /dev/mapper/vg_rhel67-lv_home is now 5242880 blocks long.

# resize authority
[root@rhel67 ~]# lvreduce -L -19G /dev/mapper/vg_rhel67-lv_home  
  WARNING: Reducing active logical volume to 26.63 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
  Size of logical volume vg_rhel67/lv_home changed from 45.63 GiB (11682 extents) to 26.63 GiB (6818 extents).
  Logical volume lv_home successfully resized

[root@rhel67 ~]# lvdisplay /dev/vg_rhel67/lv_home
  --- Logical volume ---
  LV Path                /dev/vg_rhel67/lv_home
  LV Name                lv_home
  VG Name                vg_rhel67
  LV UUID                TG9ipf-EeEA-jKN6-BrG2-J3Gx-mXz2-tylb4X
  LV Write Access        read/write
  LV Creation host, time rhel67, 2017-07-04 04:05:41 +0700
  LV Status              available
  # open                 0
  LV Size                26.63 GiB
  Current LE             6818
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

[root@rhel67 ~]# bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
1024*20
20480
2048/4
512

[root@rhel67 ~]# lvreduce -l -512 /dev/vg_rhel67/lv_home
  WARNING: Reducing active logical volume to 24.63 GiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_home? [y/n]: y
  Size of logical volume vg_rhel67/lv_home changed from 26.63 GiB (6818 extents) to 24.63 GiB (6306 extents).
  Logical volume lv_home successfully resized

[root@rhel67 ~]# resize2fs /dev/vg_rhel67/lv_home
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg_rhel67/lv_home to 6457344 (4k) blocks.
The filesystem on /dev/vg_rhel67/lv_home is now 6457344 blocks long.

[root@rhel67 ~]# mount /dev/vg_rhel67/lv_home /home

[root@rhel67 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_rhel67-lv_root
                       50G  1.9G   45G   4% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             477M   41M  411M  10% /boot
/dev/mapper/vg_rhel67-lv_home
                       25G   44M   23G   1% /home

# now check
[root@rhel67 ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_rhel67
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               99.51 GiB
  PE Size               4.00 MiB
  Total PE              25474
  Alloc PE / Size       20098 / 78.51 GiB
  Free  PE / Size       5376 / 21.00 GiB
  VG UUID               DYk8Up-pACU-XZco-ZuEw-iXLL-G98b-gDUSyP
   
[root@rhel67 ~]# pvs
  PV         VG        Fmt  Attr PSize  PFree 
  /dev/sda2  vg_rhel67 lvm2 a--  99.51g 21.00g

[root@rhel67 ~]# lvs
  LV      VG        Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home vg_rhel67 -wi-ao---- 24.63g                                                    
  lv_root vg_rhel67 -wi-ao---- 50.00g                                                    
  lv_swap vg_rhel67 -wi-ao----  3.88g

# check how much freespace 
[root@rhel67 ~]# pvscan
  PV /dev/sda2   VG vg_rhel67   lvm2 [99.51 GiB / 21.00 GiB free]
  Total: 1 [99.51 GiB] / in use: 1 [99.51 GiB] / in no VG: 0 [0   ]

[root@rhel67 ~]# vgdisplay
  --- Volume group ---
  VG Name               vg_rhel67
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               99.51 GiB
  PE Size               4.00 MiB
  Total PE              25474
  Alloc PE / Size       20098 / 78.51 GiB
  Free  PE / Size       5376 / 21.00 GiB
  VG UUID               DYk8Up-pACU-XZco-ZuEw-iXLL-G98b-gDUSyP

# check size partition
[root@rhel67 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_rhel67-lv_root
                       50G  1.9G   45G   4% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             477M   41M  411M  10% /boot
/dev/mapper/vg_rhel67-lv_home
                       25G   44M   23G   1% /home

# now expand the freespace
[root@rhel67 ~]# resize2fs /dev/vg_rhel67/lv_root 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_rhel67/lv_root is mounted on /; on-line resizing required
old desc_blocks = 4, new_desc_blocks = 5
Performing an on-line resize of /dev/vg_rhel67/lv_root to 18612224 (4k) blocks.
The filesystem on /dev/vg_rhel67/lv_root is now 18612224 blocks long.

# check again the size
[root@rhel67 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_rhel67-lv_root
                       70G  1.9G   65G   3% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             477M   41M  411M  10% /boot
/dev/mapper/vg_rhel67-lv_home
                       25G   44M   23G   1% /home

nohup – remove output message from console

avoid message nohup: ignoring input and appending output to `nohup.out’ so we can out from background jobs shell

add  </dev/null &>/dev/null & at end command

this will output message

nohup php index.php some_variable

this will silent and send jobs to background

nohup php index.php some_variable </dev/null &>/dev/null &

 

 

redhat – local dvd repo

# mounting iso to redhat

mount -o loop rhel7.iso /mnt/rhel7

# or locate where the dvd mount, ex /mnt/rhel7

ln -s /mnt/rhel7 /tmp/rhel7

# create new repo to dvd

nano  /etc/yum.repos.d/rhel7.repo

# input this code

[RepoLocal]
name=baseurl
baseurl=file:///tmp/rhel7/
enable=1
gpgcheck=0

# clean repo and makecache

yum clean all && yum makecache

# test to install

yum install perl

logs install gitlist in ubuntu server

gitlist source code https://github.com/klaussilveira/gitlist

download stable version at gitlist.org


# find where git
where git
#return  /usr/bin/git

# create repo in user git
su git
mkdir -p ~/repo/cec-spt.git && cd ~/repo/cec-spt.git
git init --bare
exit

# first commit to empty repository
cd /var/www/html/source-code-spt
git init
git add .
git commit -m "first init"
git remote add origin ssh://git@localhost:/home/git/repo/cec-spt.git
git push origin master

# to html folder
cd /var/www/html
wget https://s3.amazonaws.com/gitlist/gitlist-master.tar.gz -O gitlist.tar.gz
tar -xvzf gitlist.tar.gz
cd gitlist
mkdir cache
chmod 777 cache
cp config.ini-example config.ini
nano config.ini

# edit this value
client = '/usr/bin/git'
repositories[] = '/home/git/repo/'

# remove function proc_open & parse_ini_file from disable_functions
sudo nano /etc/php5/apache2/conf.d/disable_functions.ini
# enable proc_open & parse_ini_file
disable_functions =passthru,shell_exec,system,popen,curl_exec,curl_multi_exec,show_source

# restart apache
sudo service apache2 restart

# test in browser
http://localhost/gitlist