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
R2dump debug tool
Viewed 2018 times since Tue, Sep 8, 2020
ILMT Procedure - ILMT / TAD4D / SUA / BFI
Viewed 10042 times since Fri, Jul 5, 2019
List STALE partitions across Volume Groups for each Logical Volume in AIX
Viewed 2423 times since Tue, Jul 17, 2018
Finding password rules in AIX
Viewed 2553 times since Mon, May 28, 2018
Convert to Scalable Volume Groups
Viewed 3652 times since Wed, May 30, 2018
AIX NTP Client configuration
Viewed 11806 times since Tue, Jul 17, 2018
AIX, Security, System Admin Difference between sticky bit and SUID/GUID
Viewed 8841 times since Fri, Apr 19, 2019
Mirroring session (TTY) on AIX using portmir
Viewed 9217 times since Thu, Feb 21, 2019
AIX disk queue depth tuning for performance
Viewed 15088 times since Thu, Jan 16, 2020
AIX -- extending Logical Volumes online
Viewed 2621 times since Tue, Mar 12, 2019