Currently browsing category

Linux

VirtualBox – How to increase hard disk size of Linux guest

VirtualBoxEver since my desktop broke down six months ago, I was without a Linux machine. Lately the urge to get back to Linux kicked in and immediately setting up a VM came to my mind. I had already used VirtualBox earlier so I got started and installed Linux Mint. During the installation I had setup the HDD size to be 8GB and dynamic which could grow if required. Within a week as Dropbox and Thunderbird sync started the free space came to zero very quickly. So I set on to find a way to increase the HDD size where Windows XP is setup as the host and Linux Mint is setup as the guest OS.

The process to re-size an existing VirtualBox hard disk for a Linux Guest OS is as follows:

  1. Run the command vboxmanage as shown below, where “F:\VirtualBox\’ is the directory where the vdi file exists and ‘Mint 12.vdi’ is the name of the vdi file. The re-size option takes the final size (in MB) of the disk after resizing (below I have set it to 15GB).
    vboxmanage modifyhd "F:\VirtualBox\Mint 12.vdi" –-resize 15360

  2. Download GParted Live CD ISO from http://sourceforge.net/projects/gparted/
  3. Setup the ISO to load as a CD Drive in VirtualBox. (Goto Settings -> Storage -> Click on one the CD Drive -> Under Attributes click on the CD icon and select ‘Choose a Virtual CD/DVD Disk file’)

  4. Start the VM machine and let it boot into GParted screen.

  5. Once GParted is loaded, you should be able to see the unpartitioned size available along with the primary partition and the swap partition.

  6. It is not possible to move the swap partition to the end of the partition table directly and use the free space for the primary partition, hence follow the below steps one by one.

  7. Select the Extended partition which contains the swap partition and right click and choose ‘Resize/Move’.

  8. In the Popup window, note down the size of the partition.
    I had the primary partition as 6.75GB, Extended Partition which held the swap at 1.25 GB and the unallocated space stood at 7GB.

  9. Now drag the right edge of the partition to the very end, this would mean that the free space following would become zero. Click on ‘Resize/Move’ button and then click on Apply button.
    Step Result: The extended partition size increased from 1.25 to 8.25GB, with 7GB unallocated space moving inside the extended partition.

  10. Now select the swap partition and choose ‘Resize/Move’ option. Note the size of the partition. Drag the right edge of the partition to the end and then drag the left edge of the swap partition to bring it to the actual swap file size. Click on ‘Resize/Move’ and then Apply.
    Step Result: The swap partition moved to the end of the partition table and unallocated space of 7GB moved to the left of the swap partition.

  11. At this point, we are still unable to expand the primary partition to use up the free unallocated space, hence click on the extended partition again, choose ‘Resize / Move’, this time drag the left hand edge of the partition to be same size as the initally noted value, for me it was 1.25 GB. Click on Resize/Move button and then Apply.
    Step Result: The extended partition is now back to 1.25 GB and is again at the end of the partition table, with the unallocated space moving to the left of the extended partition.

  12. Click on the primary partition and now drag the right edge of the partition to use up the free space. Click on the Resize/Move button and then click on Apply.
    Step Result: The primary partition increased to 13.75GB and there is no unallocated space left.

Though I would have loved to include screenshots, I had already followed the process before writing this. In case you run into issue or have an easier way of doing this do let me know using the comments section below.

Firestarter configuration to allow VPN

FirestarterYesterday I had installed Firestarter (A Linux Firewall) in my Linux Mint desktop to act as the first line of defense against network based attacks.

Things were fine till today evening which was when I faced an issue with VPN. Although Firestarter allowed me to connect to the VPN, it was blocking me from doing a remote desktop to my work machine or another other machine in the network for that matter. In short Firestarter was blocking the VPN tunnel.

So the quickest way to fix this is:

  • Note down your VPN gateway IP address.
  • Open terminal and issue the command, enter the root password when prompted:
    sudo gedit /etc/firestarter/user-pre
  • Copy and paste the below code:
    # Forward Cisco VPN client traffic
    iptables -A INPUT -j ACCEPT -s xx.xx.xx.xx -p esp
    iptables -A INPUT -j ACCEPT -s xx.xx.xx.xx -p udp -m multiport –sports isakmp,10000
    iptables -A INPUT -j ACCEPT -i tun0
    iptables -A OUTPUT -j ACCEPT -d xx.xx.xx.xx -p esp
    iptables -A OUTPUT -j ACCEPT -d xx.xx.xx.xx -p udp -m multiport –dports isakmp,10000
    iptables -A OUTPUT -j ACCEPT -o tun0

  • Replace xx.xx.xx.xx with the VPN Gateway IP address you noted.
  • Save and close gedit.
  • Restart Firestarter by issuing:
    sudo /etc/init.d/firestarter restart

You should now be able to not only to the VPN but also remote desktop to your machine.