Adding disk space to Ubuntu (guest OS)

Recently, in one of my VMWare system (with Windows XP host OS and Ubuntu guest OS), I ran into disk space shortage while installing a package (Thrift – A cross language service).  Though there were many articles on the Internet in helping extending the guest OS partitions, they were for older versions or not applicable any more or had many complex steps.  On spending some time and digging more on the issue, I found pretty straight forward steps in achieving what I wanted to do – doubling the disk space for Ubuntu.

Initial setup:
  Host OS: Windows OS
  Guest OS: Ubuntu Karmic  (had 8G pre-allocated)
  Disk: 148G Total and 60G Free out of which 8G to be allocated to Ubuntu

   Double Ubuntu disk space to 16G by adding a new partition

Step 1:

  Run “disk analyzer” and get current disk space usage data that provides total, used, available and usred.  See below.  The system has less than 10% free disk space and needs more.

Step 2:

On deciding to go with allocating new disk space, you must first back up the disk and turn-off the virtual machine.  Select the virtual machine, if you have more than one in VMPlayer, and click “Edit virtual machine settings” and click Hard Disk item and set the expand disk capacity to 16G. (8 + 8) as show below.  Also make sure that you have enough free space available (in host) to allocated to guest OS.

Step 3:

Download “gparted” – a GUI disk utility by running
> sudo apt-get install gparted
> sudo gparted

Select the “unallocated” partition and select “Create partition”. In the pending operations pane you will see “Create Primary Patition …” and click “Apply All Operations” (A green check mark in tool bar).

Step 4:

Now mount this new partition. Say for example, I am going use this for /src2  directory, then
> sudo  mkdir   /src2
> sudo  mount  -t  ext4   /dev/sda3   /src2

Move some big directories to this partition or new directory and thus releasing some disk space free on /dev/sda1 in my screen shots above.  And after the move I had 60% free on /dev/sda1 partition (an important boot partition)
> mv   /big_directory   /src2/big_directory

Also for more on partitioning see  and if you like to create a bootable USB Linux distro check out this post.


Sharing files between Linux and Windows

If you are running a guest and host operating systems, many a times you would like to share some drives or directories between them.  It may be to share some documents or data or text files, etc.  And to share a directory (example, C:/Share/Edu) between Windows XP host and Ubuntu guest OS you can do the following.

1. First allow for sharing on Windows by right click on the directory of interest (say, C:/Share/Edu) and select “Sharing And Security…” and it will bring up “Edu Properties” window.  Select Sharing tab and set “Allow this number of users” to 2 or the number you like.  Since the sharing is between guest and host OSes, setting it to 2 will suffice.

  In Windows Explorer > Go to C:/Share/Edu > Right click and select “Sharing And Security” > (In new window) > Select “Sharing” tab > Set “Allow this number of users” radio button value to “2”

2. Assuming you have already installed Ubuntu (version 9 or above), go to System > Administration > Synaptic Package Manager as shown below which will bring up new window and look for smbfs (Samba File System) and choose it for download.  Ubuntu will automatically select other packages that are needed for this package.
Note: You need to have sudo authority (or root privileges) to download and install a package.

3. Once done bring up a terminal on Ubuntu and run

hadoop@ubuntu> sudo -s  (if you are not root already)
root@ubuntu> mkdir /mnt/win_edu
root@ubuntu> mount -t smbfs -o username=YOUR_WINDOWS_USER_NAME //WINDOWS_HOSTNAME/Edu /mnt/win_edu
# This will mount windows shared "Edu" directory on to /mnt/win_edu mount point.
#  NOTE: Instead of "smbfs" option above you can also use "cifs - Common Internet File System" supported by Samba, Windows 2000, XP, etc.

4. Change directory to /mnt/win_edu from Ubuntu terminal and you should see all windows files in Edu directory.  You can also check all mounted directories by running

root@ubuntu> mount

5. After you are done to unmount the file system simply run

root@ubuntu> umount -v -d /mnt/win_edu

Or if you just want to copy files between two systems use WinSCP freeware.  Get the guest IP address by running ifconfig and look for “inet addr”, then connect to it from WinSCP.

hadoop@ubuntu> ifconfig
eth1 Link encap:Ethernet HWaddr 00:0c:29:f7:a0:41
inet addr: Bcast: Mask: