Learn Linux storage with Basic Linux Storage Scenario #4.

Resize the file system /opt from its current size of 300MB to 200MB. Do not lose any Data while performing the resizing

  • If /opt as allocated storage as standard partition then it is not able to allocate /resize the storage
  • If /opt as allocated as lvm then it can be resized.

Commands to reduce lvm disk size:Basic Linux Storage Scenario #4

  • df –h
  • lvreduce
  • resize2fs
  • umount
  • fsck

Related files:

/etc/fstab

  • Check any data on /opt
  • umount
  • fsck /dev/vg/lv-opt //to fix any corrupted block (vg may be different)
  • $ resize2fs /dev/vg/lv-opt 200M
  • e2fsck –F /dev/vg/lv-opt      //To clean corrupted block, If fsck command not work, use this command
  • Use step (4)
  • lvreduce 0L 200M /dev/vg/lv-opt
    • It may destroy data
      • Anyhow we have resized the data in step (4) – all data will be resized within 200M
  • mount –a
  • df –f  or lvdisplay      // to check LV as reduce to 200MB
  • check whether we have lost data
    • ls /opt/

Note: Logical Volume:- can be extended or reduced at any time.