• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

lvreduce Command Examples in Linux

by admin

If the plan is to make the LV smaller, you first have to resize the filesystem and then use the lvreduce command to decrease the size of the LV. This is because if you reduced the LV first, the system would not be able to access the filesystem beyond the new LV size.

To shrink the size of an LV, there are five important steps, and they must be executed in order or the procedure will fail and potentially cause filesystem damage:

1. Unmount the mount point or logical volume with the umount command.

# umount /mount/point

2. Force fsck to check the filesystem.

# fsck -f /dev/mapper/VG0-lv0

3. Use resize2fs to reduce the filesystem.

# resize2fs /dev/mapper/VG0-lv0 24M

4. Use lvreduce to reduce the size of the logical volume.

# lvreduce -L -40M /dev/mapper/VG0-lv0

5. Mount the filesystem with the mount command.

# mount /dev/mapper/VG0-lv0 /mount/point
# df -hP /mount/point

lvreduce command examples

1. To reduce the logical volume:

# lvreduce -l [-]LogicalExtentsNumber[%{VG|LV|FREE|ORIGIN}]

2. To disable udev synchronization:

# lvreduce --noudevsync

3. To reduce or set the logical volume size in units of logical extents:

# lvreduce -l [-]LogicalExtentsNumber[%{VG|LV|FREE|ORIGIN}]
# lvreduce --extents [-]LogicalExtentsNumber[%{VG|LV|FREE|ORIGIN}]

4. To reduce or set the logical volume size in units of megabytes:

# lvreduce -L [-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]
# lvreduce --size [-]LogicalVolumeSize[bBsSkKmMgGtTpPeE]

5. To do not perform fsck before resizing filesystem when filesystem requires it:

# lvreduce -n
# lvreduce --nofsck

6. To resize underlying filesystem together with the logical volume using fsadm:

# lvreduce -r 
# lvreduce --resizefs

Filed Under: Linux

Some more articles you might also be interested in …

  1. findmnt: command not found
  2. How to Create a Bridge Interface Using nmcli in CentOS/RHEL 7 and 8
  3. lvscan Command Examples in Linux
  4. collectd : command not found
  5. e4defrag Command Examples in Linux
  6. dkms: command not found
  7. vgextend Command Examples in Linux
  8. How to Troubleshoot Performance Issues on Linux – Beginners Guide
  9. w Command Examples in Linux
  10. createrepo: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • raw: command not found
  • raw Command Examples in Linux
  • rankmirrors Command Examples in Linux
  • radeontop: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright