Friday, April 25, 2014

Running Ubuntu on 24GB SSD (Dual boot windows 8.1) - Managing Vagrant and VM files

I use an ASUS S56C ultrabook, it has a hybrid drive ( 24G SSD + 750G HDD ) with Windows 8 as the primary OS.

I primarily use Ubuntu, and wanted to keep windows too ( i paid 3K extra for that! ) so dual booting was my only option. Installing Ubuntu on the HDD was not an option because it was already divided into 5 partitions ( Recovery , OS , 350G, EFI , 128MB) etc and i wanted to avoid the mess dealing with Windows. And Ubuntu didn't support SSD cache out of the box.

Setting up Ubuntu 14.04 on SSD


So I decided to install Ubuntu on the SSD. On further inspecting the SSD , the SSD is divided into 2 partitions .One for the OEM ( windows copy 4G ) and another 18G free partition( used as cache by Windows ).

I installed Ubuntu on the 18G partition. Ubuntu + installation of essential packages ( VLC , git mercurial , gparted , gstream , etc ) takes around 8G , leaving me with only 10G free space.

10G is not enough for me to setup vagrant and save the VM's. Each vagrant image I had was around 10G. So I decided to move the VM's to another ntfs drive. But i didn't have write permission on NTFS drive. This was because Windows 8 has an "Fast Boot" option which prevents me to write to NTFS drives from another OS. you can disable that option by going to power options in Win8. But then later found out that NTFS drives don't support unix style permissions. :|

After all the frustration dealing with Win8 i decided to shrink the D drive ( 350G) to give me a nice 50G partition. I formatted it to EXT4 and mounted it to /media/new_drive/.

Changing the default path for vagrant and virtualbox

By default vagrant saves all the data in ~/.vagrant.d/ directory. To change the all we have to do is set the environment variable VAGRANT_HOME to a new location. You can do that by 

1) create a new file in /etc/profile.d/ called vagrant.sh . This file will be loaded during boot to setup the environment variable.

sudo nano /etc/profile.d/vagrant.sh

in the file type:

export VAGRANT_HOME = /media/new_drive/vagrant/

where /media/new_drive is where the EXT4 partition is mounted.

2) VirtualBox also saves the copy of the image in the users home directory. By default virtual box saves the copy of the image to ~/.virtualbox/ directory. To change the default location:

open virtualbox -> file -> preference 

Here change the default image save path to /media/new_drive/virtualbox .


Now you can run vagrant as usual and all the configuration and image files will be saved on the new drive.

Note: 
1) SSD cache is manged by Diskeeper express cache in windows on my machine. In some hybrid computers, its managed by Intel SRT or RST (depends ) . Disabling that is advised before installing another OS (do a research before you proceed)
2) Windows 8.1 works perfectly with fast boot disabled and without SSD cache. Its slow now.
3) Ubuntu is super fast now.
4) There are several posts online on how to use SSD as a cache on Ubuntu.
5) Asus S56C - Windows 8.1 + ubuntu 14.04 + vagrant

No comments:

Post a Comment