LVM Resize a Filesystem: Difference between revisions

From UNIX Systems Administration
Jump to navigation Jump to search
No edit summary
Line 7: Line 7:
== Linux ==
== Linux ==
==== Extend an ext4 Filesystem ====
==== Extend an ext4 Filesystem ====
# Increase the size of the logical volume.
# Increase the size of the logical volume
#:<tt>'''# lvextend -L +<size>[M | G] /dev/<volume_group>/<logical_volume>'''</tt>
#:<tt>'''# lvextend -L +<size>[M | G] /dev/<volume_group>/<logical_volume>'''</tt>
# Resize the underlying filesystem
# Resize the underlying filesystem
#: <tt>'''# resize2fs /dev/<volume_group>/<logical_volume>'''</tt>
#: <tt>'''# resize2fs /dev/<volume_group>/<logical_volume>'''</tt>
==== Extend an xfs Filesystem ====
==== Extend an xfs Filesystem ====
# Increase the size of the logical volume.
# Increase the size of the logical volume
#:<tt>'''# lvextend -L +<size>[M | G] /dev/<volume_group>/<logical_volume>'''</tt>
#:<tt>'''# lvextend -L +<size>[M | G] /dev/<volume_group>/<logical_volume>'''</tt>
# Resize the underlying filesystem
# Resize the underlying filesystem
#: <tt>'''# xfs_growfs -d </path/to/filesystem>'''</tt>
#: <tt>'''# xfs_growfs -d </path/to/filesystem>'''</tt>
==== Reduce an ext4 Filesystem ====
==== Reduce an ext4 Filesystem ====
# Note: You may have to change to runlevel 1 in order to unmount.
# Note: You may have to change to runlevel 1 in order to unmount
# Backup your data!
# Backup your data!
# Dismount the filesystem before reducing the size.
# Dismount the filesystem before reducing the size
#: <tt>'''# umount /dev/<volume_group>/<logical_volume>'''</tt>
#: <tt>'''# umount /dev/<volume_group>/<logical_volume>'''</tt>
# Force check the filesystem to ensure it is clean. '''DO NOT RUN <tt>e2fsck</tt> IF THE FILESYSTEM IS MOUNTED'''.
# Force check the filesystem to ensure it is clean. '''DO NOT RUN <tt>e2fsck</tt> IF THE FILESYSTEM IS MOUNTED'''
#: <tt>'''# e2fsck –f /dev/<volume_group>/<logical_volume>'''</tt>
#: <tt>'''# e2fsck –f /dev/<volume_group>/<logical_volume>'''</tt>
# Reduce the filesystem.
# Reduce the filesystem
#: <tt>'''# resize2fs /dev/<volume_group>/<logical_volume> -<size>[M | G]'''</tt>
#: <tt>'''# resize2fs /dev/<volume_group>/<logical_volume> -<size>[M | G]'''</tt>
# Reduce the logical volume.
# Reduce the logical volume
#: <tt>'''# lvreduce –L -<size>[M | G] /dev/<volume_group>/<logical_volume>'''</tt>
#: <tt>'''# lvreduce –L -<size>[M | G] /dev/<volume_group>/<logical_volume>'''</tt>
# Re-check the filesystem to ensure it is clean.
# Re-check the filesystem to ensure it is clean
#: <tt>'''# e2fsck –f /dev/<volume_group>/<logical_volume>'''</tt>
#: <tt>'''# e2fsck –f /dev/<volume_group>/<logical_volume>'''</tt>
# Mount the filesystem.
# Mount the filesystem
#: <tt>'''# mount /dev/<volume_group>/<logical_volume>'''</tt>
#: <tt>'''# mount /dev/<volume_group>/<logical_volume>'''</tt>



Revision as of 18:53, 1 March 2017

AIX

Extend a Filesystem

  1. # chfs -a size=+<additional size>M <absolute path to filesystem>

Reduce a Filesystem

  1. # chfs -a size=-<reduced size>M <absolute path to filesystem>

Linux

Extend an ext4 Filesystem

  1. Increase the size of the logical volume
    # lvextend -L +<size>[M | G] /dev/<volume_group>/<logical_volume>
  2. Resize the underlying filesystem
    # resize2fs /dev/<volume_group>/<logical_volume>

Extend an xfs Filesystem

  1. Increase the size of the logical volume
    # lvextend -L +<size>[M | G] /dev/<volume_group>/<logical_volume>
  2. Resize the underlying filesystem
    # xfs_growfs -d </path/to/filesystem>

Reduce an ext4 Filesystem

  1. Note: You may have to change to runlevel 1 in order to unmount
  2. Backup your data!
  3. Dismount the filesystem before reducing the size
    # umount /dev/<volume_group>/<logical_volume>
  4. Force check the filesystem to ensure it is clean. DO NOT RUN e2fsck IF THE FILESYSTEM IS MOUNTED
    # e2fsck –f /dev/<volume_group>/<logical_volume>
  5. Reduce the filesystem
    # resize2fs /dev/<volume_group>/<logical_volume> -<size>[M | G]
  6. Reduce the logical volume
    # lvreduce –L -<size>[M | G] /dev/<volume_group>/<logical_volume>
  7. Re-check the filesystem to ensure it is clean
    # e2fsck –f /dev/<volume_group>/<logical_volume>
  8. Mount the filesystem
    # mount /dev/<volume_group>/<logical_volume>

Further Reading

  1. IBM pSeries and AIX Information Center