virtual-box

Resizing Kolla Vagrant CentOS base box

At the time of this writing Kolla uses the puppetlabs/centos-7.0-64-puppet as the base box for the Vagrant Virtual Box provider.
The main issue with the selected base box is that it only has a 20GB root disk. However, Kolla needs at least a 40GB disk when doing a All In One installation.

I ran into the following error when using the default 20GB base box:

The following SSH command responded with a non-zero exit status.  
Vagrant assumes that this means the command failed!  
cat /tmp/vagrant-network-entry_enp0s8 >> /etc/sysconfig/network-scripts/ifcfg-enp0s8  
Stdout from the command:  
Stderr from the command:  
cat: write error: No space left on device  

The temporary solution just to get Kolla installed using Vagrant without any further modifications is to resize the puppetlabs/centos-7.0-64-puppet base box to have a larger disk size.

Create Vagrant VM

After cloning the kolla repository, navigate to kolla/dev/vagrant and run vagrant up
Then shutdown the VM vagrant halt

Find Disk to be resized

List all VMS VBoxManage list vms

Keep note of the VM name
Example: "vagrant_operator_1446740538626_12437" {29db98c9-b085-4ecc-be9b-dba01d8c2256}

Find the VM disk: VBoxManage showvminfo vagrant_operator_1446740538626_12437 | | grep vmdk
Example: IDE Controller (0, 0): /Volumes/diogogmtdata/VirtualBox VMs/vagrant_operator_1446740538626_12437/packer-centos-7.0-x86_64-virtualbox-vagrant-puppet-1438003672-disk1.vmdk (UUID: 3ca3b592-784e-4dc2-9e84-af0b63bec83f)

Resize the disk

Convert VMDK disk to VDI: VBoxManage clonehd packer-centos-7.0-x86_64-virtualbox-vagrant-puppet-1438003672-disk1.vmdk vagrant-puppet-disk1.vdi --format vdi

Resize the VDI disk: VBoxManage modifyhd vagrant-puppet-disk1.vdi --resize 61440

Attach resized disk into the VM

Find the storage controller name: VBoxManage showvminfo vagrant_operator_1446740538626_12437 | grep Storage
Example: Storage Controller Name (0): IDE Controller

Attach disk into the VM: VBoxManage storageattach vagrant_operator_1446740538626_12437 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium vagrant-puppet-disk1.vdi

Note: By attaching as device 0 automatically will detach the existing disk

Create new primary partition

Start again the VM: vagrant reload && vagrant ssh

Using fdisk: fdisk /dev/sda

Command: n

  • Partition type: p (primary)
  • Partition number (3,4, default 3): 3
  • Use default value for first and last sectors

Command: t

  • Partition number (1-3, default 3): 3
  • Hex code (type L to list all codes): 8e

Command: w

Reboot VM: reboot

Extend partition

Create physical volume: pvcreate /dev/sda3

Extend volume group: vgextend centos /dev/sda3

Extend partition: lvextend -l +100%FREE /dev/mapper/centos-root

Since CentOS uses XFS as the file system you can't use resize2fs to resize the partition.

Instead use xfxgrowfs:
Install xfx
growfs: yum install -y xfsprogs.x86_64
Resize partition: xfs_growfs /dev/mapper/centos-root

Notes:

VirtualBox issue with TP-LINK-WN823N bridged interface

While running some test scenarios on my local development I encountered a bug with the bridged network interface on Virtual Box when using the wireless TP-LINK WN823N USB stick

Overview

One of my VMs has two network interfaces:

  1. Bridge interface to my en0:Ethernet
  2. Host only adapter which contains the static IP used to access the VM remotely

Since I have a problem with my wireless network card when I'm on the go I need to plug in an wireless USB stick to have internet connection, now if I have the VM running I need to change the interface to bridge the host intergace from en0:Ethernet to en5:USB WLAN

Problem

Theoratically I should be able to switch the bridged host interface and the VM should automaticaly get a new IP from the newly connected network. However, while running a test scenario to make sure that I wouldn't be left without internet access when being on the go, I found to my surprise that I had lost internet connectivity when bridging the en5:USB WLAN interface.

Initially I thought I needed to restart the interface on the VM to get the new settings from the DHCP server.

$: ifdown eth0 && ifup eht0
$: ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:3e:cb:64  
inet addr:10.0.0.253  
Bcast:10.0.0.255  
Mask:255.255.255.0  
inet6 addr: fd2b:f7e9:da9b:0:4c0e:b708:8908:c769/64 Scope:Global  
inet6 addr: fd2b:f7e9:da9b:0:a00:27ff:fe3e:cb64/64 Scope:Global  
inet6 addr: fe80::a00:27ff:fe3e:cb64/64 Scope:Link  
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  
RX packets:839 errors:0 dropped:1 overruns:0 frame:0  
TX packets:504 errors:0 dropped:0 overruns:0 carrier:0  
collisions:0 txqueuelen:1000  
RX bytes:75805 (75.8 KB)  TX bytes:54480 (54.4 KB)  

The bridged interface was up and configured and I could ping the host IP address. However, the gateway was unreachable.
I first thought the default gateway wasn't configured, but after checking I confirmed all the routes were OK.

$: ip route
default via 10.0.0.1 dev eth0  
10.0.0.0/24 dev eth0  proto kernel  scope link  src 10.0.0.253  

So even though the interface was up and the default gateway was set I still couldn't ping it.

Update

Since I had the mac wireless card fixed I don't need to use the USB stick anymore so I'm not facing this issue directly.
I might still give it a try with the latest version of VirtuaBox to see if the problem is still present.
If anybody has any ideas on what could be the problem or how to go about debugging please leave a comment below.