Add a Disk and Extend FileSystem on RHEL7 on VMware Fusion 8 for Mac (El- Capitan)

Below is the Filesystem on our VM

Filesystem           Size  Used Avail Use% Mounted on

/dev/mapper/ol-root   18G   11G  7.0G  61% /

devtmpfs             476M     0  476M   0% /dev

tmpfs                491M  144K  491M   1% /dev/shm

tmpfs                491M  7.2M  484M   2% /run

tmpfs                491M     0  491M   0% /sys/fs/cgroup

/dev/sda1            497M  177M  320M  36% /boot

tmpfs                 99M   12K   99M   1% /run/user/0

Our aim is to grow the Filesystem /dev/mapper/ol-root

Filesystems in Linux are extended using the following steps

  1. Add a Physical Disk —> Needs a Shutdown
  2. Create a Physical Volume, using pvcreate —> Online
  3. Grow the Volume Group, using vgextend —> Online
  4. Grow the Logical Volume, using extend—> Online
  5. Extend the Filesystem(XFS) , using xfs_growfs—> Online

Let us continue and see each step in details now…

  1. Shutdown your VM and ddd the disk from option Virtual Machine—> Hard Disk (SCSI)
  2. Check from Disk Utility if the new Disk AppearsScreen Shot 2016-05-14 at 5.27.55 PM
$ pvdisplay

 

3. Create Physical Volume

root@localhost ~]# pvcreate /dev/sdc

WARNING: xfs signature detected on /dev/sdc at offset 0. Wipe it? [y/n]: y

  Wiping xfs signature on /dev/sdc.

  Physical volume "/dev/sdc" successfully created

4. Extend the Volume Group

$ vgdisplay

[root@localhost ~]# vgextend ol /dev/sdc

  Volume group "ol" successfully extended

5. Extend the Logical Volume

[root@localhost ~]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/ol/root

  LV Name                root

  VG Name                ol

  LV UUID                nfBnYo-iJhh-fC0y-dWqD-A5Nf-SVHX-lBwioW

  LV Write Access        read/write

  LV Creation host, time localhost.localdomain, 2016-05-13 14:49:36 +0300

  LV Status              available

  # open                 1

  LV Size                17.47 GiB

  Current LE             4472

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     8192

  Block device           252:0

[root@localhost ~]# lvextend --size 35G /dev/ol/root

  Size of logical volume ol/root changed from 17.47 GiB (4472 extents) to 35.00 GiB (8960 extents).

  Logical volume root successfully resized.

[root@localhost ~]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/ol/root

  LV Name                root

  VG Name                ol

  LV UUID                nfBnYo-iJhh-fC0y-dWqD-A5Nf-SVHX-lBwioW

  LV Write Access        read/write

  LV Creation host, time localhost.localdomain, 2016-05-13 14:49:36 +0300

  LV Status              available

  # open                 1

  LV Size                35.00 GiB

  Current LE             8960

  Segments               2

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     8192

  Block device           252:0

Now the logical volume is extended

6. Resize the Filesystem

Since this is RHEL7 and the default FS for root is XFS, if we try to grow the FS using resize2fs like we did earlier on ext3 and ext4, it will give below error

[root@localhost ~]# resize2fs /dev/ol/root 35G

resize2fs 1.42.9 (28-Dec-2013)

resize2fs: Bad magic number in super-block while trying to open /dev/ol/root

Couldn't find valid filesystem superblock

If you were using RHEL6 and ext4, you could use resize2fs, but we will continue with xfs_growfs

To grow the XFS filesystem we have to use command xfs_growfs

[root@localhost ~]# xfs_growfs /dev/ol/root

meta-data=/dev/mapper/ol-root    isize=256    agcount=4, agsize=1144832 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=0        finobt=0

data     =                       bsize=4096   blocks=4579328, 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 4579328 to 9175040

Check to confirm

Filesystem           Size  Used Avail Use% Mounted on

/dev/mapper/ol-root   35G   11G   25G  31% /

devtmpfs             476M     0  476M   0% /dev

tmpfs                491M  144K  491M   1% /dev/shm

tmpfs                491M  7.2M  484M   2% /run

tmpfs                491M     0  491M   0% /sys/fs/cgroup

/dev/sda1            497M  177M  320M  36% /boot

tmpfs                 99M   16K   99M   1% /run/user/0

 

Category: LinuxLinux

Tags:

Leave a Reply

Article by: Shadab Mohammad