Monday, July 15, 2013

Dual booting on EFI systems

Some time ago, I chose to reinstall Windows on my home computer. I was using Server 2012 thanks to Dreamspark. I was most excited for trying ReFS, but it didn't feel any faster than ntfs. Of course, its main feature isn't speed, but integrity, specially if you mount it over a mirrored raid array. But what I didn't like the most about WinServer was that it took so long to boot up.

So ok, I spent some money and bought a copy of Windows 8. It sure was faster to boot up, and having superfetch back was a nice addition as well, even more if you have lots of ram. My motherboard right now is a Gigabyte Z77 UD3H. It allows booting using UEFI or the "legacy" bios style (quoted because it still is quite used). I chose to install Windows in EFI mode. It really doesn't feel much different than MBR mode, but I know that it made an EFI partition and the boot loader was there. Everything is cool so far.

Recently my coworkers convinced me to install a Linux flavor in my work laptop. It comes preloaded with Windows 7, but most of them replaced it with Linux. They wonder how could I bare Windows? Well, it does the job (actually the computer I use the most comes with Linux, with Android on top of it, and fits in a pocket). Since I work as a JVM programmer (ex-Java, nowadays Scala), it is really the same to me what OS I have running. But I decided to install Linux in order to relearn its console commands. I say relearn because I had to use Linux before, in a previous job. I chose Linux Mint to vary a bit from Ubuntu.

Anyway, I was able to shrink my Windows partition using the Disk Management console. This laptop was using MBR and its disk had already three primary partitions (four is the limit of primary partitions for a MBR disk). The system partition with Windows installed on it, a reserved partition, and a recovery partition. Now I added the four and last one, and partition to format with ext4 and install Mint on it. But I also needed a swap partition! So I ended up ditching the recovery partition and put the swap there.

Linux booted really fast compared to Windows, and somehow I felt it does a better use of this laptop resources. So I wanted to install some Linux flavor at home as well. This time I chose Ubuntu, version 13.04, for this task because it's well supported and there are pages talking about how to install it using UEFI. They are mostly related to new computers having Secure Boot enabled, but that was not my case.

First, I again shrunk the Windows partition on the SSD to make room for Ubuntu. I moved some stuff (like games) to a partition in a regular mechanical disk and made sure that disk also have free space. My idea was to install the root directory to the SSD, and swap and home to the HDD. Having 16gb of ram I was quite sure paging would barely occur, so I didn't want to waste SSD space installing it there.

Afterwards, I burnt Ubuntu's Live CD, boot it and installed Ubuntu. It automatically detected my EFI partition, and when asked where to install the boot loader, I chose my root partition /dev/sda5 instead of the entire device /dev/sda. Then the installation proceeded.

But what happened? I was asked to reboot, and then it booted straight to Windows! I was hoping for GRUB to appear. At least I was able to boot and open the browser to find out what the deal was.

After reading some blogs, I rebooted to the Live CD and went to /boot/efi. There it mounts the EFI partition I had on my SSD. There I had:

  • /boot/efi/EFI/Boot/bootx64.efi Microsoft's boot loader
  • /boot/efi/EFI/ubuntu/grubx64.efi Ubuntu's boot loader
  • /boot/efi/EFI/Microsoft/... all Windows stuff

I backed up bootx64 and copied grubx64 to bootx64 in Boot folder. When I rebooted it went straight to Ubuntu!

Now I made sure that Ubuntu was installed well (HDD's home mounted and such), updated to the latest version of its software, installed Chrome and the rest. It was handy that I had direct access to the EFI partition right there. Later I learnt that I could access the EFI partition within Windows with mountvol /s.

I knew that in the motherboard's firmware there was an entry for the Windows Boot Manager, which Windows added when it was installed. Now it was accessing GRUB, but there was no option to boot to Windows from GRUB. I read that I could add that using chainloading, but I didn't understand quite well how that was done. I wanted to see if it was possible to add a GRUB entry on the system's firmware and choose there if booting to Windows or to Ubuntu, so I rebooted and entered BIOS.

Now I learnt a few things:

1) This motherboard can boot the system in UEFI or BIOS mode. The UEFI options are (not literal):

  • Windows Boot Manager
  • UEFI: first disk (the ssd)
  • UEFI: dvd

and then the BIOS options were the ssd, the hdd and the dvd unit.

It turned out that the first option was UEFI: ssd and this one went to load bootx64 (grub now). If I chose Windows Boot Manager it booted Windows.

2) The BIOS support is called CSM for Compatibility Support Module. I tried disabling it, and then when I rebooted, the screen was all black and it went straight to Ubuntu. It was faster, maybe because it didn't have to load all the legacy BIOS stuff. But then again, I was unable not only to enter BIOS but also to choose the operating system. I ended up clearing the CMOS.

3) This motherboard has no EFI shell. I downloaded a shell and installed it as bootx64. Now when I booted I went straight to a shell. Fun...

Suddenly I stumbled upon what I was looking for: rEFInd. A GUI where I could choose what EFI system to load. I installed it following their instructions and it automatically detected my Windows and Ubuntu systems, with pretty icons and such. Sadly it seems its graphics support relies on the already established system, so when I tried disabling CSM again, nothing appeared, just a blank screen. I cleared the CMOS again and the system was back to normal.

Now rEFInd serves as my EFI Boot Manager, where I choose if I want to boot to Windows or to Ubuntu. I know I could have used GRUB for something similar, or maybe even the motherboard's boot selection to choose both operating systems, but I like how this manager looks, and I feel I learnt much about the EFI boot process. I've read many sites in my quest to gather enough knowledge as to avoid messing things up, and now I'm writing this post before this knowledge is gone.

Saturday, June 1, 2013

An Introduction to Interactive Programming in Python

I'm attending this online course at Coursera. Even though I knew a bit about Python, I wanted to polish my skills. It is a bit weird because I haven't had to use Python for any work nor for college, so I'm not that familiar with the language. People say it's really easy to use and can be used as a teaching language. I know that it is widely used in the scientific community, and that Google promotes it as well.

So, back to this course, I have to say the introductory part of the title is quite correct. Being a seasoned developer, I find it easy as they don't only teach you Python, but programming language techniques too, like loop or object oriented classes. They built and use CodeSkulptor, an online IDE where you can write Python code and it executes it. It uses a subset of Python 2, and a custom library for GUI programming.

Still, the teachers are quite funny and each mini project is a game, which is cool. (Mental note, take more AI classes).

Sad thing, at this same time I'm also learning another language which I'm feeling way more passionate about: Scala.

Monday, December 3, 2012

Launching a GWT Demo with IntelliJ IDEA

It's been a while since I worked with GWT. I did it for a pet project, when I was into all the databases stuff. It was about database normalization. You know, to avoid redundancies, which of course you denormalize when you copy your entities to Lucene or a NoSQL database. But this post isn't about that.

I wanted to start a simple GWT project. Copying the one in the tutorial. So I launched my new IDEA Ultimate environment (those $100 have to pay off), which has built-in GWT support. This has to take only a few minutes I thought. Right...

First, I wanted to run the project in production mode, deploying it to a Tomcat 6. It said the deploy was successful, yet nothing was there. I checked Catalina Home, Catalina Base, all those variables. After hours I decided to remove the Tomcat folder and create a new one, so I downloaded it again from the Apache site, unzipped it, and set it up in IDEA. Then I checked with great detail all files in conf, that everything was there, and suddenly, it worked. What happened? Only deity knows...

So, now let's make it run in dev mode. I read about a new mode in GWT 2.5: "Super Dev Mode" and IDEA suports it. Let's try it.

Well, supposedly it runs a compiler server and you add bookmarks links so when you work on your GWT page, you can rebuild your javascript code "on the fly". But where was my GWT page? It certainly didn't work with my app that was running on Tomcat (in production mode). I guess Super Dev Mode needs more polishing.

Let's try the old and tested "Classic" Dev Mode. It started successfully. Now I need to install the GWT plugin for Chrome. Easy you say? Nahh.. It seems that this plugin is not supported (at least yet) if you run Chrome on Windows 8 (or Server 2012, in my case). Why? Well, people are complaining in the forums. After being defeated once more, I downloaded and installed Firefox. Aha! It seems that there is no official GWT extension for Firefox. Luckily there was an unofficial one and it seemed to work.

So this was the status of a little GWT demo which was supposed to be running in minutes but took me hours. Now at least I can start adding more widgets and panels. I hope I can run the GWT plugin for Chrome again without resorting to virtual machines.

As usual, thanks to StackOverflow for helping me finding some answers, or at least people that had the same questions.

Thursday, September 6, 2012

Oracle Database XE listening port

I installed an instance of Oracle Database XE (version 11g) at my home machine. The idea was to connect an (also Oracle) Glassfish server to it. So, I start the server, and bam! Port 8080 is busy. By whom? I wonder, if the last time I was using this computer, I started a Tomcat server successfully.

Well, what do you know, there was a service installed by the Oracle Database that decided to occupy that port. Its name was something like Oracle listener. So I shut it down. Now Glassfish works fine.

I configure the datasource using Glassfish Admin Tool. I set everything, but it complains that it cannot connect to the database. I wonder again, because I had a Oracle SQL Developer open and connected to the database, and everything was working fine there.

After revising the parameters for the millonth time (having OracleDataSource Javadoc at hand on a separate browser tab), I decide to close the SQL Developer connection and reopen it. Aha! It cannot establish a connection. Then the light bulb turns on, and I decide to restart that service, but with Glassfish running so it cannot claim the 8080 port. It starts fine. At first I still cannot connect, this time complaining that the SID is wrong, but after a minute, the database accepts the SID, I can connect the SQL Developer again to the database, I can also connect my JDBC Datasource (in Glassfish) to the Database... and we all rejoice.

Monday, August 15, 2011

Migrating from JBoss 4.3 to Jboss 5.1

In several of my previous jobs, which involved an enterprise application that ran on an application server, it usually was the one made by JBoss. The downside is that I know next to nothing about Websphere, Glassfish, and other competing servers, but the upside is that I'm pretty familiar with JBoss.

JBoss version 4, that is. And now, in 2011, I found out that the new project I'm working on, also uses JBoss 4. Yes, I know, it's Jboss 4.3 EAP, enterprise supported by Red Hat, which not long ago I found out is not the same as version 4.2, as the messaging system is different. But still, it just feels so old! JBoss AS is version 7 already, which I have to say, boots REALLY fast, and I've got the feeling that I'll be using JBoss 7 at work maybe in the year 2015.

Now, you'll say: but neither JBoss 6 nor 7 are not full JEE certified! They even haven't got EAP versions! (I think Jboss 7.1 will be EAP). So this time I focused on trying to run the current system on JBoss 5.1

This is not the first time I do this. That was last year, on another project, but couldn't succeed and ran out of time. Luckily this time I did have success. What happened last time was that the queues were in JBossMQ, and I didn't know how to migrate them to JBoss Messaging. This time, as the system runs in JBoss 4.3, it's already configured for JBoss Messaging, so that part was easy.

Also, the WARs used the Spring Framework, so there are no EJBs or EARs to convert. That also made the migrating process easier, although it made less sense to migrate, as it was only for the microkernel of JBoss 5, the JMS and the new version of JTA. No new EJB container nor Hibernate that mattered this time.

But still there were a few quirks:

  1. Classpath: One of the projects included a JAR library with JAXB implementation, and since that's included in Java 6, there was an exception because you had the same classes in different classloaders on the same hierarchy and JBoss 5.1 was picky about that.
  2. Libraries in SAR package: They needed to be in root of the SAR instead of in the lib folder. There is a workaround (or maybe it's the official way) by using jboss-structure.xml to specify where the libraries are, but haven't used that.
In conclusion: easier to migrate if you don't use the EJB stack, as I didn't have to deal with ejb-jar.xml, persistence.xml and the kind, but still not as easy or straightforward that I'd like to. I guess it won't be easier to move to JBoss 6 or 7, or even another application server. So much for standards...

Monday, August 8, 2011

Googlon

Today I solved the Googlon Quiz in order to enter the Google Developer Day here in Buenos Aires. Since I didn't have much time I used plain old Java. I think this particular exercise would have been much easier in Scala, had I known the language.


Speaking of Google, I received some interesting news that sadly I can't tell :)

Sunday, August 7, 2011

Different languages for the JVM

A few weeks ago I started learning Groovy and Grails. Even though I'm quite proficient with Java and the Spring Framework for building web pages, I wanted to know if Grails would lead me to an even faster way.

I downloaded a few examples and I have to say that I like the convention over configuration scheme of Grails, but was not so comfortable with Groovy's approach. I also tried Griffon as the supposed project had a client-server architecture and because of the requirements I wasn't sure if a web-based client was enough so I wanted to try a desktop alternative.

Griffon follows Grails conventions but seems less mature. Also, I found IntelliJ to be the best IDE (tried also STS and Netbeans) for Groovy apps.

In the meantime, the main subject for the Java User Group meeting that was coming was Scala. I'm lucky to have the, according to reviews, great book Programming in Scala, and will be starting reading it soon. I heard that having Scala it makes little sense to learn Groovy, so maybe a better use of my time will be to learn Scala and the Play Framework.

As a matter of fact, I was supposed to play with Scala today, but my procrastination lend me to install JRuby and Jython, and ended playing with the last one, after I learned that the popular Django framework was made in Python.

So I made a test web site following a Django-Jython tutorial, but it seems that there is little connection with the rest of the Java world. My goal was to convert the site to a web archive (.war), deploy it in JBoss, and connect Django with the JMS and the transaction manager. I don't know, maybe it's supposed to be used standalone.

I think I'll go back to Scala now.