I have a laptop (ASUS harman/kardon) that has two drives, a small SSD, and 1TB HDD. It came with Windows installed on the SSD, and I installed linux on the HDD.
Since I almost exclusively use the linux partition, is there any way to simply switch the linux partition over to the other drive and put Windows on the HDD (I don't want to lose my windows license).
I would like to keep the linux image how it is, I'm fine if I have to restore windows from scratch.
I understand that I may need extra space, and I have a large enough external drive to accommodate both partitions.
So is it possible to swap linux to the SSD and Windows to the HDD without having to start over on both?
Attempt 1
I shrank the linux partition on the HDD to make room for a windows partition. I then created a windows install disk to install Windows on the HDD. Unfortunately, this install disk picks up the other Windows install. It also only gives me an "Install now" button, which is very useless as I have no clue where it will install.
Looks like I have to physically remove the SSD, save my linux stuff from the HDD somewhere else, and then run the windows install and let it take control (because what kind of user needs control of the operating system anyways?). Any other ideas? Is there a way to force Windows to install somewhere specific?
Update
I made a partition on the HDD and managed to install windows on it. I then reformatted the SSD (leaving the boot partition intact) and used rsync (from the linked question) to copy all the data from the old drive to the new drive.
I then ran sudo grub-install
, but on boot, grub picks up only the installation on the HDD (and also windows boot manager, which it always has).
Am I missing a step? Do I somehow need to run grub-install when booted from the new 'install'? If so, how do I boot from it?
Edit: Looks like I need to chroot to the new 'install'. However, when doing this, I lose the disk (/dev/nvme0n1) that I want to install grub onto. Is there a way to set up grub so that when it boots and this disk exists (I know it will), it will work?
Answer
So I finally managed to do this, and it definitely took a lot of work but it's done and it seems to be running fine (and much faster). The only thing left is to deal with swap, which is still on the HDD.
Step 1:
Make a linux live disk, boot into it and shrink the HDD to leave enough room for a Windows install (Don't worry about exact sizing as the partitions will eventually be resized). I used a linux live disk because I like gparted, and I couldn't do it with my running linux system since that drive was mounted and couldn't be resized.
Note - You can't move the windows partition after you install Windows. I made the assumption that you could. This means that if the linux partition is at the beginning of the HDD (as I had it), that space ends up wasted. I recommend moving everything to the end of the drive, and then putting the windows partition at the beginning, as it can always be expanded (this takes quite a bit of time, however)
Step 2:
Make a Windows boot disk - can be done on the windows site. Ideally, this would be on a second flash drive since when (not if) something goes awry and you have to start over, you don't have to make a new linux disk.
Step 3:
Install windows, click the "Install Now" and then go through until it lets you pick a partition, pick the partition you created when resizing the HDD(it doesn't even have to be formatted, windows will do its thing with free space on a drive). Let windows do its thing. When you log into the new windows install for the first time, it will verify the license key.
Step 4:
Copy everything you want from the original windows install.
Step 5:
Boot back into linux from your live disk (not the one installed on the HDD). Destroy the SSD and make an ext4 partition. Make sure not to touch the FAT32 partition at the beginning, this is the boot partition and it's important.
Step 6:
rsync everything over to the new drive. This involves mounting the old disk and new disk and syncing everything over (some things may fail, like /proc/devices, that's fine, but make sure you're root). This looks like:
mount /dev/sda2 oldDisk/ #the existing linux partition
mount /dev/nvme0n1p2 newDisk/ #The new, empty partition on SSD
rsync -avz oldDisk/ newDisk
Step 7:
Boot back into your original linux install (this may work on the live flash drive as well).
mount /dev/nvme0n1p2 /mnt #Mount the new drive somewhere
mount --bind /dev /mnt/dev/
grub-install --boot-device=/mnt /dev/nvme0n1 #note this is the whole device, not just the patition (akin to /dev/sda)
update-grub #so the new stuff is picked up.
This is outlined here.
That should be everything. I've since cleaned up the linux install. Windows boot manager looks like it's finally happy with itself (I guess a few reboot cycles is all it takes).
It leaves around the old linux install, which I've yet to clean up. I also don't know how to clean up the windows boot manager because that also got a little messed up with the missing windows installs, but at least it boots.
No comments:
Post a Comment