Description
The vxresize command either grows or shrinks both the file system and its underlying volume to match the specified new volume length.
# /etc/vx/bin/vxresize [-F fstype] [-g diskgroup] volume new_size
Note1 : new_size is the final size or it can begin with a + or – to add or subtract from the current volume size
For example for the following 2 mounted file system below we have
# df -k /vxfsmnt
Filesystem kbytes used avail capacity Mounted on
/dev/vx/dsk/testdg/vxfsvol 174080 120008 53680 70% /vxfsmnt << file system size = 174080kb
/dev/vx/dsk/testdg/ufsvol 163327 14257 4423 97% /ufsmnt << file system size = 163327 kb
Step 1: Confirm the file system type (fstype) ,volume and file system size are the same and ensure that the file system capacity is not 100%., if capacity 100% , remove some unwanted data before proceeding
# vxprint -qgtestdg -v vxfsvol
v testvol fsgen ENABLED 348160 - ACTIVE - - << volume size = 348160sec = 174080kb
# fstyp -v /dev/vx/dsk/testdg/vxfsvol | head -4
vxfs << file system type = vxfs version 7
magic a501fcf5 version 7 ctime Thu May 09 16:05:06 2013
logstart 0 logend 0
bsize 8192 size 21760 dsize 0 ninode 174080 nau 0 << filesystem size = {( bsize*size)/1024} = 174080kb
# vxprint -qg testdg -v ufsvol
v ufsvol fsgen ENABLED 348160 - ACTIVE - - << volume size = 348160sec = 174080kb
# fstyp -v /dev/vx/dsk/testdg/ufsvol | head -9
ufs << file system type = ufs
magic 11954 format dynamic time Wed May 15 09:27:39 2013
sblkno 16 cblkno 24 iblkno 32 dblkno 992
sbsize 2048 cgsize 4096 cgoffset 32 cgmask 0xffffffe0
ncg 11 size 174080 blocks 163327 << filesystem size=174080kb, actual available blocks=163327kb
bsize 8192 shift 13 mask 0xffffe000
fsize 1024 shift 10 mask 0xfffffc00
frag 8 shift 3 fsbtodb 1
minfree 10% maxbpg 2048 optim time << minfree reduces the number of available blocks for UFS
Step 2: Check the status of the file system is clean
For vxfs we have
# echo “8192B.p S” | fsdb -F vxfs /dev/vx/rdsk/testdg/vxfsvol
flags 4000 mod 0 clean 3c << for vxfs version 7 and greater
or
flags 0 mod 0 clean 3c << for vxfs version 6 or under
Both of these flag indicate the file system are CLEAN and vxresize will not have any issue, any other output will require an umount of filesystem and a file system check (fsck –F vxfs)
Similarly for UFS we have:
# fsdb -F ufs /dev/vx/dsk/testdg/ufsvol
fsdb of /dev/vx/dsk/testdg/ufsvol (Read only) -- last mounted on /ufsmnt
fs_clean is currently set to FSLOG
fs_state consistent (fs_clean CAN be trusted)
/dev/vx/dsk/testdg/ufsvol > ^D (cntrl ^D to exit)
This indicates the file system has logging enabled, and the is set to FSLOG, if it contained inconsistent file system data , the flag would be set FSBAD and require full file system check (fsck –F ufs). With disabled logging the flag would be set FSCLEAN to indicate a undamaged cleanly mounted file system.
Step 3a: For growing a volume and the underlying file system, determine if there is available free space to grow volume
# vxdg -g testdg free
DISK DEVICE TAG OFFSET LENGTH FLAGS
disk0 c4t50060E80004372C0d2s2 c4t50060E80004372C0d2 1220608 9120000 -
disk1 c4t50060E80004372C0d16s2 c4t50060E80004372C0d16 524288 331520 -
disk2 c4t50060E80004372C0d21s2 c4t50060E80004372C0d21 524288 331520 -
disk3 c4t50060E80004372C0d31s2 c4t50060E80004372C0d31 524288 331520 -
Alternatively, we can run vxassist commands to determine what the available free space can be used:
i. All available free space in the disk group
# vxassist –g testdg maxgrow vxfsvol layout=concat
Volume vxfsvol can be extended by 10113024 to: 10461184 (5108Mb)
ii. Specify a disk from the available free disk pool in the disk group
# vxassist -g testdg maxgrow ufsvol layout=concat disk0
Volume ufsvol can be extended by 9119744 to: 9467904 (4623Mb)
Step 3b: If you shrinking a file system (only applicable to vxfs fstype), confirm the file system in not defragmented and if there is free space at available so there is enough disk storage for data after shrinking the file system.
i. Check if available space is free for shrinking at the end of the volume for success
Using the size of the volume and the amount you wish to shrink making sure the value does not exceed the used space and allowing a little extra so the file system does not become 100% full after shrinking.
Filesystem kbytes used avail capacity Mounted on
/dev/vx/dsk/testdg/vxfsvol 174080 120008 53680 70% /vxfsmnt
In this example. we will shrink by 5Mb=10240sectors, volume size= 348160 sectors,so we need to check if there is free available space between 337920 - 348160
# ncheck -F vxfs -o sector=348000-348160 /dev/vx/dsk/testdg/vxfsvol
/dev/vx/dsk/testdg/vxfsvol:
sectors(160) blocks(0)
----------------- -----------------
0/348000-0/348159 0/21750-0/21760
fileset fset match match devid/ name indx inode indx inode sectors name
---------- ---- ------ ---- ------ ------------- ------------------
- - - - - 0/ 337920 -0/348159 << available space is free…ok to proceeed
ii. Defragmentation
Run defrag report to determine level of fragmentation
#/opt/VRTS/bin/fsadm -DE /vxfsmnt
Directory Fragmentation Report
Dirs Total Immed Immeds Dirs to Blocks
Searched Blocks Dirs to Add Reduce Reduce
total 212 51 163 3 3 3
Extent Fragmentation Report
Total Average Average Total
Files File Blks # Extents Free Blks
1818 10 1 2874
blocks used for indirects: 0
% Free blocks in extents smaller than 64 blks: 4.24
% Free blocks in extents smaller than 8 blks: 0.35
% blks allocated to extents 64 blks or larger: 82.83
Run defragmentation for a specific period using the –t option (in seconds)
# /opt/VRTS/bin/fsadm -t 100 -de /vxfsmnt
Recheck the defragmentation report, rerun as required until an acceptable value is reached
Step 4: Running the vxresize commands ( -D debug optional) for growing
a. UFS file system
# vxresize -F ufs -g testdg -D ufsvol +20m
VxVM vxresize INFO V-5-1-2742 volume: ufsvol new_length=389120 media=usetype: fsgen old_length=348160 vx_devname: /dev/vx/rdsk/testdg/ufsvol blkname=/dev/vx/dsk/testdg/ufsvol
VxVM vxresize INFO V-5-1-2735 filesystem type: UFS
VxVM vxresize INFO V-5-1-2696 /dev/vx/rdsk/testdg/ufsvol is mounted on /ufsmnt
VxVM vxresize INFO V-5-1-2725 VXASSIST_CMD: /usr/sbin/vxassist -g testdg growto ufsvol 389120 2>&1
VxVM vxresize INFO V-5-1-2727 VXASSIST_CMD: volume ufsvol, diskgroup testdg is currently 348160 sectors - size will grow to 389120 sectors
VxVM vxresize INFO V-5-1-2719 UFS_MKFS_CMD: /usr/lib/fs/ufs/mkfs -M "/ufsmnt" "/dev/vx/rdsk/testdg/ufsvol" "389120" 2>&1
VxVM vxresize INFO V-5-1-0 /dev/vx/rdsk/testdg/ufsvol: 389120 sectors in 190 cylinders of 32 tracks, 64 sectors
VxVM vxresize INFO V-5-1-0 190.0MB in 12 cyl groups (16 c/g, 16.00MB/g, 7680 i/g)
VxVM vxresize INFO V-5-1-0 super-block backups (for fsck -F ufs -o b=#) at:
VxVM vxresize INFO V-5-1-0 32, 32864, 65696, 98528, 131360, 164192, 197024, 229856, 262688, 295520,
VxVM vxresize INFO V-5-1-0 328352, 361184
Highlighted in BOLD, the vxassist commands which grows the volume to new size, followed by the mkfs command to grow the file UFS system
b. For vxfs file system we have:
# /etc/vx/bin/vxresize -F vxfs -D -g testdg vxfsvol +20m
VxVM vxresize INFO V-5-1-2742 volume: vxfsvol new_length=389120 media=usetype: fsgen old_length=348160 vx_devname: /dev/vx/rdsk/testdg/vxfsvol blkname=/dev/vx/dsk/testdg/vxfsvol
VxVM vxresize INFO V-5-1-2737 filesystem type: VXFS
VxVM vxresize INFO V-5-1-2696 /dev/vx/rdsk/testdg/vxfsvol is mounted on /vxfsmnt
VxVM vxresize INFO V-5-1-2725 VXASSIST_CMD: /usr/sbin/vxassist -g testdg growto vxfsvol 389120 2>&1
VxVM vxresize INFO V-5-1-2727 VXASSIST_CMD: volume vxfsvol, diskgroup testdg is currently 348160 sectors - size will grow to 389120 sectors
VxVM vxresize INFO V-5-1-8579 VXFS_FSADM_CMD : /usr/lib/fs/vxfs/fsadm -Fvxfs -r "/dev/vx/rdsk/testdg/vxfsvol" -b 389120 "/vxfsmnt"
VxVM vxresize INFO V-5-1-0 UX:vxfs fsadm: INFO: V-3-25942: /dev/vx/rdsk/testdg/vxfsvol size increased from 348160 sectors to 389120 sectors
Highlighted in BOLD, the vxassist commands which grows the volume to new size, followed by the fsadm command to grow the VXFS file system.
c. for vxfs we can also shrink the volume/filesystem ( UFS filesystem CANNOT be shrunk) as follows:
# vxresize -g testdg -D vxfsvol -50m
VxVM vxresize INFO V-5-1-2742 volume: vxfsvol new_length=4302080 media=usetype: fsgen old_length=4404480
vx_devname: /dev/vx/rdsk/testdg/tvol blkname=/dev/vx/dsk/testdg/vxfsvol
VxVM vxresize INFO V-5-1-2737 filesystem type: VXFS
VxVM vxresize INFO V-5-1-2696 /dev/vx/rdsk/testdg/vxfsvol is mounted on /vxfsmnt
VxVM vxresize INFO V-5-1-8579 VXFS_FSADM_CMD: /usr/lib/fs/vxfs/fsadm -Fvxfs -r "/dev/vx/rdsk/testdg/vxfsvol" -b 4302080 "/vxfsmnt"
VxVM vxresize INFO V-5-1-0 UX:vxfs fsadm: INFO: V-3-23586: /dev/vx/rdsk/testdg/vxfsvol is currently 4687360 sectors - size will be reduced
VxVM vxresize INFO V-5-1-2725 VXASSIST_CMD: /usr/sbin/vxassist -f -g testdg shrinkto vxfsvol 4302080 2>&1
VxVM vxresize INFO V-5-1-2726 VXASSIST_CMD: volume vxfsvol, diskgroup testdg currently 4404480 sectors - size will shrink to 4302080 sectors.
Highlighted in BOLD, the fsadm commands which shrinks the VXFS file system to new size, followed by the vxassist command to shrink the volume to match.