man in the mirror

with all the new storage available in the nas i've started reorganizing things. i also got a new m2 drive to replace the two 1TB drives in the gaming rig.

the story of this particular windows partition is an interesting one. see i used to have all of my computers and servers linux based. i tried all the games available on steam in linux and the ones that werent available i tried to load in steam in wine. that only kinda worked and only served as an exercise in patience and fortitude. i also wanted to use lightroom for photograpy and lightroom in wine was unbearable. i first attempted to load windows into a vm running in oracle virtual box. this kinda worked, it just couldnt use all of the power of the physical host. i eventually arrived at a decision to try to dual boot my box with linux and grub as the main partition and boot loader.

dump vm to raw image

i first had to dump the vm to a raw image outside of virtualbox. there is a built in vboxmanage command for this. interesting though, the 'internalcommands' option  is not mentioned when you do vboxmanage /? but you can do vboxmanage internalcommands /? and it will show you more details available

VBoxManage.exe internalcommands converttoraw C:\path\to\your\vm\image.vdi C:\path\to\output\raw\image.RAW

from here you should now have a raw image of the disk in a vm

boot to usb and resize partitions

to accomplish the dual boot i booted the box with a usb drive imaged with linux mint. there are a number of different usb images you can use other than linux mint, i just knew it had gparted and dd available on it. ive sometimes used System-RescueCD as it has a lot of fun utilities on it too.

after you made your raw image and booted to a usb disk you'll have access to your main disk that you dont want to damage accessible. next youll want to open up gparted and find your destination disk for the new image. im not going to go into detail on how to use gparted, but youll want to choose the drive in the top right drop down, then select the partition you want to resize to make room for the new drive. not there is a risk of data loss here so dont resize the partition smaller than how much data you have on the disk. theres still a risk there even if you dont resize smaller so make a backup image of the main disk youre modifying before you do any of this.

after resizing the partition with gparted you now have some unformatted space to play with.

throw the image on the new partition

ok so now you have an open unformatted partition and a raw image, now you need to find the partition names to use so you can run the command to take the image and write it to the open partition. if youve got a gui you can look at gparted to find the disk names or the common disk management that usually is available in live disks. you will likely find something like /dev/sda or something like that as you recognizable drive with your other partitions. on there you can find the names for other partitions which will look like /dev/sda3, it might look different depending on your existing layout but generally the /dev/sda will be the entire drive and the number is specifying the partition number.

once you find the drive you want to send data to you need to find where your raw image is you can prep the command to actually send the image to the partition. this is done with a binary called dd, its a wonderful little thing.
the command will look like this

dd if=/mnt/location/of/raw.img of=/dev/sda3 status=progress

dd is the binary, if is the "input file", of is the "output file", and the status=progress means it will show you a nice little summary while its moving the data

you can see a lot more of the things dd can do by running

man dd

das boot

after youve got that image transferred youll need to tell whatever it is that you have as your boot loader that theres another OS on the drive to pick from. if youre using grub this is one way. I used bootrepair to detect OSs on the existing disk and this picked up windows in the boot menu

now what?

this was how my box was set up for a bunch of years, boot to linux for daily driver and then boot to windoze when i needed to do editing and offloading for photography or wanted to play some windows based games. this was fine for quite a while until i wanted to get into some more games and started doing a lot more photography. eventually the linux partition started having some unrelated booting issues so the default to windoze was set. after this i picked up a laptop, some vr gear and an egpu case to run an rtx 2060. the aging desktop pc became a fleeting thought... until i wanted more from the valve index. I spec'd out a much more up to date rig with an m2 slot. i remained on the two ssd's for a while before picking up a decent m2 when prices dropped recently. grabbed a samsung 990 pro off amazon, slapped that dude on the board and started running a backup of my drives.

expand space and dump disk images to drive

copying the first drive was going to be easy, the second drive i had to look up. to get the OS and primary drive mirrored over was a simple dd command like i did earlier. boot to a usb linux os and determine your new drive and old drive names. in the below /dev/sda is the old drive and /dev/sdb is the new drive

dd if=/dev/sda of=/dev/sdb status=progress	

after that is complete you should have the first disk imaged onto the new drive. so what if i had a second drive that i wanted to show up on the same new drive. you cant just run the dd command again or it will put all the data starting at the beginning. so we have to tell dd to seek to a specific spot and start writing the image. but whats that spot? open up gparted, find your disk, right click on the empty partition and click information. listed somewhere around there you should see the "First Sector" value. thats what you need. from there its just

dd if=/dev/sdc seek=numberFromGparted of=/dev/sdb status=progress

where /dev/sdc is the secondary drive and /dev/sdb is the new drive that was used in the previous step.

time to check and see if it will boot!

well it didnt. i ended up having to boot to a windows recovery disk and use bootrec to let windows fix things.

bootrec /fixmbr
bootrec /scanos
bootrec /rebuildbcd

after that it still wouldnt work.

I then used bcdedit to try and rebuild some of the boot. and because this old partition still had a system information partition that was somewhat small that reminded me that this partition might still be set for mbr instead of gpt. so lets nuke that and then create a new one

del c:\boot\bcd
bcdedit /createstore c:\boot\bcd.tmp
bcdedit /store c:\boot\bcd.tmp /create {bootmgr} /d "Windows Boot Manager"
bcdedit /import c:\boot\bcd.tmp
bcdedit /set {bootmgr} device partition=c:

After this still had issues... but wait, since this was an mbr boot still i remembered that the bios was still set to secure boot. set that back to legacy boot turning off UEFI and windoze came right up like a real live boy!

convert to UEFI from MBR

i feel like this should be a separate article... maybe ill get to this next