Table of Contents
Increase LVM space in a VirtualBox OEL 6.3 env
Increase Disk space for your VirtualBox Image at OS level ( Windows 7 )
Shutdown your VBox Image C:\VM\12c> cd C:\VM\12c C:\VM\12c> vboxmanage modifyhd 12c.vdi --resize 40000 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Reboot your Vbox Image
Check out physical and logical Volume space
# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_hhrace01-lv_roor 27G 8.2G 18G 32% / # pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg_hhrace01 lvm2 a-- 30.30g 0 # lvs LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert lv_root vg_hhrace01 -wi-ao-- 27.23g lv_swap vg_hhrace01 -wi-ao-- 3.08g # lvdisplay /dev/mapper/vg_hhrace01-lv_swap --- Logical volume --- LV Path /dev/vg_hhrace01/lv_swap LV Name lv_swap VG Name vg_hhrace01 LV UUID 2XTX7f-CXmI-HdPh-36Fl-meKo-T9kd-iRuwLU LV Write Access read/write LV Creation host, time hhrace01.de.oracle.com, 2012-07-20 11:40:27 +0200 LV Status available # open 2 LV Size 3.08 GiB Current LE 788 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:1 # lvdisplay /dev/mapper/vg_hhrace01-lv_root --- Logical volume --- LV Path /dev/vg_hhrace01/lv_root LV Name lv_root VG Name vg_hhrace01 LV UUID NLIoRr-f1FI-u8ZG-fvQS-mpY4-67fX-rPe7vP LV Write Access read/write LV Creation host, time hhrace01.de.oracle.com, 2012-07-20 11:40:07 +0200 LV Status available # open 1 LV Size 27.23 GiB Current LE 6970 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:0
Add the new space to our LVM partition
# fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 41.9 GB, 41943040000 bytes
255 heads, 63 sectors/track, 5099 cylinders, total 81920000 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
Disk identifier: 0x0008c597
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 1026048 64581631 31777792 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First sector (63-81919999, default 63): 64581632
Last sector, +sectors or +size{K,M,G} (64581632-81919999, default 81919999):
Using default value 81919999
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
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)
Syncing disks.
Verifiy whehter we need a reboot - check whether our partition is already listed:
# fdisk -l
Disk /dev/sda: 41.9 GB, 41943040000 bytes
255 heads, 63 sectors/track, 5099 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008c597
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 4021 31777792 8e Linux LVM
/dev/sda3 4021 5100 8669184 8e Linux LVM
Disk /dev/mapper/vg_hhrace01-lv_root: 29.2 GB, 29234298880 bytes
255 heads, 63 sectors/track, 3554 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_hhrace01-lv_swap: 3305 MB, 3305111552 bytes
255 heads, 63 sectors/track, 401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
# pvcreate /dev/sda3
Device /dev/sda3 not found (or ignored by filtering).
--> So we need to reboot VBox Image
# pvcreate /dev/sda3
Writing physical volume data to disk "/dev/sda3"
Physical volume "/dev/sda3" successfully created
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_hhrace01 lvm2 a-- 30.30g 0
/dev/sda3 lvm2 a-- 8.27g 8.27g
# vgdisplay
--- Volume group ---
VG Name vg_hhrace01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 30.30 GiB
PE Size 4.00 MiB
Total PE 7758
Alloc PE / Size 7758 / 30.30 GiB
Free PE / Size 0 / 0
VG UUID 1HKbMF-KSxu-Sdo5-Fs5V-kr6P-i4jL-X9CHci
# vgextend vg_hhrace01 /dev/sda3
Volume group "vg_hhrace01" successfully extended
# pvscan
PV /dev/sda2 VG vg_hhrace01 lvm2 [30.30 GiB / 0 free]
PV /dev/sda3 VG vg_hhrace01 lvm2 [8.27 GiB / 8.27 GiB free]
Total: 2 [38.57 GiB] / in use: 2 [38.57 GiB] / in no VG: 0 [0 ]
# lvdisplay
--- Logical volume ---
LV Path /dev/vg_hhrace01/lv_root
LV Name lv_root
VG Name vg_hhrace01
LV UUID NLIoRr-f1FI-u8ZG-fvQS-mpY4-67fX-rPe7vP
LV Write Access read/write
LV Creation host, time hhrace01.de.oracle.com, 2012-07-20 11:40:07 +0200
LV Status available
# open 1
LV Size 27.23 GiB
Current LE 6970
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
# lvextend /dev/vg_hhrace01/lv_root /dev/sda3
Extending logical volume lv_root to 35.49 GiB
Logical volume lv_root successfully resized
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_hhrace01-lv_root 27G 8.2G 18G 32% /
# resize2fs /dev/mapper/vg_hhrace01-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_hhrace01-lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/vg_hhrace01-lv_root to 9304064 (4k) blocks.
The filesystem on /dev/mapper/vg_hhrace01-lv_root is now 9304064 blocks long.
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_hhrace01-lv_root 35G 8.2G 26G 25% /
Add space to file system if free space in our physical volume group is available
# pvs PV VG Fmt Attr PSize PFree /dev/sda2 vg_hhrace01 lvm2 a-- 30.30g 0 /dev/sda3 vg_hhrace01 lvm2 a-- 8.26g 5.26g # vgdisplay --- Volume group --- VG Name vg_hhrace01 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 38.57 GiB PE Size 4.00 MiB Total PE 9873 Alloc PE / Size 8526 / 33.30 GiB Free PE / Size 1347 / 5.26 GiB VG UUID 1HKbMF-KSxu-Sdo5-Fs5V-kr6P-i4jL-X9CHci # lvextend -L+1G /dev/mapper/vg_hhrace01-lv_root Extending logical volume lv_root to 28.23 GiB Logical volume lv_root successfully resized # df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_hhrace01-lv_root 27G 19G 6.7G 74% / Resize filesytem # resize2fs /dev/mapper/vg_hhrace01-lv_root resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mapper/vg_hhrace01-lv_root is mounted on /; on-line resizing required old desc_blocks = 2, new_desc_blocks = 3 Performing an on-line resize of /dev/mapper/vg_hhrace01-lv_root to 8448000 (4k) blocks. The filesystem on /dev/mapper/vg_hhrace01-lv_root is now 8448000 blocks long. # df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_hhrace01-lv_root 32G 19G 12G 63% / tmpfs 2.1G 500M 1.6G 24% /dev/shm /dev/sda1 485M 103M 357M 23% /boot kits 589G 395G 195G 67% /media/sf_kits kits 589G 395G 195G 67% /KITS /dev/sr0 57M 57M 0 100% /media/VBOXADDITIONS_4.2.14_86644