Skip to content

Instantly share code, notes, and snippets.

@knzm
Created July 19, 2012 16:39
Show Gist options
  • Select an option

  • Save knzm/3145179 to your computer and use it in GitHub Desktop.

Select an option

Save knzm/3145179 to your computer and use it in GitHub Desktop.
memo: remove a disk from LVM with shrinking ext3 partition
1. check free space by running "df -h"
=> under 50%, ok
2. unmount the volume
3. dumpe2fs -h /dev/VolGroup00/data
Block count: 10483712
Reserved block count: 524069
Free blocks: 6391697
Free inodes: 2621196
First block: 0
Block size: 4096
4. e2fsck -fC0 /dev/VolGroup00/data
=> /dev/VolGroup00/data: 244/2621440 files (17.6% non-contiguous), 4092015/10483712 blocks
5. resize2fs -p /dev/VolGroup00/data 5000000
6. mount, check size, then unmount
7. lvdisplay
LV Size 39.99 GiB
Current LE 10238
8. lvreduce -l 5119 /dev/VolGroup00/data
9. vgdisplay
Alloc PE / Size 5119 / 20.00 GiB
Free PE / Size 5119 / 20.00 GiB
10. e2fsck -fC0 /dev/VolGroup00/data
11. resize2fs -p /dev/VolGroup00/data
12. vgreduce VolGroup00 /dev/xvdg1
13. pvscan
PV /dev/xvdf1 VG VolGroup00 lvm2 [20.00 GiB / 0 free]
PV /dev/xvdg1 lvm2 [20.00 GiB]
Now we can detach the volume xvdg! (unless any other partitions are used)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment