Programming Blog

Jeremy Morgan

Mostly Coherent Ramblings of a Silicon Forest Software Developer

How to Restore Arch Linux Boot After Installing Windows

By: Jeremy Morgan






This week they released the RTM Version of Windows 10, and I decided to install it on my laptop. Most of my development is done on my desktop Mac at home, but the laptop is good for collaborating, coffee shop coding, etc. I decided Windows 10 and Visual Studio 2015 would be good for this. There’s only one issue: I also have Arch Linux on this laptop, and it’s dialed in very nice and I definitely don’t want to remove it.

I haven’t upgraded Windows on this machine since I put Windows 8.1 on it over a year ago, so I never had to deal with the issue of fixing grub. It is slightly different from other distributions, and there is no “boot repair” yet. I decided to Google a few things and figure out how to restore it but didn’t find a complete article on it, so I decided to write one. I installed Windows 10 on the machine without changing any of the partition data, and that’s crucial. After doing that it would only boot into Windows 10, so here’s what I did.

1. Download an Arch Linux ISO

Download a live ISO for Arch Linux here. If you’re using Windows, LiLi is a great free tool for creating bootable Linux USBs.

boot to this USB drive and you’ll be taken to a command prompt.

2. Restore Grub

This assumes of course that you were using GRUB to begin with, but here’s how to restore it.

Find the partition your linux is installed on:

1
cfdisk

You’ll see something like this:

How to restore GRUB in Arch Linux

In my case my Linux installation is at /dev/sda4. Note where yours is, then exit this application.

So mount your Linux partition:

1
mount -t ext4 /dev/sda4 /mnt

Then, change root with this command (specific to Arch Linux)

1
arch-chroot /mnt

and restore GRUB:

1
grub-install /dev/sda

And yes, it does detect Windows 10 properly.

After you reboot, you’ll see your familiar boot screen again:

How to restore GRUB in Arch Linux

And you can now boot into Linux (or Windows) again.

Configure Grub

Now if you’re like me (which you probably are if you’re reading this blog) you will be bothered that it incorrectly says “Windows 8” or whatever your previous version was. This is easy to fix by editing some entries in your Grub configuration:

Make a backup of your grub.cnf

1
sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.8.1

Edit the file:

1
sudo nano /boot/grub/grub.cfg

Look for the Windows 8 or Windows 7 entry in the file:

How to restore GRUB in Arch Linux

and change it to whatever you want. Then reboot. Now it should look like this:

How to restore GRUB in Arch Linux

This is how I have mine set up. If you’d like to learn more about GRUB menu options click here.

Summary

This is how you can restore your dual boot options if you reinstall or upgrade Windows on a dual boot Arch Linux system. I have heard of people just reinstalling Linux afterword, and it’s a terrible idea unless you were going to change it anyway. It only takes a few minutes to fix.

A note about Arch Linux:

As I said in the article I have Arch Linux installed and it’s “dialed in” meaning I have a nice system compiled with only what I need, lean custom kernel, and my development environment is all set up. I wouldn’t advise an Arch install to everyone, but it has been fantastic for me personally. It runs very fast and reliably and it’s easy to update everything.

If you’re looking for a new disto, or just want to escape the Ubuntu crowd, you should give it a try. IT has a steep learning curve as you’ll need to know Linux really well, or be able to follow the directions explicitly, but if you do you’ll find a nice solid system that’s fast and lean.

Get Arch Linux Now

-Jeremy


Do you like articles like this?

I’m constantly hacking on stuff and writing about happenings in the programmer world. You can subscribe to my feed here, or you can get the hacker newsletter 100% spam free!

You can also follow my projects on GitHub:

Comments