Category Archives: HowTo

Run your dual-booted Ubuntu install under Windows with VMWare

First off, this isn’t what you might call a “supported” configuration so as ever YMMV and don’t blame me if it goes horrifically wrong and you end up with two/three systems that won’t boot (your VM, your native install and optionally, the VM host :P). Having said that it worked fine for me, but it might be wise to make a disk image somewhere else and have a livecd ready if it goes wrong and you need to do recovery. Also you can possibly do this with VirtualBox or VMWare Player, but I haven’t tried it. I started with Ubuntu 15.04 installed on my second hard disk in an extended partition along with an NTFS data partition, and Windows 10 on the other disk which is the primary (but is an SSD, so it’s small) along with VMWare Workstation 12.

In short we’re going to create the VM, then add an extra boot disk and install GRUB into this from the Ubuntu DVD.

First off, create a new VM, choose a Custom machine and go through all the usual steps of names and locations and cores and RAM. When you get to “Select a Disk Type”, choose SATA (if you choose SCSI it will whinge on first boot that performance will be poor). Then select “Use a physical disk”, set Device to the correct disk (PhysicalDrive1 in my case) and choose Use individual partitions, then tick the relevant partitions for your Linux system (ie the root filesystem and the swap partition).

Finished dual boot VM

Click Next a few more times and then Finish (don’t hit Customize Hardware, or it doesn’t bother adding the disk). Then edit the machine to add a hard disk. This one can be SCSI since it’ll be an actual virtual disk, you want to create a new one and set the size for something like 200MB (it’s going to have the boot partition, so not much space needed!). Finally mount the Ubuntu 15.04 live disk in the CD drive, as you’ll need to boot this first.

Now boot the machine. At this point you might be told “Insufficient permission to access file”; when I had this working in Workstation 9 it would just throw up a UAC prompt but apparently 12 doesn’t, so restart VMWare Workstation as administrator to get that low-level disk access we need. Once you’ve got to the live desktop, open a terminal (Ctrl-Alt-T in Ubuntu). We’re going to format our new virtual disk, then chroot to it and install GRUB. To partition and format the new disk, run the following, but first heed this warning: for me the virtual disk was /dev/sda, but I suggest checking with ls /dev/sd* to make sure you don’t overwrite your dual-boot disk, as that would be a mess!

parted /dev/sda mklabel msdos
parted /dev/sda mkpart primary ext2 0% 100%
mkfs.ext2 /dev/sda1

It goes without saying these have to be run as root. Next up comes courtesy of AskUbuntu user Nathan Kidd, on this question which explains how to chroot to an empty disk; it looks like this:

mkdir /mnt/chrootdir
mount /dev/sda1 /mnt/chrootdir
for dir in proc dev sys etc bin sbin var usr lib lib64 tmp; do
    mkdir /mnt/chrootdir/$dir && mount --bind /$dir /mnt/chrootdir/$dir
chroot /mnt/chrootdir

Finally we need to install GRUB and then run an update to generate the menus, and we’re done!


That’s it! Exit the chroot, shutdown the VM (it hangs, I had to hard-reset) and remove the ISO, and the next time it gets booted it’ll be running the real Ubuntu install on your hard disk. Remember to install the open-vm-tools and open-vm-tools-desktop packages or VMWare Tools to make auto-resize and stuff work. Also I wouldn’t suspend the VM and then boot the real copy…that pretty effectively kills both the VM and the underlying install in my experience.

Installing Ubuntu wireless drivers on fresh install

So here’s the problem I found myself faced with today; when I ran Ubuntu 15.04 live on my laptop I could pop open the Additional Drivers tool, enable the driver for my wireless card and get on the Internet, lovely. Then I made the (I think very sensible) assumption that the same would work after I’d installed Ubuntu, until to my surprise, it just sits there thinking about it.

Wireless Driver Working

It turns out once you’ve installed Ubuntu expects an Internet connection and doesn’t use the CD (or USB stick in my case), not ideal when it’s the network driver and you don’t have wired in your house. In principle you should be able to go to Ubuntu Software under Software & Updates and just select the CDROM option, then tell it to install the driver.

CDROM option enabled

No dice, it still just sits there. However this AskUbuntu question (found using my phone!) points to the commands to do it from a terminal, which usually gives a bit more helpful info. First run ubuntu-drivers devices which gives the name of the package to install, then attempt to install the package by the usual means:

root@buccaneer-linux:/home/sam# ubuntu-drivers  devices
== /sys/devices/pci0000:00/0000:00:1c.1/0000:03:00.0 ==
modalias : pci:v000014E4d00004358sv0000105Bsd0000E040bc02sc80i00
model    : BCM43227 802.11b/g/n
vendor   : Broadcom Corporation
driver   : bcmwl-kernel-source - distro non-free

== ==
driver   : intel-microcode - distro non-free

root@buccaneer-linux:/home/sam# apt-get install bcmwl-kernel-source
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
The following NEW packages will be installed
  bcmwl-kernel-source dkms
0 to upgrade, 2 to newly install, 0 to remove and 217 not to upgrade.
Need to get 0 B/1,574 kB of archives.
After this operation, 8,390 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Media Change: Please insert the disc labelled
 'Ubuntu 15.04 _Vivid Vervet_ - Release amd64 (20150422)'
in the drive ‘/media/cdrom/’ and press enter

At this point I put my USB stick back in and symlinked it (ln -s /media/sam/UUI /media/cdrom if you don’t know) and pressed Enter, which presented me with exactly the same message again. Apparently doing that just makes Ubuntu helpfully unmount the USB stick!

Adding new software source

The solution is to add the USB stick as a separate software source, although identifying the correct syntax took some trial and error. Under the Other Software tab, hit Add, then enter a line something like below, hit Add Source, do apt-get update (there will be a lot of “failed to fetch” errors!) and then try the install.

deb file:///media/sam/UUI vivid main restricted

However (and this is where I had trouble and had to run the update quite a few times), the three words after the path depend on the distribution. So, on your USB stick in the folder you specify (UUI in my case) should be a dists folder and in that folder should be another folder for the distribution – vivid in my case. The final two refer to the components available and should match the subfolders of vivid

Folder structure of Ubuntu install package archive

After you’ve run the update the install should finally succeed with apt-get install bcmwl-kernel-source in my case, and then all that’s left is to remove your new software source.


Add a new software source like deb file:///media/usbstickmountpoint vivid main restricted, run ubuntu-drivers devices then apt-get install the relevant package under “driver”

Hope that helps someone!

How to auto-reload binaries in GNU ARM Eclipse

I’ve been working on my final year project using the GNU ARM Eclipse plugin and the STM32F4 Discovery board to write some simple signal generation software. Eclipse has a button to reset the target and restart debugging on the toolbar, and I figured it would also download a new binary if there was one. Unfortunately it doesn’t, and I couldn’t find any explanation how to start debugging, find a problem, make a change, recompile and reload the software without stopping and restarting the debugger, which isn’t all that quick.

Turns out its really easy, at the bottom of the Startup tab in the Eclipse Debug Configurations box is a space for commands to run after a reset, and it looks like that’s run when you hit the reset and restart button too. The commands I used were:

symbol-file C:\\Users\\Sam\\...someotherstuff...\\Debug\\projectname.elf
load C:\\Users\\Sam\\...someotherstuff...\\Debug\\projectname.elf

It looks like the double backslash is important to escape the path properly, and obviously I’ve changed the path and remove the project name to protect the guilty!

Hope that helps someone, or possibly me if I forget how to do this!

Linker trouble in GCC 4.8

Thought I’d share this one as it stumped me for a while. I discovered recently that Tarantula, a project I’ve been working on for YSTV, wouldn’t build using GCC 4.8 despite building fine with 4.7. It complained about not being able to resolve a few pthread symbols, specifically:

../../bin/ undefined reference to `pthread_create'
../../bin/ undefined reference to `pthread_detach'
../../bin/ undefined reference to `pthread_join'

It turns out in 4.8 the –as-needed linker flag is enabled by default, which will not link with symbols the linker doesn’t think are needed at build time. Unfortunately because of the way it works, if a library was specified in a link line before the file that depends on it, it will not be linked.

However, if instead a shared library has a dependency, it must be specified on that library’s link line rather than the main executable’s whereas it used to be enough to specify just for the executable. For me the solution was to add the $(LIBS) makefile var to the end of the link line for the .so file.

Alternatively, for the “big hammer” solution, the as-needed behaviour of GCC can be turned off using -Wl,–no-as-needed as a global compiler flag in the Makefile.

Inexplicably slow hard disks? Try disabling PIO mode

A baffling problem I came across recently was a server where copying between internal disks ran painfully slowly, getting around 3.3MB/s between internal SATA drives. Of the machine’s three disks, two were failing with huge numbers of ATA errors and bad sectors, so I pulled those out an ran test copies to and from the remaining system disk, with no improvement. Incidentally, to find out that the drives were failing I used a brilliant little tool called HDD Guardian which reads SMART monitoring values the same way smartctl does, just with a nice graphical interface.

It turns out the server had defaulted to IDE mode on the disk controller as Server 2003 doesn’t really contain any SATA AHCI drivers and you’d need a floppy disk to install them. In of itself this wouldn’t cause an issue, but when Windows detects multiple CRC errors on a disk transfer, it will reduce the transfer rate. Eventually the disk will become stuck in Programmed Input/Output or PIO Mode, which essentially means all data transfers must pass through the narrow CPU IO bus rather than going via system memory which chews up a lot of CPU time. There’s a lot more info on this topic at

To fix this, there are some instructions in KB817472 in the Microsoft Knowledgebase and some other instructions in this TechLogon article, neither of which fixed the problem. Since the server in question is a VM host and all the VMs were copied onto other systems anyway when the drives failed, I just reinstalled it with Server 2008 and the disks set in AHCI mode, which is cheating, but it made the problem go away.

Now my transfer speeds are back to normal, so I just have to replace the two 500GB drives with 4000 reallocated sectors. Drive magnets anyone?

How to fix a loose battery on Acer Aspire 5750

I’ve had my trusty Acer Aspire 5750 for a few years now; and with the addition of an SSD, from PC World of all people (there was a sale), I expect it to last for a while yet. On and off I’ve noticed it failing to resume, or just powering off at odd times and worked out the battery is loose, but up until now I haven’t been able to fix it.

Inside the battery compartment are a pair of plastic loops which are the catch for the release mechanism, and then there are fixed plastic wedges on the battery for the loops to snap into. It looks like one or both of them is on the edge of tolerance, so occasionally the battery would fall far enough to lose contact and power off.

A little bit of plastic to the resuce

A little bit of plastic to the resuce

The solution: Cut a tiny piece from a plastic card (I used an expired gift card) and leave it on top of the battery when it goes back in, and then pull open the battery release and push it down fairly hard – who’d have thought such an annoying problem would be so easy to fix!

Anyway, I couldn’t find anything on Google for it, so hopefully this helps somebody.

EDIT 28/08/2014:
Well it turns out that wasn’t a very permanent solution to the problem, it kept coming back when the bit of plastic fell out. In the end I bought a new battery from Amazon (one of these) which has actually fixed the problem, it doesn’t wobble anymore.