On January 14th 2020, Microsoft ended support for Windows 7. To avoid any issues in the future, I decided to switch to Windows 10. The laptop that would be affected was my HP Envy j120 which has 2 slots, giving it the capability of containing 2 separate hard drives. This means I could potentially have 2 different operating systems on my laptop. After the ‘2nd hard drive kit’ (which included a SSD cable and hard drive caddy) arrived, I installed Windows 10 on one hard drive & CentOS 7 on the other hard drive. I wanted the primary operating system to be CentOS 7 so I installed it on ‘hard drive 1’. I then disconnected the cable for hard drive 1, installed the second hard drive and attached it to the cable that I connected to the ‘hard drive 2’ slot on the motherboard. With hard drive 1 disconnected, I powered up the laptop and installed Windows 10 on the second hard drive.
At this point there were technically 2 operating systems on the laptop but I will need to allow them to both appear in a selection menu when I turn the laptop on. I then reconnected hard drive 1 and entered a series of commands to determine the location of the boot partition (where the Windows operating system occupies) on the second hard drive. I will need that information when I edit the bootloader file in CentOS.
The output of the first command (fdisk -l) is shown below:
Notice there are two hard drives listed – it helps a lot to easily identify the hard drives if they are different in size 🙂 The size of the hard drive where Windows 10 was installed is 480Gb so /dev/sdb is the drive I am interested in. So now I need to know the boot partition of the Windows hard drive. The output of those commands is shown below. I placed focus on the Windows hard drive which is /dev/sdb by entering the command ‘parted /dev/sdb’ and asked for a list of the partitions ‘print’. Notice under the ‘Flags’ column a partition is labeled as ‘boot’.
I then edited a file located in ‘/etc/grub.d’ and added ‘Windows 10’ as an entry in that file along with the location of the boot partition (we got this information from the previous commands) which in my case was ‘(hd1,1)’.
I then had to issue a command to make the entry into the bootloader – ‘grub2-mkconfig –output=/boot/grub2/grub.cfg’
That’s it, I rebooted my laptop and I could see the second operating system in the boot menu. My 5 year-old laptop is now running the latest versions of Windows and CentOS!