wtorek, 24 stycznia 2017

Resize vagrant disk storage (hard drive) with Virtual Box provider and Windows guest.

You need to know your VM name. It can be checked with:
> VBoxManage list vms
"YOUR_VM_NAME" {385e587a-ad47-4d36-a734-a126b9e04590}

Usually vagrant boxes comes with VMDK type storage which cannot be resized. 
You need to convert the format to resizeable VDI.
> VBoxManage  clonehd \
"/root/VirtualBox VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vmdk" \
"/root/VirtualBox VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vdi" \
--format vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'vdi'. UUID: 67985552-a3e5-4fad-aedd-82565ac963d4


packer-virtualbox-iso-1459796137-disk1.vmdk is a hdd disk file. Your file name can differ slightly. 
packer-virtualbox-iso-1459796137-disk1.vdi is new disk file that will be created in VDI format.
 
Now it's time to resize the disk image.
> VBoxManage modifymedium \
/root/VirtualBox\ VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vdi \
--resize 163840
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

163840 is new disk size in MB. Now you need to convert the disk image back to VMDK.
> VBoxManage  clonehd \
"/root/VirtualBox VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vdi" \
"/root/VirtualBox VMs/YOUR_VM_NAME/packer-virtualbox-iso-1459796137-disk1.vmdk" \
--format vmdk
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'vmdk'. UUID: 9f433356-976c-422b-b7f1-2e1279cec993


Run the VM (for example: `vagrant up`). In our case it is a Windows machine. 
That's why you need to go to the guest system and increase disk size there.
Open Disk Management `diskmgmt.msc`. Right click on allocated partition and click Extend Volume.

środa, 11 stycznia 2017

How to install Ansible on Debian Jessie

I'm starting with fresh minimal netinst Debian jessie.


  1. Add ubuntu package repository from where ansible will be installed (don't worry, it is official way of installing ansible on debian)

    echo "deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main" >> /etc/apt/sources.list
  2. Install ansible

    apt-get update
    apt-get install ansible
  3. Verify installation

    ansible --version

poniedziałek, 9 stycznia 2017

Comment out with notepad++

Usually Ctrl + / but in notepad++ the shortcut to comment out selected block code is:

  Ctrl + Shift + Q

 

However to comment out single line the shortcut is:

  Ctrl + Q

piątek, 6 stycznia 2017

Debian network related configuration files

/etc/protocols    List of internet protocols, i.e. tcp, udp
/etc/services      List of system ports with applications, i.e 22 SSH
/etc/network/interfaces   List of network interface cards (nic), i.e. eth0, lo
/etc/hostname    Host name


Install Vagrant and Virtual Box on Debian

I'm starting with fresh minimal netinst Debian jessie.
  1. Install Vagrant (1.9.1 here - check if you have newer version available)

    wget https://releases.hashicorp.com/vagrant/1.9.1/vagrant_1.9.1_x86_64.deb
    dpkg -i vagrant_1.9.1_x86_64.deb
  2. Install Virtual Box (I'm using Debian Jessie - change 'jessie' to your version)

    echo "deb http://download.virtualbox.org/virtualbox/debian jessie contrib" >> /etc/apt/sources.list
    apt-get update
    apt-get install virtualbox-5.1
  3. Run Vagrant machine ( hashicorp/precise64 is one of Debian images)

    vagrant init hashicorp/precise64
    vagrant up
    vagrant ssh

Add entry to /etc/apt/sources.list

Sometimes you are asked to add a new sources entry on your debian/ubuntu machine.

For example on Virtual Box Installation page you are asked to  
Add the following line to your /etc/apt/sources.list:

deb http://download.virtualbox.org/virtualbox/debian jessie contrib
 
You can do it manually with text editor or append to file directly win one command:

echo "deb http://download.virtualbox.org/virtualbox/debian jessie contrib" >> /etc/apt/sources.list

How to check Windows Server license expiration date? slmgr.vbs -dli

slmgr.vbs -dli

 

Type command:

    slmgr.vbs -dli

Regular windows trial is valid for 10 days. 
Evaluation license is valid for  180 days.
However to activate this 180 days you need to provide explicit command:

  slmgr.vbs -rearm