So I searched for how to expand a LV (logical volume) under LVM, and
every single page was telling me how to add another disk or another
partition.
This particular machine is running as a Xen virtual, and it had also
been installed with LVM. Yes, I'm aware that's extra layers of indirection.
Here's the method I used to increase the disk size, again posted for
those who come later.
Adding extra physical volumes to a VG
vgextend my_volume_group /dev/sdX1 /dev/sdY1 ...
Adding extra "virtual" space to a VG
This one is if you have a Xen VM with a disk that is also LVM.
1.
Stop the VM and enlarge the disk in XenCenter.
2. Start the VM again and boot the OS
3.
Log in as root and run fdisk /dev/xvda
[root@mail ~]# fdisk /dev/xvda
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/xvda: 20 GiB, 21485322240 bytes, 41963520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0005041e
Device Boot Start End Sectors Size Id Type
/dev/xvda1 * 2048 1026047 1024000 500M 83 Linux
/dev/xvda2 1026048 20987903 19961856 9.5G 8e Linux LVM
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 has been deleted.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (1026048-41963519, default 1026048):
Last sector, +sectors or +size{K,M,G,T,P} (1026048-41963519, default
41963519):
Created a new partition 2 of type 'Linux' and of size 19.5 GiB.
4.
Reset the new partition type to *8e*
Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.
5.
Write the changes
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next
reboot or after you run partprobe(8) or kpartx(8).
6.
Run partprobe to reread the disk partition sizes
[root@mail ~]# partprobe
7.
Then expand the Physical Volume's size
[root@mail ~]# pvresize /dev/xvda2
Physical volume "/dev/xvda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
[root@mail ~]# pvdisplay
--- Physical volume ---
PV Name /dev/xvda2
VG Name vg_mail
PV Size 19.52 GiB / not usable 20.81 MiB
Allocatable yes
PE Size 32.00 MiB
Total PE 624
Free PE 320
Allocated PE 304
8. Then you can roll onwards and extend the LVs into the new physical
extents.
--
CF
_______________________________________________
Linux-users mailing list
[email protected]
http://lists.canterbury.ac.nz/mailman/listinfo/linux-users