So… I have a laptop with Windows 10. And I’m using also the Linux Subsystem for my development, lately is exclusively nodejs and Vue.
But, regardless of the usage, it’s still windows. So, after a while, it becomes bloated and slow and heavy.
I decided to install Linux, alongside with my windows system, choosing ElementaryOS. A very pretty OS, based on Ubuntu.
It wasn’t very easy, since I have to pass some not so easy obstacles.
The obvious steps to take
So, the obvious steps to make, in order to install a second operating system (call me Linux distribution) along side to your primary one (call me Windows), are the following:
As we all know, the way ntfs works, is to split all files across the partition, in small pieces. And defragmentation is the process which gathers all these pieces in the beginning of the partition, in order to leave all the empty space at the end. The main reason for doing this, is step 2, “shrinking the partition”.
Theoretically, it’s an easy procedure. You empty the drive as much as possible (empty trash, deleted all movies you even forgot that you had, uninstall all these games you played years ago etc).
And afterwards, run the tool. You can use either the built in applicator external ones, such as my personal favorite, defraggler. Usually, it’s a long time process, not less than a whole night, even if it’s an SSD drive.
2. Honey, I shrunk the partition
Second step, is to shrink the partition, so to give enough space for the Linux. Linux, if we’re talking for a single user system, nowadays it will need two extra partitions: main and swap. If you’re planning to use it in a more complicated scheme, like multiple drives etc, then you need something more complicated, but for a one-man show these two partitions are enough.
Just keep in mind that the swap partition must be, in general, the same size as your memory. The main partition now, definitely not less than 12-15Gb, if you want it for simple use, have in mind for something up to 30Gb. You will still have access to the Windows partition, so you will be able to use/access it from the Linux.
3. Time to Linux!
Installing Linux, is the key part, since this is the reason why we do this in the first place, right? Find a distribution you prefer (I decided to use Elementary OS, a really beautiful distribution based on Ubuntu) and install it. As I wrote earlier, in a one-man show, we can keep it simple.
So, when it comes to select partitions, just make the first choice, “install alongside” with Windows. This way, you will lose nothing and still have access to Windows, through grub, the Linux boot manager.
4. Is everything in place?
As soon as everything is installed, I would suggest to do a few reboots, to make sure that everything boots at it should be. Both Windows and Linux.
5. Update Linux
Next step (we’re almost done) is to do all he necessary updates on your all fresh installation. After this, a couple more rebooto make sure nothing is broken and… voila! Two operating systems, Windows and Linux, next to each other. Easy peasy, right?
Well… in theory, it should be easy like this. Completely straightforward.
But no. It wasn’t like this, not at all. But let’s take it from the beginning:
The not-so-obvious problems
And here came the first problem, and it’s called “non-movable files”. There are some system files used for… system purposes. Memory paging, memory dump, hibernation files and much more. And for Windows to make sure that they will achieve the maximum possible performance, they flag these files as “non-movable”. And usually, in order to make sure that the specific blocks are used as less as possible from other files, Windows stores these files at the end of the partition.
So, do the math; non-movable files (aka blocks) at the end of the partition I had to shrink. Tough luck.
Trust me, it wasn’t easy to find the solution; after a lot of searching and searching and searching, I ended up to an article showing how to disable everything: hibernation, memory paging, memory dump, everything; deactivating them and removing all files.
This was the part I had to write down and remember, so when everything was done, to make sure that all these changes would be reverted. I definitely didn’t want to end up with an unstable Windows system that wouldn’t be able to restore if anything wrong happened.
Problem: Updating Linux
This was something unexpected. As soon as I installed ElementaryOS, there were quite a lot of updates to be done. But something went wrong. Something terribly wrong. The update crashed and I rebooted. But there was no Linux any more. Or, to be more accurate, there was no kernel. Or to be more accurate, “kernel panic not syncing vfs“.
The worst part was that there was no more Windows too.
Problem: Where did the Windows installation go?
And yes, ElementaryOS was broken, but as it looks like, something went wrong with Windows too! Selecting Windows from grub ended up to a black screen doing nothing. Just great!
Thankfully, a few days ago I came up to a rescue software package called Hiren’s BootCD. A really amazing tool that saved the day! Download the iso file, download the copy2usb tool and you have a usb with all the tools you need.
The only thing that remains, is to boot with the USB. But this should be easy, right?
Problem: How the heck you boot from the USB?
This at least, should be easy, right? I mean, boot the laptop, keep pressing F9 or F11 (usually) depending on the hardware and you’ll end up with the boot menu.
For some reason, this didn’t work. Whatever I did, it was always the grub menu. Which no menu option worked. Just fine. After a lot of reading, I found the sequence of commands to boot from the USB:
ls set root=(drive name) chainloader +1 boot
I ran these commands so many times tonight, I learned to type them with closed eyes! 😀
So, finally, this way, I managed to boot with the Hiren’s BootCD and (after more search), find out how to restore the MBR.
So, yeah, Windows was back! Thankfully!
Problem: Where did the Linux installation go?
Now, that was the hilarious part of the story; I got back the Windows installation, but lost the Linux one. Couldn’t “see” the Linux installation, couldn’t see the grub boot manager, couldn’t boot to Linux.
So, I did all of them from step one. Deleted all three partitions (grub, ext4 and swap) and started all over again.
This time, everything went fine with Linux. All updates, everything. But once again, no Windows.
Question: Can I have Linux through Windows?
I tried to think out of the box. If, for some reason, Windows are not working well with grub, what if I tried the other way round? Could I find a way to install a boot manager through Windows? So I could avoid using grub?
I tried to use the default Windows boot manager but I have to be honest here, the documentation and the process I found was so complicated, I didn’t even tried it.
Still, I downloaded EaseBCD. From what it looked like, this could do the work. Unfortunately, it didn’t Because the BIOS was configured as Efi and not as Legacy. And although I did change all BIOS settings from Efi to Legacy, Windows was loading again in Efi mode.
So, once again, bummer.
Finally, something that worked
At this point, I was more frustrated than confused. I mean, what the heck, I’m not the first and neither the last guy on this planet trying to make the obvious, there has to be something else that could… perhaps fix the grub in a way that won’t break the Windows partition?
And yes, there is. And the name is Boot Repair. It’s in an iso format, that you have to “burn” on a cd or a USB. But now, I already knew how to boot with the USB, right? Yeah!
I have to say that it was an awkward experience, because, it wasn’t just a task with a few clicks to make, it was an actual procedure with clicks, console commands and installations.
But yes. It worked. And now, I have grub (with quite a lot of options which I need to remove) with ElementaryOS and Windows 10.
And both are booting just fine! Right now, I’m writing from the Linux system, while installing my apps in the background.
It’s so cool!
PS: This is not a guide on how to overcome all the obstacles I mentioned above; that wasn’t my intention in the first place. I’m not a Linux guru. It’s more like the start of a nice discussion I would like to have with all of you guys, smiling while reading my story, and definitely sharing your experience.