Last week I got a new laptop. Lenovo U410. It’s a nice ultrabook. However, the chief topic of this post is not to review it, however to set up Archlinux on it without loosing any of the features that are, what should I call them… um, factory inbuilt. I’m talking about a raid0 array and a one-key rescue system that came preconfigured with the system. I searched much on the internet to find a safe way to install linux on this system however all of them did something that I didn’t want to do…
The usual method went something like this: backup everything, turn off raid, turn off UEFI and enable legacy boot in the bios, and then install whatever you like. I thought if they have given such nice features then why not use them? There must be a way of installing linux in this system without nuking it first. So, I went on and found the way… I will just write down the steps here for future reference.
Goal
The system that I wanted to create was something like this: 80GB for windows, about 40GB for Archlinux (20GB root and 20GB home plus about 200MB for boot) and the remaining space for a big data partition that can be shared between windows and linux.
Partitioning
First of all, there were two drives in the system. One big 500GB hard drive and another 24GB SSD. For our purposes, we don’t need to touch the SSD. Our dealing will be solely with the big one. The system comes with 4 primary partitions preconfigured. What it means is, we can’t make any new partitions without deleting at least one partition. Now, the partitions that one can see were only two. A partition in which windows was installed and another one labeled “Lenovo” which contained drivers and other softwares that came with the system.
To reach our goal, I needed to make some adjustments to these partitions. First of all, backup all the data in the partition labeled as “Lenovo”. Around 5GB of drivers and softwares. Once that’s done, fire up a partition manager. I used the combination of Gparted and Easeus partition manager to accomplish the following tasks… however, all of it can also be done with gparted.
I used a Ubuntu live disk for gparted. Then I did the following things:
1. Deleted the partition labeled as "Lenovo"
2. Resized the partition that contained Windows 7 from about 420GB to 80GB
3. Created an extended partition in the unallocated space after the windows 7 partition
4. Created an NTFS partition for storing the data. About 325GB.
5. Created an FAT32 partition for /boot for the linux system. About 20GB.
6. Created an EXT4 partition for / (root) of the linux system. About 20GB.
7. Created an EXT4 partition for /home of the linux system. Used all the remaining space… about 21GB.
You might notice that I have created a FAT32 file system for the boot partiton. Why? Well, we need it. We will not replace the windows bootloader in the MBR, rather, we’ll point the windows bootloader towards grub of our newly installed system. That grub, will be installed in a partition(specifically, the boot partition) and not the mbr. However, windows can’t see ext4 partitions… we’ll need something that the windows bootloader can see. It will probably see NTFS but it will certainly see FAT32. That’s why I went with FAT32. And, it paid off…
Installing Archlinux.
Well, I didn’t do anything special while installing Archlinux. Just follow the beginner’s guide and do the normal set up. Don’t worry about UEFI and stuff. Follow along until you come to the part where you need to install grub. There we need to take a detour. But first, we need grub installed (not in the MBR or partition but in our system. Using pacman):
pacman -S grub-bios
Once grub is available in our system, we need to install it in the boot partition. How? Like this. But for future reference, in case that if the page is edited for some reason, I’ll also post the commands here.:
modprobe dm-mod grub-install --target=i386-pc --recheck --debug --force /dev/sdaX chattr -i /boot/grub/i386-pc/core.img mkdir -p /boot/grub/locale cp /usr/share/locale/en@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo chattr +i /boot/grub/i386-pc/core.img
Note: When I issued the chattr command, it game some strange error… I looked it up but didn’t understood much. So, I decided to ignore it… seems that my computer also did the same as it works flawlessly right now. So, it doesn’t matter.
Alos, create a grub.cfg while you are at it:
grub-mkconfig -o /boot/grub/grub.cfg
So, once grub is installed in our boot partition, we need to make a copy of it’s boot info by doing the following: (Again, taken from the awesome archwiki)
my_windows_part=/dev/sdx# my_boot_part=/dev/sdx# mkdir /media/win mount $my_windows_part /media/win dd if=$my_boot_part of=/media/win/linux.bin bs=512 count=1
Adjust that to your setup and execute it. You might need to install ntfs-3g to write to the windows partition. If so, do so.
Configuring windows bootloader
Once grub has been installed, our work on the linux end has finished. Now, all we need to do is point the windows bootloader to our newly created boot partition with the info contained in the linux.bin file that we just created. To do that, I’m gonna directly quote archwiki page that I referenced earlier.
Boot to windows and open up and you should be able to see the FAT32 partition. Copy the linux.bin file to C:. Now run cmd with administrator privileges (navigate to Start->All Programs->Accessories, Right-click on Command Prompt and select “Run as administrator.”)
bcdedit /create /d “Linux” /application BOOTSECTOR
BCDEdit will return an alphanumeric identifier for this entry that I will refer to as {ID} in the remaining steps. You’ll need to replace {ID} by the actual returned identifier. An example of {ID} is {d7294d4e-9837-11de-99ac-f3f3a79e3e93}
bcdedit /set {ID} device partition=c: bcdedit /set {ID} path \linux.bin bcdedit /displayorder {ID} /addlast bcdedit /timeout 30
And that’s it. You’re good to go. Now, you can boot up both windows and linux and you haven’t sacrificed any of the nice things that came with the system. One-key rescue still works and so does the raid0 array. All in all, an ideal solution.