Posts Tagged ‘virtualization’

JeOS on VirtualBox

June 3, 2010 Leave a comment

I always needed test environment for my destructive experiments.  Sandbox, if you want. A place I can do whatever I want without worrying about the consequences. I’m tired of destroying my operating system. I’m talking about these times when I modify and rebuild kernel modules/kernels/libraries for experimental purposes, such as making KVM support Mac OS X, making netfilter/iptables module support advanced connection tracking, etc. This time, I needed to patch rtl8178 kernel module (wireless driver) to allow packet injection. I decided to solve the problem once and for all.

The problem, if you didn’t follow, is that these kind of changes might have destructive influence on the running operating system. There are basically two different approaches to address this problem:
1. Take snapshot, or “point in time” of the operating system and after experiment is finished return to that point.
2. Experiment in a “sandbox” where no one cares what gets ruined and it can’t harm the operating system.

I prefer the second approach because when you roll back to certain point in time everything rolls back and I’m always doing more than one thing so I don’t want my other stuff to roll back as well. Besides, that kind of solution is always “heavy” as the whole system needs to be compared to the way it was before. Sure, you can make use of timestamps and more sophisticated comparisons to make it quicker but unless you use real snapshots (such as in LVM or ZFS), it’s not ideal.

So we go with the sandbox approach. Once again we have a few options. We can create chroot jail but it might have problems accessing physical devices (I never tried actually) and I don’t really like the way the chrooted environment is created. We can use “live” operating system that runs directly from real memory (no changes are made to disk) but then only one operating system can run simultaneously which means that during the potentially destructive session my normal operating system won’t be available, which is exactly when I might need it.

Virtual machine seems like an adequate solution. It fulfills the sandbox demand, it’s easy to setup and some virtualization platforms even got snapshot abilities. The only problem is it doesn’t always have access to physical devices. However, in this case the device is usb based and therefor accessible from within the virtual machine as well. For virtualization platform I chose VirtualBox (3.1.8). Vmware doesn’t support my processor’s virtualization capabilities so it’s out of the game and VirtualBox performs better than KVM, on my computer at least. Especially when it comes to I/O performance. Now I need to choose adequate operating system for the virtual environment.

I want the operating system to be as minimal as possible, no need for fancy graphical environments, office suite, web browsers, etc… I started looking for candidates but man, there are so many distros out there! I would have simply used Ubuntu because I’m used to it, it has huge software repositories and it would be very similar to my actual operating system, the only problem is it comes with loads of unnecessary software. I considered installing Debian exactly for that reason and then I found out about Ubuntu’s JeOS (thanks Amir). JeOS stands for just enough operating system and it’s simply Ubuntu’s core. It seemed perfect for my needs. JeOS comes with Ubuntu server edition.

The installation is fairly simple and quite fast. On the first installation screen you need to press F4 and select “Install a minimal system” as shown. There is also a Vmware/KVM optimizied version (“Install a minimal virtual machine”) but it’s not VirtualBox optimized so I chose the minimal server option. The rest of the installation is following simple screens. When I had the option to choose software packages I chose the basic Ubuntu Server and OpenSSH.

Boot time is also impressive, leaving us with old-school tty login screen. Cool. Next thing is to install VirtualBox guest additions to make interaction smoother and better. Before it is installed few prerequisites has to be installed first:
# sudo apt-get install gcc xserver-xorg-core

It will install gcc and X.Org, the graphical environment server. It won’t install window manager (such as Gnome or KDE), graphical login (GDM or KDM), etc… just the core X server. To install VirtualBox Guest Additions, from the virtual machine menu: Devices -> Install Guest Additions. Then:
# sudo mkdir /media/cdrom
# sudo mount -o ro /dev/sr0 /media/cdrom
# sudo /media/cdrom/ (depends on your platform)

Make sure you get no errors and viola! our new test environment is ready. I took a snapshot (Machine -> Take Snapshot) so I can always return to this basic point. What if you do want lightweight window manager ? I used FluxBox but you can install whatever you like. To install fluxbox:
# sudo apt-get install fluxbox
# sudo apt-get install xinit x11-utils eterm xterm
# echo fluxbox > ~/.xinitrc

The packages eterm, x11-utils allows you to set FluxBox background with “fbsetbg” command. xterm is the standard terminal emulator (I guess one may argue with that but it’s my favorite anyway). None of them is necessary. To load the graphical environment:
# startx

That’s it. I also managed to recompile rtl8187 kernel module but it’s out of the scope of this post. Enjoy your new test environment!

Virtualizing Mac OS X on Linux

April 5, 2010 4 comments

In my last post I wrote about virtualization. Here I’m going to introduce the world of virtualizing Mac OS X (Apple’s operating system) on linux.

Why would anyone want to run Mac OS X on virtual machine? Many reasons. Some people buy Apple’s computer but prefer linux as an operating system. However they still use from time to time native OS X applications such as iTunes. It makes perfect sense to load virtual OS X instance only when needed. Another reason might be testing new releases of OS X, software updates, etc… but the main reason, I believe, is software developers who want to develop iphone/ipad applications but don’t own Apple computer.

Before I proceed, I have to say a few things about Apple’s behavior and some legal issues as well. Imagine, that in order to develop windows application you’d have to buy computer from Microsoft. You would also have to run windows operating system and use Microsoft’s development environment only. In order to test your application outside the development environment, you’d also must register as Microsoft developer (99$ fee). When you finish developing, you’d have to submit your application to Microsoft’s store, and wait for approval. Microsoft, on it’s end doesn’t obligate to approve or disapprove your application in a given period. If your application does get to the Microsoft store, they keep the right to get it off whenever they feel like changing policy, and then no one would be able to get your application anymore.

If it sounds right, stop reading now. You better off to billy’s blog. Read more…

Trinity: Acer, AMD and the holy BIOS modders

April 4, 2010 1 comment

This story is about three things I despite: bad support, not fully utilizing my computer’s hardware and injustice. At least it got happy ending 🙂

It all started two years ago when I purchased my current computer, Acer aspire L5100. It looked sexy, compact, had good spec and was on a special sale. The processor is AMD Athlon 64 X2, which supports 64bit operating systems and hardware virtualization.

So what are these features and why did they mean such a great deal for me? Well, virtualization alone means abstraction of computer resources, meaning the ability to run “secondary” operating systems “inside” the primary. In other words, you can have, for example Windows 98, MS-DOS and Windows 7 running altogether simultaneously in one physical computer. Each one unaware of the others. Unfortunately, this ability (emulating physical computer that works independently) consumes a lot of resources, meaning everything becomes slow and not responsive, sometimes completely unusable. Hardware virtualization implements this ability in hardware level, off-loading work from main processor, thus everything works faster, and it works even better with 64bit processor.

So, for operating systems lover person such as myself, these features are quite important because they allow easy deployment of operating systems in those virtual computers described above. Happily, I opened my new computer’s box, plugged everything, powered on, wiped the pre-installed vista with ubuntu linux and was ready to test my new capable processor.

When I tried loading a virtual machine (aka VM) I saw horrible message saying AMD-V is disabled by BIOS. AMD-V is AMD’s hardware virtualization technology. BIOS is the first piece of code running when computer is powered on. It basically detects attached peripherals (cdrom, hard drive, etc…) and starts the operating system boot process. It also controls different hardware related things such as date, heat sensors, fan speed etc…

Changing BIOS settings is very easy. All you need to do is reboot the computer, quickly press a known key (Usually DEL or F1) and you get the BIOS menu. Alas! on my BIOS there is no menu for enabling AMD-V!! I checked all the menus, and then I checked again. No such an option exists. Could the message I got be wrong ? I investigated a little more and I found another evidence, on the main system log file. The log entry was “kvm: disabled by bios”.

This could mean one of the things:

  1. My processor is not AMD-V capable
  2. My processor is AMD-V capable but BIOS blocks it and there is no menu to change it
  3. Linux kernel has compatibility issues with my BIOS/processor

Googling a lil’ bit showed that I’m not the only person with this problem, the problem is probably number 2 and no one found solution. At this point I verified that my BIOS version is the latest (makes sense since I just bought the computer) and sent nice email to Acer support asking for help (here comes the bad support part). After two days(!), I get respond that tells me to contact the local reseller whom I bought it from, and so I did, unwilling to believe they can possibly even understand my email since their business is all about importing electronics.

Surprisingly, they did understand and told me I need to upgrade my BIOS version (da!). I asked for newer version but didn’t had any. I didn’t give up, and send another email for Acer support describing everything. This time a little more aggressive, pointing out that they deceive the public and I think it’s illegal. I got respond at the same day:

Dear Customer, try other versions of bios. your bios Compliant with latest Intel Virtualization Technology spec but attention, the characteristics of the changes say it is compatible, but your computer does not have this technology.

Now, I’m not sure what exactly made me jump to the conclusion the support guy was a complete jerk, the fact his english makes no sense, the fact he is writing about Intel processors (wtf? you don’t even sell them), or that he just ignored my request for newer BIOS version. After ridiculous email exchange in which they told me try downgrade to all previous BIOS vesrions (yeah, like that is gonna solve anything), and pointing blaming fingers to my reseller and linux, and doing nothing about their faulty ftp server, I decided I had enough.

I was very angry and I wanted to press charges against them. After some time I let it go, hoping one day they will release new version. Meanwhile my virtualization needs were not satisfied and things worked painfully slow. About month ago I was upgrading my operating system, installing fresh copy of Ubuntu 9.10 (which is great, btw) and for some reason I reminded this saga. There were lots of hopes when I checked Acer’s website for new BIOS versions and then one big disappointment. They didn’t change a thing (except their ftp server now works but I couldn’t care less). I rechecked the old forums posts of people with similar problem and amazingly I ran into this post:

Today Is All You Peoples Lucky Day! Im the administrator of the bios modding forum and i have looked into this bios (R01-B0 version) and am happy to report that the Virtualization option , aswell as CPU And memory overclocking options were hidden by acer. I have unlocked these features and if you want to take the risk , here is my modded bios file…

Can you imagine the excitement?! It was posted six months ago, so I didn’t waste a lot of time in the darkness. Now, as much as I wanted just to download the modified BIOS file and install, I had to take some precautions. The BIOS is stored on a memory chip, and it’s integrity is critical. If for some reason the BIOS gets corrupted, it would render the system useless. Nothing would start until it gets fixed or replaced, and the worst part is that it’s impossible to fix it using the system it’s on because it won’t start…

It means that the upgrade procedure shouldn’t be interrupted, I have to understand what I do because I might have only one chance, the BIOS file must not be corrupted, and it suppose to come from reliable source. So I took the time and studied the materials. seems big and decent forum. The guy introduced himself as the administrator (“1234s282”) is indeed a respectable administrator with many posts. I copied the BIOS file (from, I don’t trust the link I got at the original post since I can’t verify it’s the same guy), along with flashing utility (the action of overwriting the BIOS with new image file is called “flashing”) and other utilities to make my disk-on-key boot a small DOS operating system.

I’ll avoid the technical details, but flashing involves booting DOS operating system from disk on key (or floppy diskette if you still got one), running the flash utility with the new BIOS file and cross your fingers. When I did it, everything went smooth, except the utility failed writing the last block. I started thinking it’s the last time I see my computer working, because the BIOS might be corrupted (it was only partially written to memory chip). I couldn’t think of anything I can do to save myself at that point, so I crossed my fingers and reboot.

I still don’t fully understand why it worked, at that point I was just glad it did. I guess it’s because I used a modified version of the existing one, and basically it’s the same image with only minor changes. I checked my new BIOS and found the menu to enable AMD-V (was already enabled). I also found a menu that enables/disables BIOS write protection, so I disabled and did the flashing procedure again, just to make sure. It worked flawlessly.

Finally, with AMD-V enabled, I boot my operating system, once again just to find out the same damn log entry: “kvm: disabled by bios”. That’s strange because people reported this BIOS to work on the same computer model as mine. I checked, and it turns out that you can get Acer aspire L5100 in different variations. It also turns that AMD-V can only be used on socket AM2 and not socket 939 (those are just different types of connectors between the processor and the motherboard). Fortunately, mine is AM2. So what else could be wrong ?

I had no clue. I wondered what would happen if I really disable it in BIOS. Who knows, maybe the person who modified the BIOS got the enable/disable strings the wrong way. Believe it or not, it fu*kin worked!! YES! Thank you 1234s282, the work you do is holy!

Finally justice has been done and I got my peace. And the message of this story ? Never give up. Don’t be afraid to try new things. Sometimes it’s the most desperate acts that would get you what you want.

EDIT: You can also upgrade your bios with flashrom command, but you need the bios file in different format from the one supplied by Acer. I can provide my ‘flashrom –read’ output if anyone wants. It has been reported as working.

And why trinity ? Because my computer is now a whole, a god-like fully utilized powerful machine! (I ain’t no christian so I apologize if it’s inappropriate metaphor but it sure makes one hell of a title… (got it, hell of a title? (I’m so funny (not))))