Sunday, June 5, 2016

RHEL7 - Removing home directory and extending root filesystem

login as: sudhir
sudhir@192.168.10.13's password:
Last login: Sun Jun  5 09:39:15 2016 from 192.168.10.8
[sudhir@localhost ~]$ su -
Password:
Last login: Sun Jun  5 09:39:18 EDT 2016 on pts/0
[root@localhost ~]# pwd
/root
[root@localhost ~]# df -h /home
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-home   12G   37M   12G   1% /home
[root@localhost ~]# df -h /homes
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  9.6G  4.0G  5.7G  41% /
[root@localhost ~]# fuser -cu /home
/home:                5957c(sudhir)
[root@localhost ~]# kill -9 5957
[root@localhost ~]# umount /home
[root@localhost ~]# grep home /etc/fstab
/dev/mapper/centos-home /home                   xfs     defaults        0 0
[root@localhost ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   2   3   0 wz--n- 24.53g 68.00m
[root@localhost ~]# lvremove /dev/mapper/centos-home
Do you really want to remove active logical volume home? [y/n]: y
  Logical volume "home" successfully removed
[root@localhost ~]# lvs
  LV   VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root centos -wi-ao---- 9.56g
  swap centos -wi-ao---- 3.73g
[root@localhost ~]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   2   2   0 wz--n- 24.53g 11.24g
[root@localhost ~]# pwd
/root
[root@localhost ~]# cd /
[root@localhost /]# cd /home
[root@localhost home]# ls
[root@localhost home]# cd ..
[root@localhost /]# rmdir /home
[root@localhost /]# pwd
/
[root@localhost /]# cp -rp /homes/ /home
[root@localhost /]# vi /etc/passwd
[root@localhost /]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  9.6G  4.0G  5.7G  41% /
devtmpfs                 482M     0  482M   0% /dev
tmpfs                    497M   84K  497M   1% /dev/shm
tmpfs                    497M  7.0M  490M   2% /run
tmpfs                    497M     0  497M   0% /sys/fs/cgroup
/dev/sda1                473M  156M  318M  33% /boot
/dev/sr1                 4.1G  4.1G     0 100% /run/media/sudhir/CentOS 7 x86_64
tmpfs                    100M     0  100M   0% /run/user/0
tmpfs                    100M   12K  100M   1% /run/user/42
tmpfs                    100M     0  100M   0% /run/user/1000
[root@localhost /]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256    agcount=9, agsize=305152 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=2505728, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost /]# df -h .
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  9.6G  4.0G  5.7G  41% /
[root@localhost /]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   2   2   0 wz--n- 24.53g 11.24g
[root@localhost /]# lvscan
  ACTIVE            '/dev/centos/root' [9.56 GiB] inherit
  ACTIVE            '/dev/centos/swap' [3.73 GiB] inherit
[root@localhost /]# lvextend /dev/centos/root 11G
  Physical Volume "11G" not found in Volume Group "centos".
[root@localhost /]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   2   2   0 wz--n- 24.53g 11.24g
[root@localhost /]# lvextend /dev/centos/root +11G
  Physical Volume "+11G" not found in Volume Group "centos".
[root@localhost /]# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   2   2   0 wz--n- 24.53g 11.24g
[root@localhost /]# lvextend /dev/centos/root -L +11G
  Size of logical volume centos/root changed from 9.56 GiB (2447 extents) to 20.56 GiB (5263 extents).
  Logical volume root successfully resized.
[root@localhost /]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=256    agcount=9, agsize=305152 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=2505728, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2505728 to 5389312
[root@localhost /]# df -h .
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   21G  4.0G   17G  20% /
[root@localhost /]#
[root@localhost /]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   21G  4.0G   17G  20% /
devtmpfs                 482M     0  482M   0% /dev
tmpfs                    497M   84K  497M   1% /dev/shm
tmpfs                    497M  7.0M  490M   2% /run
tmpfs                    497M     0  497M   0% /sys/fs/cgroup
/dev/sda1                473M  156M  318M  33% /boot
/dev/sr1                 4.1G  4.1G     0 100% /run/media/sudhir/CentOS 7 x86_64
tmpfs                    100M     0  100M   0% /run/user/0
tmpfs                    100M   16K  100M   1% /run/user/42
tmpfs                    100M     0  100M   0% /run/user/1000
[root@localhost /]#

No comments:

Post a Comment