Using Vagrant and Virtual box is very easy, but most boxes have very little space provisioned for the root volume, these steps will show how to covert your storage from a VMDK (Virtual Machine Disk) to a VDI (Virtual Disk Image), then expand that disk to a more appropriate size.
-make certain you have available space on your host machine prior to starting this exercise.
$ cd VirtualBox\ VMs/
$ ls
vagrants_oraclelinux1_testdb
$ cd vagrants_oraclelinux1_testdb/
$ ls
Logs box-disk1.vmdk vagrants_oraclelinux1_testdb.vbox
$ VBoxManage clonehd box-disk1.vmdk box-disk1.vdi -format VDI
$ ls
Logs box-disk1.vmdk box-disk1.vdi vagrants_oraclelinux1_testdb.vbox
--25gb for small db on root volume
$ VBoxManage modifyhd box-disk1.vdi --resize 25000
$ vagrants_oraclelinux1_testdb daniels$ VBoxManage showvminfo vagrants_oraclelinux1_testdb | grep "Storage"
Storage Controller Name (0): IDE Controller
Storage Controller Type (0): PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0): 2
Storage Controller Port Count (0): 2
Storage Controller Bootable (0): on
Storage Controller Name (1): SATA Controller
Storage Controller Type (1): IntelAhci
Storage Controller Instance Number (1): 0
Storage Controller Max Port Count (1): 30
Storage Controller Port Count (1): 1
Storage Controller Bootable (1): on
$ vagrants_oraclelinux1_testdb daniels$ VBoxManage showhdinfo "box-disk1.vdi"
UUID: cd2bdcc2-87ba-4e07-88dd-a5f77c61aba1
Parent UUID: base
State: locked write
Type: normal (base)
Location: /Users/drstanle/VirtualBox VMs/vagrants_oraclelinux1_testdb/box-disk1.vdi
Storage format: VDI
Format variant: dynamic default
Capacity: 20000 MBytes
Size on disk: 2166 MBytes
Encryption: disabled
$ VBoxManage storageattach vagrants_oraclelinux1_testdb --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium box-disk1.vdi
--note
at this point you can remove/release the vmdk volume from your Virtual Machine. either delete the file on the OS or remove it from your VM console.
$ vagrant up
$ vagrant ssh
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 8.3G 1.4G 6.5G 18% / <------- not nearly enough
tmpfs 230M 0 230M 0% /dev/shm
/dev/sda1 477M 55M 398M 12% /boot
# fdisk -l
# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sda: 26.2 GB, 26214400000 bytes
255 heads, 63 sectors/track, 3187 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: 0x0007bd61
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 1293 9870336 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1293-3187, default 1293):
Using default value 1293
Last cylinder, +cylinders or +size{K,M,G} (1293-3187, default 3187):
Using default value 3187
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.
WARNING: Re-reading the partition table failed with error 16: 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)
Syncing disks.
# shutdown -h now
$ vagrant ssh
# vgdisplay -determine lv mapping belonging to VolGroupOS
--- Volume group ---
VG Name VolGroup
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 9.41 GiB
PE Size 4.00 MiB
Total PE 2409
Alloc PE / Size 2409 / 9.41 GiB
Free PE / Size 0 / 0
VG UUID QLTbVE-sgqO-2CC0-fTmL-unRg-nnC7-vT56n6
# vgextend VolGroup /dev/sda3
No physical volume label read from /dev/sda3
Physical volume /dev/sda3 not found
Physical volume "/dev/sda3" successfully created Volume group "VolGroup" successfully extended
# ls /dev/mapper/
control VolGroup-lv_root VolGroup-lv_swap
# lvextend -l +100%FREE /dev/mapper/VolGroup-lv_root
Extending logical volume lv_root to 23.01 GiB
Logical volume lv_root successfully resized
# resize2fs /dev/mapper/VolGroup-lv_root
resize2fs 1.43-WIP (20-Jun-2013)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mapper/VolGroup-lv_root is now 6032384 blocks long.
# exit
$ vagrant reload --provision
$ vagrant ssh
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 23G 1.4G 21G 7% / <---------woohoo
tmpfs 230M 0 230M 0% /dev/shm
/dev/sda1 477M 55M 398M 12% /boot
vagrant 465G 184G 282G 40% /vagrant
enjoy
No comments:
Post a Comment