Sony laptops are nice and performing Windows machines, but they are notorious for being incompatible with Linux on many fronts. This one is not an exception. I spent a considerable time figuring out how to set it up properly and by documenting this for you, my dear reader, I hope to save some of your time.
This article documents the working steps I took to manually install Linux (Fatdog64), with Secure Boot enabled all the way (never turned off), and keeping Windows available for dual-booting.
To protect the innocent I will not mention the exact model, but you can be assured based on the many articles I've read, other UEFI models suffer from similar problems too.
This is a bit lengthy. If you just want to read the steps, go ahead and click here.
vmlinuz
and initrd
) to any existing partition.
grub.cfg
. So if you favorite distros bootloader does not work,
but you managed to install it to the point where it has a good and
valid grub.cfg, you can use Fatdog64's bootloader to boot it, too.
I assume you are familiar with BIOS (non-UEFI) boot process. The term MBR (Master Boot Record) should not be foreign to you.
When UEFI BIOS is ready to load the operating system, it will attempt to find and load a bootloader. Unlike in BIOS system where the bootloader is in a fixed place in MBR, in UEFI the bootloader location can vary, as long as it is located in a special disk partition called the ESP (EFI Service Partition) (Protip: ESP is a term, not a label, and there can be more than one ESPs).
The default bootloader is named bootx64.efi
(for amd64/x86_64 systems)
and is located in /EFI/Boot
directory. In other words, the default
filepath for the bootloader is /EFI/Boot/bootx64.efi
-
in the first ESP partition (if there is more than one).
At least in theory.
But this is not set in stone. Apart from answering the obvious
question (but no obvious answer) of "which one is the first ESP partition",
in a properly configured and spec-compliant UEFI BIOS, you can define
and store entries that points to many different bootloaders - both
specifying their filepaths as well as which partition that keep them.
You can, for example, define that an entry calledFooBar that
loads /EFI/FooBar/mybootloaderx64.efi
from the third
partition of the second hard disk.
Then, you can also choose, among these entries, which are the default bootloader. And it is expected, although not required, that at boot time, the UEFI BIOS provides some means for the user to choose alternative bootloaders other than the default one (just like the legacy BIOS provides hotkeys to choose boot devices) - so you can choose to boot FooBar instead of the default one.
Once the bootloader is loaded, UEFI BIOS will transfer control to it and
its job is done. The bootloader is responsible to load the rest of the
operating system just like the MBR does; and in fact its
job is easier - in legacy BIOS, the MBR is only 512-byte - not
much space to cram complex logic that modern disk subsystem requires,
so MBR is usually only used to load and find the "second stage" loaders
which are the "real" loaders: e.g. ldlinux.sys
for syslinux, or
second stage of grub, or grldr
for grub4dos, etc.
An UEFI bootloader on the other hand can be of any reasonable size (e.g 1MB, 2MB is common) and is loaded at once, effectively skipping the MBR stage and goes direct to the "second-stage".
That's it! Simple, right?
If you want more details and want to really know what exactly happens within UEFI BIOS from the point the computer is turned on until it starts looking for a bootloader, you may want to read from this link instead. ☺
Many! The main problem is that many UEFI BIOS-es are non-compliant to the specs. They just implement enough to get Windows booting, and nothing else (what else is new here - same thing happened to ACPI too).
For example, you may not have the interface to add/edit/define entries. Or the UEFI BIOS may not offer you the ability to choose boot entries to use at boot time. Certain UEFI BIOS-es always boots Windows first if it can find it, regardless of whatever other entries and whatever default entries you have specified. To add insult to injury, certain software (not sure whether it is the UEFI BIOS, Sony EFI pre-loaders or Windows boot manager) removes some entries it deems extraneous (that is, everything which has nothing to do with Windows).
I hope you see the problem. Sony UEFI BIOS comes with all of those problems. About the only redeeming feature is that you can make it boot from external media quite easily (press Sony "Assist" button, and when the menu appears, choose "external media").
As noted above, installing Fatdog64 is easy, just copy over two files. Installing bootloaders in UEFI (even in Secure Boot mode) ie easy too, just copy a bunch of files - contrast this with installing legacy BIOS which requires you to write toe MBR, boot sector, making sure that boot files are stored in contiguous location on disk, etc etc.
What is especially difficult is telling the UEFI BIOS to make use of the bootloader you just installd; and to keep using it as the default bootloader regardless of various hostile actions that try to remove it.
In the days before UEFI, it is possible to use Windows bootloader
as the primary bootloader to start Linux operating system.
You can do it this way: configure ntldr
(or bootmgr
in Windows
Vista and 7) to load a bootsector image and chainload to it.
The bootsector image could then load grldr
(grub4dos bootloader) or
other bootloaders which then load Linux.
If you configure this properly, you will even get a boot menu when the
computer is started, asking you to choose to boot Windows or the other
entries. It is nice and good.
After UEFI, however, nobody has figured out how to use Windows bootloader to boot anything other than Windows. The closest one I can find is this - but it didn't work when I tried it.
The actual steps are quite simple.
Test this a couple times by shutting down and starting up Windows, making sure that it really does a shutdown and cold startup rather than using its FastBoot / HybridBoot / HybridSleep stuff (which is a cheap trick because they couldn't get Windows to boot faster properly).
/EFI/Boot/bootx64.efi
and /EFI/Microsoft/Boot/bootmgfw.efi
). This will be our target.
sda7
) for Fatdog64.
sda3
. Rename /EFI
directory to /EFI-win
.
sdb2
). Then copy over Fatdog's /EFI
directory to
sda3
.
/drivers
directory from Fatdog UEFI bootloader driver
and put it under /EFI/Boot
in sda3
, and rename it to
drivers_x64
so that they are automatically loaded and the
rEFInd bootloader will have access to NTFS partitions (especiall
important if your Fatdog64 files are located in NTFS).
/EFI-win
and the UEFI BIOS does not
know how to boot that. Rather than fighting with UEFI BIOS, it is
much simpler to modify rEFInd configuration and tell it to load
Windows bootloader (normally rEFInd does not require this step as
it can find Windows bootloader automatically too, but since we
moved it to /EFI-win
, it can't find it and has to be told
where it is).
/EFI/Boot/refind.conf
(on sda3
) and create a new
entry to boot Windows. A sample entry already exists,
but it points to /EFI/Microsoft/Boot/bootmgfw.efi
. All you need
to do is modify it so that it points to /EFI-win/Microsoft/Boot/bootmgfw.efi
instead. Then remove the "disabled" line to activate it.
You can add icons if your want to get fancy.
vmlinuz
, initrd
and also grub.cfg
(this is needed by grub2 to find out
which partition has Fatdog64 installed).
grub.cfg
must be put at the root of the partition that contains Fatdog64.
Update May 2017
Long-time Fatdog user and Puppy Linux forum member Wognath followed this guide to Fatdog on his computer; then he tried to update Windows. In his own words:
Installing a new bootloader also means that ALL your previously installed operating system will not boot unless you configure the new bootloader to boot them. If you don't understand the consequences of the actions described in earlier, you'd better stay away from doing this altogether. You have been warned!
I quote the second post from the top:
Boot Linux from Windows, it didn't work for my case. Perhaps it would work if Secure Boot is disabled but in my case I was attempting to do the installation without disabling Secure Boot at all.
This should work, as it is similar to what this article explains only that it is less extreme, but it did not work for me - somehow the UEFI BIOS or Sony preloader managed to find the right copy of bootmgfw.efi from somewhere and still booted Windows. You should definitely try this one first before going with what steps outlined in this article.
The ability to boot from UEFI and Secure Boot is the result of hard work from many people, without which none of this would have happened. Fatdog64 owes its ability to boot from UEFI/Secure boot by using excellent software from these people / projects:
Thank you, guys!