Sunday, 16 June 2013

Sane Window Placement in Unity

I've never been terribly enamoured with Unity's window placement algorithm. Granted, it works reasonably well for single monitor configurations. However, once we start using larger multi-monitor configurations, windows all too often pop up on a monitor far away from the one presently in use. That's bad enough; but when we're talking about dialog windows too, it quickly becomes intolerable.

The simple but effective algorithm of "place beneath the pointer" is a tried-and-tested golden oldie. It is often found on the older-style window managers, built for productivity and simplicity (think descendents of fvwm). It also happens to be ideal for large multi-monitor configurations, as new windows are spawned where your pointer (representing your present view point) is.

Thankfully, switching to such a placement algorithm is made simple in Compiz.

Start "ccsm" via the Unity dash, locate the "Window Management" section, click on "Place Windows", and make the following changes:

Placement Mode -> Pointer
Multi Output Mode -> Use output device with pointer
Force Placement Windows -> enter the text "(type=Dialog) | type=Normal", without the quotes.

Saturday, 1 June 2013

Installing Linux on Samsung Laptops

I'd had enough of waiting for Samsung to comment on their laptop bricking fiasco. As you may recall from my earlier post, Samsung support had set out to obtain some information with good intentions, but ultimately could tell me nothing other than what I interpreted as Samsung refusing to honour their own warranty terms. I wasn't impressed.

Elsewhere in the ether of the Internet, I could see little sign of progress. In general, people are still waiting for Samsung to issue a statement. Perhaps one of their subsequent BIOS updates has already resolved the issue? They're not saying.

Having owned this Samsung NP350V5C-A0EUK laptop for 6 months now, I feel as though I've waited long enough. Now's time to bite the bullet and install Linux, regardless of the risks.

Needless to say, I can't be held responsible for any problems resulting from anyone choosing to follow the following instructions.

Due Diligence

Torvalds did pull a patch written by Matthew Garrett, which limits the amount of data written to UEFI storage, thus preventing (or at least reducing the likelihood) of the issue manifesting. To maximise my chances of success, I intended to install a distro of Linux which included this patch in its installation media.

To this end, I sought a recently released distro. An obvious candidate was Ubuntu 13.04, having being released just a month or so ago. According to the release notes, the installation media comes with Ubuntu kernel 3.8.0-19.29 based on Linux 3.8.8 (I also confirmed this on this directly on the installation media ubuntu-13.04-desktop-amd64.iso).

By comparing drivers/firmware/efivars.c in the diff with that in Matthew's patch, it was clear that the 13.04 installation media does indeed contain the patch - it's as safe as it's presently possible to get.

The other obvious thing to check was that my laptop's BIOS was up-to-date with the included SW Update application. It was.


Frankly, there isn't much else to check. Ubuntu provides some general UEFI installation advice, but there isn't much new there.

I was going to leave things moreorless as they were out of the box - UEFI enabled, SecureBoot enabled - and set up a dual-boot with Windows 8. I would leave partitioning to be handled within Ubuntu's installer (you occasionally hear of concerns regarding shrinking Win 8 partitions using Linux tools without taking additional steps before the event - I didn't think such concerns were founded).


I used Startup Disk Creator on Ubuntu to create a bootable USB drive from ubuntu-13.04-desktop-amd64.iso. Then I booted it via Samsung's BIOS (entered using F2) via the "Boot Override" section in its "Exit" tab.

I chose to select "download updates whilst installing" to capture any further updates at the earliest opportunity which might possibly impact the stability of the UEFI (not that I thought there were any; but, caution never hurt). This had the effect of upgrading the kernel from 3.8.0-19 to 3.8.0-23 during the installation process.

Since I was essentially testing a default installation on Samsung UEFI laptops, I refrained from my usual custom partitioning and chose "Install Ubuntu alongside Windows 8", which I would imagine is the more commonplace installation choice. That also had the added benefit of saving me from accustomizing myself with the nightmare that is an OEM's Win 8 default partitioning scheme.


Rebooting... worked. I was presented with a GRUB boot menu. Choosing Ubuntu booted into 13.04 successfully.
  • Graphically, Unity was working perfectly with the Intel HD4000
  • Win 8 partitions could be accessed with one click
  • Wireless was up - the network password had been remembered from when I entered it during the installation process
  • The battery meter was fine
  • Bluetooth was working
  • Suspend on lid close/restore on lid open was fine
Next up, booting back into Win 8. Choosing Windows 8 (loader) from the GRUB menu resulted in:

error: can't find command 'drivemap'.
error: invalid EFI file path.

Press any key to continue...

Booting to "Windows Boot Manager" via the BIOS' Boot Override menu didn't work either - it presented a Windows "your system has encountered an error" screen briefly, before rebooting. This wasn't good.

I continued booting to "Windows Boot Manager" via the BIOS. On the third attempt, Win 8's Automatic Repair (quite a nice feature, Microsoft - well done) kicked in and automatically started the boot repair process. No user input was required. It spent about 60 seconds "repairing", after which it rebooted.

"Windows Boot Manager" via the BIOS then succeeded - Win 8 was alive again.

As for the Windows 8 (loader) entry in the GRUB menu; this is just going to need some tweaking of the GRUB menuentry (some ideas can be found here). I did get it working directly via GRUB; I'll make the changes to the grub config later on.


Just comment out most of the grub menuentry for Windows 8; leave the second search line (search --fs-uuid --no-floppy --set=root <the_ID>) and replace the chainloader line with chainloader (${root})/EFI/Boot/bootx64.efi. Hopefully GRUB will have this remedied soon.


It worked close to flawlessly for me.

Whether that's because Samsung has fixed the issue in a BIOS update, or because of Matthew's kernel patch, or perhaps my particular laptop's firmware isn't affected, or just down to luck (and it might fail later on), I'm not sure. I certainly can't say it will work for you. All I can say is that, so far, it's worked for me.

If you do fancy installing Linux on your Samsung laptop, I'd advise a path similar to the one I've documented here. It's quick, easy, and intuitive - it is basically aligned with the default installation recommendations for 13.04 on UEFI.

So, the situation is looking promising. The real travesty is Samsung's continued, and continuing, blithely indifferent attitude towards Linux users. This appears to be a critical firmware bug which results in complete hardware failure. Failing to provide a fix in a timely manner, failing to provide updates to end-users, and refusing to fix machines which fail under warranty; that is not a consumer-friendly approach. Given that Samsung is now king of kings among Android mobile device manufacturers, their attitude is hard to understand, and even harder to accept.