Nov 13, 2007

Setting up my favorite work environment: Part one - VMWare player and Ubuntu

Finally, I have finished setting up my working environment in the new company. Most of my time spent on configuring a "Gutsy Gibbon" running in a vmware player. The image comes from thoughtpolice (http://www.thoughtpolice.co.uk/vmware/). I did some customization including adding a new virtual disk and install a couple of new packages including sun-jdk-1.6 and Samba. I'd like to share some of my experiences and lessons learned here.

So let me start from the begining, get myself interpolate into the thoughtpolice ubuntu release. There is no "root" in this Linux distribution. If you need root privilege to do something, you need to invoke the command by "sudo your-command your-argument-list"; If you really want to see "#" prompt char, especially when you are trying to configuring your system like me, you can do this "sudo bash". Note, by default this thoughtpolice release provides a account "notroot" with password "thoughtpolice" which can be used to sudo into root privilege. While I create a new account "greenl" I find it is not allowed to sudo into root privilege. /etc/sudoers does not give me any clue. What you can do is to
edit /etc/groups file, and add your new username to each line "notroot" is added in. After I have done this, my own account "greenl" can be successfully substitude with root user privileges.


Now that I am a supervisor, my ambition grows up. The default thoughpolice release provides 4 virtual disk files which can give you up to 8GB in your virtual linux world. That's not fair! Today's typical HD has 160GB space! And I know I am gonna install Websphere and DB2 in my ubuntu, so 8GB is not satisfied. I need much more! What I have done is to go to google and ramble for while. Not long I found a hand-on empty virtual disk package created by John Bokma using freeware Qemu. And I pick up the largest one (20GB) to append my thoughtpolice ubuntu virtual disk space. It is not so easy as copying and pasting a file. Beyond that, you need a few additional steps to transfer reality file into virtual disk space:
  • Open the ubuntu-server-7.10-i386.vmx file using whatever your favorite editor (don't get scared by the .vmx extension, it is 100% a plain text file). You will find something like
    • scsi0:0.present = "TRUE"
    • scsi0:0.fileName = "ubuntu-server-7.10-i386.vmdk"
    • scsi0:0.writeThrough = "TRUE"
    • ide1:0.present = "TRUE"
    • ide1:0.fileName = "auto detect"
    • ide1:0.deviceType = "cdrom-raw"
  • And you should see that we can interpolate something here for our new 20GB virtual disk file, in my final version of ubuntu-server-7.10-i386.vmx file, the new lines I added are
    • ide0:0.present = "TRUE"
    • ide0:0.fileName = "ubuntu-server-7.10-i386-ide.vmdk"
  • You should know that "ubuntu-server-7.10-i386-ide.vmdk" is just the new virtual disk file we have added. But is that enough? After you restart your virtual machine, and log into your linux virtual box, you will see nothing has changed. Then think it twice, what if this is a real linux box and you added a new harddisk into your machine, what will your linux react to it? It will find a new device, but that's all. So you need to do something to let Linux be able to use your new device, right? Yep! You need to run sudo fdisk to create new partition on the raw disk, and mkfs.ext3 to "format" your new partition, and finally edit your /etc/fstab file to mount the new partition to your file system upon system boot.
These are exactly what I have done to expand my vmware ubuntu disk space. A little bit more words I want to say about this is my mounting point of new partition: /usr. The reason I choose /usr is by default system will install new packages to that directory. Be careful before you go direct to "sudo vi /etc/fstab" you should at least backup your current /usr directory by "sudo mv /usr /opt", and then update your PATH environment variable. In your first boot immediately after you have changed /etc/fstab file, you will find the system does not behave normal, surely because of your /usr is now an empty directory. So what you should do is "sudo cp -R /opt/* /usr" and "sudo rm -R /opt". Restart your system and rock!

Next time I will share my findings with setting up convenient communication facilities between host and virtual system, including setting up ssh and samba.

No comments: