Skip navigation

Category Archives: Technical Problems

I’ve been planning to get a new laptop for quite some time now, maybe at around December. However, certain miscalculations and one heartbreaking failure from the charger of my previous one means that I’m now typing this on a new machine, bought pretty way earlier than expected. And, like all good (or semi-good, depending on your loyalties) geeks do, I set-up the machine to dual-boot Windows 8 (pre-packaged with the hardware) and Linux the first time I had the opportunity (i.e., this long weekend).

It was hell.

Almost like this. Thankfully, only took me 1.5 days.

It seems that my hardships are all courtesy of UEFI/Secure Boot. Maybe there exists an easy way to achieve what I wanted but, judging by the volume of unresolved posts related to my problem scattered on the internet, it is not an obvious way. To anyone who might come across the same problems as me, here’s the complete narrative of how I managed to dual boot my machine.

0 Prologue

I dual-booted on an Acer Aspire-471G laptop. The OSes I want side-by-side is Windows 8 and Ubuntu 12.04 (Precise Pangolin). Since we’re dealing with the BIOS, I think it’s just proper that we get my machine on the record. If you run these steps on another machine, there might be some differences along the way.

Also, it seems that UEFI (and related dual-boot problems) has been around since Windows 7. However, I have never tried dual-booting a Windows 7 machine with Ubuntu—my experiences were all with XP and Vista, and it was all easy. And yes, I also encountered some 7-specific questions along the way.

1 Make sure that your LiveCD is 64-bit

There is no such thing as 32-bit UEFI. You will not be able to boot your machine in UEFI mode from your LiveCD if your LiveCD is  32-bit. While UEFI has support for legacy BIOS (and, from legacy BIOS, allow you to boot from a 32-bit LiveCD) this will result to a rather awkward and possibly-dangerous dual-boot set-up: you’d need to switch your BIOS mode from UEFI to legacy and back, depending on the OS you want to load.

(Blooper disclosure: I almost bricked my BIOS trying to boot from a 32-bit installer in UEFI mode: I ended up installing rEFInd through Windows and renaming stuff from my EFI System Partition, and got all sorts of weird and horrifying errors. The thing is, I just got the installer from one of our sysads at work and have used it previously to dual-boot an old 64-bit machine running XP. I’m glad I realized my mistake early.)

How do you determine then the bitness of your LiveCD installer?

At the root of your LiveCD, there is a file named README.diskdefines. Open that file (right-click->Open with->Notepad, or any other plain text editor). If you are looking at a 32-bit installer, that file will read like this (notice the ARCH variables):

#define DISKNAME  Ubuntu 12.04 LTS "Precise Pangolin" - Release i386
#define TYPE  binary
#define TYPEbinary  1
#define ARCH  i386
#define ARCHi386  1
#define DISKNUM  1
#define DISKNUM1  1
#define TOTALNUM  0
#define TOTALNUM0  1

On the other hand, if on a 64-bit installer, you’ll get:

#define DISKNAME  Ubuntu 12.04.1 LTS "Precise Pangolin" - Release amd64
#define TYPE  binary
#define TYPEbinary  1
#define ARCH  amd64
#define ARCHamd64  1
#define DISKNUM  1
#define DISKNUM1  1
#define TOTALNUM  0
#define TOTALNUM0  1

Also, the 64-bit version will have a directory named “efi” at the root. If you are seeing a 64-bit README.diskdefines and no “efi” directory, there is something wrong with your installer.

2 Get comfortable tweaking your BIOS

Warning: This can be dangerous! Proceed with a well-rested mind.

As you may have guessed earlier, there will be a lot of BIOS dealings involved here. To get to the BIOS set-up, press F2 while your machine boots.1

You need to be comfortable with two things: changing your boot order and adding .efis to the white list (“trusted”) of your machine. The first one is pretty basic but the second one has bit more technical details involved.

(For the first one, aside from being pretty basic, it is oftentimes unnecessary. You just need to make sure that your computer considers the HDD/Windows bootloader later than your optical drive and USB drive for bootable media. This is often the case. ACER ASPIRE-471G USERS, I must note that I was a bit surprised to find out that on this machine, this is not the case.)

White listing .efis involves setting a password and navigating your EFI System Partition (ESP) as well as other possibly-bootable media (like your LiveCD). Just remember two things here:

  • If you mess-up your system and suddenly can’t boot Windows, the .efis which Windows uses are at EFI/Microsoft/Boot and EFI/Boot, not case-sensitive, AFAIK. Might be worthwhile re-white listing the .efis inside these two.
  • If, after setting your boot order, you still can’t boot from your LiveCD installer, you need to white list the LiveCD efi, efi/boot/bootx64.efi

3 Installing Ubuntu

(I’ll be linking this part mostly.)

Now we get to the fun part. If your circumstances are anywhere like mine, you might need to partition your drive first. While you can partition your drive from the Ubuntu installer, in the interest of dual-booting, I recommend that you partition from Windows beforehand2. Here’s how.

Finally, you can proceed with installing Ubuntu. This tutorial pretty much says it all.

Note that the linked tutorial uses an older version of Ubuntu (11.10) which may or may not have caused the existence of the next section of this post which is…


After successfully installing Ubuntu, I rebooted. Sure the boot-up screen looked a bit different (there was a Unix-y underscore cursor present) but it still loaded directly to Windows 8!

I tried white listing the new EFI/ubuntu/grubx64.efi found in my ESP. However, that resulted to Ubuntu loading directly without even a shadow of GRUB showing up.

I then used the boot-repair utility and got these results. I had to re-white list EFI/ubuntu/grubx64.efi. Indeed, GRUB now shows up but without any option to boot Windows 8.

At this point, it’s been close to 1.5 days since I embarked on this task. I’m glad that xkcd got most of this stuff documented. And I’m also glad that, though I went beyond the 24-hour mark, nothing became a lost cause.

Besides, I’m not a very good swimmer!

In a moment of almost-frustrated defeat, I found zen from an earlier episode in this adventure. It dawned on me: just install rEFInd.

(Yep, my boot-up is now managed by rEFInd. Far from a perfect solution, in my opinion but it does what I wanted it to do. So long for now!)

  1. That’s on this Acer machine. If F2 does not work on yours, other candidates might be F10 and F8. []
  2. In my case, the Ubuntu installer didn’t detect another OS in my machine, didn’t detect Windows 8. I don’t know what would’ve happened if I made a wrong move while partitioning from the Ubuntu installer in this case. Hence, not recommended. []

Just putting this up here so I can describe the specifics of my case better…

Sometimes, Vista’s tells you that your WiFi connection’s status is “Limited” or “Local Only”. While most of the time this is solvable by resetting/going nearer to the router, I just had a peculiar case of this annoying problem.

So, today I logged in to Vista after so long. It was detecting our home WiFi with no problem but I can’t seem to load webpages on my browser. The connection seems to drop off as soon as I request for data. The longest I got a connection to last was just enough for me to log-in to GMail. I ruled out that this is a problem with my service provider as Ubuntu connects to the net just fine.

As far as I can tell, the connection is fine upon starting Windows but fails the moment I request for data. The connection cannot be reset after it fails so, to test new theories, I need to restart Windows (annoying!). I tried to ping to check when the connection drops and I only got as far as two replies before I got a request timeout.

Searching around, I found out that the problem is with Vista’s IPv6 connectivity. For some reason, if you have this enabled, Vista will have trouble connecting to pre-IPv6 (read: old) routers.

Here’s how to disable IPv6 in Vista (YouTube):

As the video suggests, you may need to wait for Vista to refresh. There was a considerable waiting time for my Vista to refresh and, as Vista isn’t exactly known for being responsive, I suggest you just restart after disabling IPv6.

OpenCV is a programming library for computer vision routines. As I’m doing my undergrad research in UPD-DCS’ Computer Vision and Machine Intelligence Group (CVMIG), I recently had the need to install OpenCV in Ubuntu.

Perhaps the most obvious way—yet most troublesome as well—to install OpenCV in Ubuntu would be to compile it from source. I started using Ubuntu March 2010 but, to date, I still haven’t installed anything successfully via build from source. So, I’m not dwelling on that here. Building from source isn’t a quick and easy way by any means.

The instructions at Ubuntu’s Community Documentation is, by far, the easiest way I’ve found. However, the last sudo apt-get install line mentioned—the one that’s supposed to install all the OpenCV goodness into your system—fails with the error message “Couldn’t find package libcv2.1”.

Maybe it used to work, back when OpenCV was just version 2.1. Unfortunately, as of this writing, OpenCV is now in version 2.3. To remedy the apparently outdated Community Docs, head over to Ubuntu’s package information page for OpenCV and sudo apt-get install all the packages mentioned there. So the last line with which I’m having issues with becomes (as of this writing!):

sudo apt-get install libcv-dev libcv4 libcvaux-dev libcvaux4 libhighgui-dev
libhighgui4 opencv-doc python-opencv

Note that the package info page link I gave is for Lucid since I’m in Lucid. There are links for the corresponding packages for other supported and LTS versions in the page. Click the one that suits you.

Running the examples

The Community Docs have instructions on how to run the examples. However, I stumbled on as, apparently, on the first iteration of the script’s compile loop, it misconcatenates strings and tries to compile something called .c.c. I tried to compile each file individually to which my terminal gave me the following:

$ gcc -o squares squares.c
squares.c:12:16: error: cv.h: No such file or directory
squares.c:13:21: error: highgui.h: No such file or directory

Followed by more lines of error which, as far as I can tell, should go away had these two libraries linked properly. While it may initially seem (as it did to me) that OpenCV failed to install properly, this is actually just some quirk with C’s compilation process. I remember having this problem with math.h and that is, as far as I understand, a standard C library at that.

When I realized this, I opened in GEdit and found how to invoke gcc/g++ so that the examples compile. Invoke gcc as:

gcc -ggdb `pkg-config opencv --cflags --libs` inputfilename.c -o outputfilename

Same thing works for the .cpp files (C++ source codes) but don’t forget to invoke g++ instead of gcc!

More musings:

  • The first command the Community Docs asks you to do is sudo su which makes you a root/superuser in the command line. From there you should be able to execute protected commands even without the sudo invocation. Hence, the sudo calls in the subsequent lines shouldn’t be necessary, though it won’t hurt to have them.
  • On why the most troublesome method is the most obvious one. Google “install opencv ubuntu” and the first link that will discuss installation without compiling the code is at position 6, and it is outdated at that (yep Community Docs, I’m still looking at you). Even the official OpenCV installation manual tells you to build from source. I know that it is bothersome to write an installation how-to for every Linux distro out there and that not all of them probably support sudo apt-get install, and for those non-Ubuntu distros that do, they probably do not connect to the Ubuntu package repos and so there may be a discrepancy or two that needs to be addressed. However, I specifically searched for Ubuntu instructions. I love Ubuntu and all the geekery that goes with it but I am of the opinion that if Ubuntu is really to be user-friendly, the easy methods should be the most obvious ones.

UPDATE: Having problems making your DDLs utilizing foreign keys work with InnoDB? This may answer some questions.

In retrospect, I made the same mistake when I asked that at SO as when I made this post. The errant statement when I made this post is

timestarted DATETIME NOT NULL,
PRIMARY KEY (timestarted),

No column reference.

Note: This post is a summary of this Ubuntu Forums Programming Talk thread. With special thanks to nklatt for asking the questions which led me to my resolution.

I’ve been working on a JDBC-backed application. Since I am familiar with MySQL, the MySQL Connector/J comes as a natural choice for a database driver. Since I’m using Java, I expected my code to run on both Linux and Windows environments.

Testing it with Vista, it runs well. However, when I tested it in Ubuntu, I was greeted with the following error:

java.sql.SQLException: Can't create table 'dbname.timelogs' (errno: 150)

Googling around, I found this which says that this error happens since MyISAM, the default storage mechanism used by MySQL, doesn’t support foreign key constraints. And yes, I am using foreign keys in my tables. Also, a quote from the official MySQL docs says,

Foreign key constraints are supported for the InnoDB storage engine only. For other storage engines, the foreign key syntax is correctly parsed but not implemented.1

I checked the tables created at Vista and found out that they use the MyISAM storage engine as I expected since I didn’t specify any storage engine in my CREATE statement and so should fall back to the default. This made me wonder all the more why didn’t it throw the error in Vista when MyISAM isn’t supposed to support foreign key constraints.

At this point, I must note that Vista runs XAMPP 1.7.3 while Ubuntu runs version 1.7.4 . I didn’t think that my XAMPP version will matter—after all, Vista is only a version behind. Spoiler: I thought wrong.

I changed my CREATE statements such that they explicitly specify the InnoDB storage engine. I ran my modified code in Vista and, surprisingly, Vista threw the very error Ubuntu does.

Confused, I switched back to Ubuntu and, for the first time in this bug-hunt, checked the table created2 at phpMyAdmin (I have two tables in my database, only one of which specifies a foreign key. The one without the foreign key gets created, of course). I discovered that MySQL 5.5.8 (the MySQL server that comes with XAMPP 1.7.4) actually defaults to InnoDB and not to MyISAM3.

So it turns out that, weirdly, the InnoDB storage engine was the one causing all my problems despite the documentation declaring that it supports (in fact, it is the only storage engine that supports) foreign key constraints. Resolution: stick with MyISAM since that is where my code runs, despite the fact that it doesn’t really support foreign key constraints.

(In any case, the user will interact with the DB through a GUI. So, it’d be more or less the GUI programmer’s fault, i.e. me, if some record doesn’t make sense. Sigh. So much for being a one-man team.)

  1. , retrieved 6/22/11, 11:09PM GMT+8. []
  2. This was still the one created by the code not specifying any storage engine causing MySQL to default. []
  3. If you read the thread I linked above, nklatt pointed this out beforehand for MySQL 5.5 . []