Difference between revisions of "HowTo Resize The "root" File System Using LVM"

From NST Wiki
Jump to navigationJump to search
(Add the Physical Volume To An Existing Volume Group)
(Add the Physical Volume To An Existing Volume Group)
Line 50: Line 50:
  
 
  vgextend 'nst22' /dev/sdb;
 
  vgextend 'nst22' /dev/sdb;
 +
 +
We can validate our work using '''pvscan''' and '''ssm list''':
 +
 +
[root@nst22 tmp]# pvscan;
 +
  PV /dev/sda2  VG nst22  lvm2 [19.51 GiB / 0    free]
 +
  PV /dev/sdb    VG nst22  lvm2 [2.00 GiB / 2.00 GiB free]
 +
  Total: 2 [21.50 GiB] / in use: 2 [21.50 GiB] / in no VG: 0 [0  ]
 +
 +
  [root@nst22 tmp]# ssm list;
 +
-----------------------------------------------------------
 +
Device        Free      Used      Total  Pool  Mount point
 +
-----------------------------------------------------------
 +
/dev/sda                      20.00 GB        PARTITIONED
 +
/dev/sda1                    500.00 MB        /boot
 +
/dev/sda2  0.00 KB  19.51 GB  19.51 GB  nst22
 +
/dev/sdb  2.00 GB  0.00 KB    2.00 GB  nst22
 +
-----------------------------------------------------------
 +
-------------------------------------------------
 +
Pool  Type  Devices    Free      Used    Total
 +
-------------------------------------------------
 +
nst22  lvm  2        2.00 GB  19.51 GB  21.50 GB
 +
-------------------------------------------------
 +
------------------------------------------------------------------------------------
 +
Volume          Pool  Volume size  FS      FS size      Free  Type    Mount point
 +
------------------------------------------------------------------------------------
 +
/dev/nst22/root  nst22    17.51 GB  xfs    17.50 GB    5.88 GB  linear  /
 +
/dev/nst22/swap  nst22      2.00 GB                              linear
 +
/dev/sda1                500.00 MB  ext4  500.00 MB  288.89 MB  part    /boot
 +
------------------------------------------------------------------------------------

Revision as of 09:09, 26 May 2016

Overview

This page demonstrates how to resize the root file system by increasing it's size by 2GB using the Logical Volume Manager (LVM). This will be done without rebooting the NST system. The follow environment exists:

[root@nst22 ~]# ssm list;
-----------------------------------------------------------
Device        Free      Used      Total  Pool   Mount point
-----------------------------------------------------------
/dev/sda                       20.00 GB         PARTITIONED
/dev/sda1                     500.00 MB         /boot
/dev/sda2  0.00 KB  19.51 GB   19.51 GB  nst22
-----------------------------------------------------------
-------------------------------------------------
Pool   Type  Devices     Free      Used     Total
-------------------------------------------------
nst22  lvm   2        2.00 GB  19.51 GB  21.50 GB
-------------------------------------------------
------------------------------------------------------------------------------------
Volume           Pool   Volume size  FS      FS size       Free  Type    Mount point
------------------------------------------------------------------------------------
/dev/nst22/root  nst22     17.51 GB  xfs    17.50 GB    5.88 GB  linear  /
/dev/nst22/swap  nst22      2.00 GB                              linear
/dev/sda1                 500.00 MB  ext4  500.00 MB  288.89 MB  part    /boot
------------------------------------------------------------------------------------
  • The root file sytem is of type xfs
[root@nst22 ~]# mount | grep root;
/dev/mapper/nst22-root on / type xfs (rw,relatime,attr2,inode64,noquota)

Demonstration

We will now show a sequence of commands to accomplish resizing the root file system by 2GB. Our NST system is a Virtual Machine (VM) running under the VMware Fusion Hypervisor. Behind the scenes we created a new virtual disk of size 2GB (/dev/sdb). On a physical system we could of used a whole disk or a disk partition for this demonstration.

The root file system size is currently 17.50GB in the Volume Group pool: "nst22". Our goal is to increase the root file system to a total of 19.50GB.

Initialize Disk or Disk Partition for LVM Usage

One can either us a whole disk or a disk partion for LVM:

  • To use a disk partition: Use a partition tool (fdisk, cfdisk, gparted, etc...) to create the disk partition for LVM.
  • To use the whole disk: Make sure the partition table is cleared out:
dd if=/dev/zero of=/dev/sdb bs=512 count=1

We will use the entire disk (/dev/sdb) for LVM using the following pvcreate command to initialize a Physical Volume:

pvcreate /dev/sdb;

Add the Physical Volume To An Existing Volume Group

We will now add (extend) the newly created Physical Volume: /dev/sdb to the nst22 Volume Group.

vgextend 'nst22' /dev/sdb;

We can validate our work using pvscan and ssm list:

[root@nst22 tmp]# pvscan;
  PV /dev/sda2   VG nst22   lvm2 [19.51 GiB / 0    free]
  PV /dev/sdb    VG nst22   lvm2 [2.00 GiB / 2.00 GiB free]
  Total: 2 [21.50 GiB] / in use: 2 [21.50 GiB] / in no VG: 0 [0   ]
 [root@nst22 tmp]# ssm list;
-----------------------------------------------------------
Device        Free      Used      Total  Pool   Mount point
-----------------------------------------------------------
/dev/sda                       20.00 GB         PARTITIONED
/dev/sda1                     500.00 MB         /boot
/dev/sda2  0.00 KB  19.51 GB   19.51 GB  nst22
/dev/sdb   2.00 GB   0.00 KB    2.00 GB  nst22
-----------------------------------------------------------
-------------------------------------------------
Pool   Type  Devices     Free      Used     Total
-------------------------------------------------
nst22  lvm   2        2.00 GB  19.51 GB  21.50 GB
-------------------------------------------------
------------------------------------------------------------------------------------
Volume           Pool   Volume size  FS      FS size       Free  Type    Mount point
------------------------------------------------------------------------------------
/dev/nst22/root  nst22     17.51 GB  xfs    17.50 GB    5.88 GB  linear  /
/dev/nst22/swap  nst22      2.00 GB                              linear
/dev/sda1                 500.00 MB  ext4  500.00 MB  288.89 MB  part    /boot