Resizing LVM Volumes

Just a quick note to remind myself outhow to resize logical and physical LVM volumes

  • Activate the Volume group:

lvm vgchange -ay

  • Resize the logical volume (sizing down by 100G in this example)

lvm lvresize --size -100G /dev/vg/root -r --verbose

  • Resize the physical volume:

pvresize --setphysicalvolumesize {size of pv minus {size toreduce}}G /dev/path/to/pv

  • If you get an error about “later extents”, it’s due to the swap being added to the partition (which does not get moved automatically), so you will need to move the data

lvm pvs -v --segments /dev/sda5 to get position ids:

/dev/sda5 ubuntu lvm2 a-- 698.04g 150g 0 xxx root 0 linear /dev/sda:0-xxx
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g xxx nnn 0 free                          
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g yyy zzz swap 0 linear /dev/sda5:yyy-zzz
  • Move the data:

lvm pvmove --alloc anywhere /dev/sda5:yyy-zzz

  • Check the positioning again

pvs -v --segments /dev/sda5

/dev/sda5 ubuntu lvm2 a-- 698.04g 150g 0 xxx root 0 linear /dev/sda:0-xxx
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g xxx nnn swap 0 linear /dev/sda5:xxx-yyy(-1)
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g yyy zzz 0 free
  • Then retry the resize

pvresize --setphysicalvolumesize {size of pv minus {size toreduce}}G /dev/path/to/pv

Linux & Windows Dual Booting Guide

Linux & Windows Dual Booting Guide

I’ve just finished work on a dual-boot setup guide with Linux and Windows 7. It covers setting up Dual Boot with Windows installed first or second, and with Linux installed first and second, and covers Linux distros that default to using LVM, such as Fedora, and those which don’t default to using LVM, such as Debian.

Link here:

http://wp.me/P3jVlp-Dz

Corporate Linux

Virtualization madness

Had my first encounter of Linux, or specifically, a linux-like environment in a corporate environment. The IT peops were trying to setup an environment on Xenserver, and they had setup a storage space to copy a virtual machine image onto. But they kept running out of space. It took me a while to figure out what they were doing (wrong), though.

They were trying to copy onto the PV partition, and Xenserver had setup its environment to use LVM, so the PV partition was already allocated to the LVM system, and therefore had no space to copy onto.

After figuring out which LV was the one they wanted to use, I had problems mounting, with mount saying I had to specify the filesystem. After trying various switches with mount and specifying a filesystem (only NFS, ext, ext2 and ext3 were supported by Xenserver. No vfat, ntfs or btrfs. Admittedly, however, the Xenserver version the IT people were using was an older version), I soon found out that the IT people had created the storage space, but not done anything else. Therefore, that would explain why I couldn’t mount it — it hadn’t been formatted. So a simple mkfs.ext3 (remember ext4 wasn’t supported) on the block device in /dev/mapper/ meant I could mount it without specifying filesystem. scp’ing into the server and copying into the path proved it worked.

 

%d bloggers like this: