LVM: Shrink & extend a filesystem/volume

LVM: Shrink & extend a filesystem/volume

# Tested on AIX 5.3

# Note: jfs2 allows to shrink the filesystem, but a jfs filesystem's size cannot be reduced

# In this example we are reducing /local/opt in order to free some space to be
# assigned to "/" afterwards


# First we've verified that there was no free space

lsvg rootvg
   VOLUME GROUP:       rootvg             VG IDENTIFIER:  00c8425d00004c000000011f18c09ed8
   VG STATE:           active             PP SIZE:        32 megabyte(s)
   VG PERMISSION:      read/write         TOTAL PPs:      1406 (44992 megabytes)
   MAX LVs:            256                FREE PPs:       2 (64 megabytes)        <--- !!!
   LVs:                13                 USED PPs:       1404 (44928 megabytes)
   OPEN LVs:           12                 QUORUM:         1 (Disabled)
   TOTAL PVs:          2                  VG DESCRIPTORS: 3
   STALE PVs:          0                  STALE PPs:      0
   ACTIVE PVs:         2                  AUTO ON:        yes
   MAX PPs per VG:     32512
   MAX PPs per PV:     1016               MAX PVs:        32
   LTG size (Dynamic): 256 kilobyte(s)    AUTO SYNC:      no
   HOT SPARE:          no                 BB POLICY:      relocatable


# Check if we are able to reduce /local/opt. Verify filesystem type

lsvg -l rootvg
   rootvg:
   LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
   hd5                 boot       1       2       2    closed/syncd  N/A
   hd6                 paging     136     272     2    open/syncd    N/A
   hd8                 jfs2log    1       2       2    open/syncd    N/A
   hd4                 jfs2       18      36      2    open/syncd    /
   hd2                 jfs2       47      94      2    open/syncd    /usr
   hd9var              jfs2       32      64      2    open/syncd    /var
   hd3                 jfs2       32      64      2    open/syncd    /tmp
   hd1                 jfs2       1       2       2    open/syncd    /local/home
   hd10opt             jfs2       2       4       2    open/syncd    /opt
   localoptlv          jfs2       128     256     2    open/syncd    /local/opt   <-- jfs2, ok
   lv_dump2            sysdump    32      32      1    open/syncd    N/A
   lv_dump1            sysdump    32      32      1    open/syncd    N/A
   lv_u01              jfs2       256     512     2    open/syncd    /u01




# Shrink F.S./volume
# ------------------------------------------------------------------------------------------

df -m
   Filesystem    MB blocks      Free %Used    Iused %Iused Mounted on
   /dev/hd4          64.00      2.99   96%     2783    77% /
   /dev/hd2        1504.00    119.41   93%    36283    53% /usr
   /dev/hd9var     1024.00    225.42   78%      562     2% /var
   /dev/hd3        1024.00    961.14    7%     1818     1% /tmp
   /dev/hd1          32.00      9.35   71%      545    20% /local/home
   /proc                 -         -    -         -     -  /proc
   /dev/hd10opt      64.00     14.73   77%     1421    28% /opt
   /dev/localoptlv   5120.00   4819.80    6%     2776     1% /local/opt      <---
   /dev/lv_u01     8192.00    602.68   93%    40483    20% /u01
   /dev/lv_u02    81920.00  59775.86   28%       54     1% /u02
   /dev/lv_u03    81920.00  50331.45   39%       56     1% /u03
   /dev/lv_u04    81920.00  63376.46   23%       42     1% /u04
   /dev/lv_u07   104448.00 101208.13    4%      340     1% /u07
   /dev/lv_u05    12288.00   2768.47   78%       89     1% /u05
   /dev/lv_u06    12288.00   2768.46   78%       89     1% /u06


# Let's reduce by 1GB

chfs -a size=-1G /local/opt
   Filesystem size changed to 8388608

# Otherwise, we can specify the final size like this:
# chfs -a size=7G /local/opt
# chfs -a size=7168M /local/opt


df -m
   Filesystem    MB blocks      Free %Used    Iused %Iused Mounted on
   /dev/hd4          64.00      2.99   96%     2783    77% /
   /dev/hd2        1504.00    119.41   93%    36283    53% /usr
   /dev/hd9var     1024.00    225.42   78%      562     2% /var
   /dev/hd3        1024.00    961.14    7%     1818     1% /tmp
   /dev/hd1          32.00      9.35   71%      545    20% /local/home
   /proc                 -         -    -         -     -  /proc
   /dev/hd10opt      64.00     14.73   77%     1421    28% /opt
   /dev/localoptlv   4096.00   3795.95    8%     2776     1% /local/opt      <---
   /dev/lv_u01     8192.00    603.16   93%    40467    20% /u01
   /dev/lv_u02    81920.00  59775.86   28%       54     1% /u02
   /dev/lv_u03    81920.00  50331.45   39%       56     1% /u03
   /dev/lv_u04    81920.00  63376.46   23%       42     1% /u04
   /dev/lv_u07   104448.00 101208.13    4%      340     1% /u07
   /dev/lv_u05    12288.00   2768.47   78%       89     1% /u05
   /dev/lv_u06    12288.00   2768.46   78%       89     1% /u06


# Check new free space on volume group

lsvg rootvg
   VOLUME GROUP:       rootvg             VG IDENTIFIER:  00c8425d00004c000000011f18c09ed8
   VG STATE:           active             PP SIZE:        32 megabyte(s)
   VG PERMISSION:      read/write         TOTAL PPs:      1406 (44992 megabytes)
   MAX LVs:            256                FREE PPs:       66 (2112 megabytes)
   LVs:                13                 USED PPs:       1340 (42880 megabytes)
   OPEN LVs:           12                 QUORUM:         1 (Disabled)
   TOTAL PVs:          2                  VG DESCRIPTORS: 3
   STALE PVs:          0                  STALE PPs:      0
   ACTIVE PVs:         2                  AUTO ON:        yes
   MAX PPs per VG:     32512
   MAX PPs per PV:     1016               MAX PVs:        32
   LTG size (Dynamic): 256 kilobyte(s)    AUTO SYNC:      no
   HOT SPARE:          no                 BB POLICY:      relocatable




# Extend F.S./volume
# ------------------------------------------------------------------------------------------

df -m
   Filesystem    MB blocks      Free %Used    Iused %Iused Mounted on
   /dev/hd4          64.00      2.98   96%     2783    77% /      <---
   /dev/hd2        1504.00    384.37   75%    36279    29% /usr
   /dev/hd9var     1024.00    225.42   78%      562     2% /var
   /dev/hd3        1024.00    961.14    7%     1818     1% /tmp
   /dev/hd1          32.00      9.35   71%      545    20% /local/home
   /proc                 -         -    -         -     -  /proc
   /dev/hd10opt      64.00     14.73   77%     1421    28% /opt
   /dev/localoptlv   4096.00   3795.95    8%     2776     1% /local/opt
   /dev/lv_u01     8192.00    602.98   93%    40496    20% /u01
   /dev/lv_u02    81920.00  59775.86   28%       54     1% /u02
   /dev/lv_u03    81920.00  50331.45   39%       56     1% /u03
   /dev/lv_u04    81920.00  63376.46   23%       42     1% /u04
   /dev/lv_u07   104448.00 101208.13    4%      340     1% /u07
   /dev/lv_u05    12288.00   2768.47   78%       89     1% /u05
   /dev/lv_u06    12288.00   2768.46   78%       89     1% /u06


# Let's extend by 512M

chfs -a size=+512M /
   Filesystem size changed to 1179648

# Otherwise, we can specify the final size like this:
# chfs -a size=1152M /

# chfs -a size=2G /


df -m
   Filesystem    MB blocks      Free %Used    Iused %Iused Mounted on
   /dev/hd4         576.00    514.91   11%     2783     3% /      <---
   /dev/hd2        1504.00    384.37   75%    36279    29% /usr
   /dev/hd9var     1024.00    225.42   78%      562     2% /var
   /dev/hd3        1024.00    961.14    7%     1818     1% /tmp
   /dev/hd1          32.00      9.35   71%      545    20% /local/home
   /proc                 -         -    -         -     -  /proc
   /dev/hd10opt      64.00     14.73   77%     1421    28% /opt
   /dev/localoptlv   4096.00   3795.95    8%     2776     1% /local/opt
   /dev/lv_u01     8192.00    602.82   93%    40520    20% /u01
   /dev/lv_u02    81920.00  59775.86   28%       54     1% /u02
   /dev/lv_u03    81920.00  50331.45   39%       56     1% /u03
   /dev/lv_u04    81920.00  63376.46   23%       42     1% /u04
   /dev/lv_u07   104448.00 101208.13    4%      340     1% /u07
   /dev/lv_u05    12288.00   2768.47   78%       89     1% /u05
   /dev/lv_u06    12288.00   2768.46   78%       89     1% /u06


lsvg rootvg
   VOLUME GROUP:       rootvg             VG IDENTIFIER:  00c8425d00004c000000011f18c09ed8
   VG STATE:           active             PP SIZE:        32 megabyte(s)
   VG PERMISSION:      read/write         TOTAL PPs:      1406 (44992 megabytes)
   MAX LVs:            256                FREE PPs:       34 (1088 megabytes)
   LVs:                13                 USED PPs:       1372 (43904 megabytes)
   OPEN LVs:           12                 QUORUM:         1 (Disabled)
   TOTAL PVs:          2                  VG DESCRIPTORS: 3
   STALE PVs:          0                  STALE PPs:      0
   ACTIVE PVs:         2                  AUTO ON:        yes
   MAX PPs per VG:     32512
   MAX PPs per PV:     1016               MAX PVs:        32
   LTG size (Dynamic): 256 kilobyte(s)    AUTO SYNC:      no
   HOT SPARE:          no                 BB POLICY:      relocatable
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
HOWTO: Implement SEA Failover with Dual VIOS
Viewed 1315 times since Tue, Jun 4, 2019
AIX - How to shutdown or reboot
Viewed 617 times since Fri, Jun 8, 2018
AIX HA / HACMP, System Admin↑ Mountguard
Viewed 1135 times since Mon, Jun 3, 2019
AIX: Error code 0516-1339, 0516-1397 0516-792: cannot extendvg with a previous Oracle ASM disk
Viewed 659 times since Wed, Feb 6, 2019
LVM: Extend an existing Volume Group by adding a new disk
Viewed 862 times since Sat, Jun 2, 2018
Online Backups and Recovery in a Snap AIX
Viewed 1033 times since Wed, May 30, 2018
AIX, Red Hat, Security, System Admin↑ System-wide separated shell history files for each user and session
Viewed 554 times since Fri, Apr 19, 2019
How To Mirror VG and Root VG
Viewed 1023 times since Mon, May 21, 2018
Remove disk from volumegroup in AIX
Viewed 600 times since Tue, Apr 16, 2019
Part 1, The basics of network troubleshooting
Viewed 1074 times since Tue, May 22, 2018