0

Suppose I have a computer that was once a purely Windows desktop, whose disk contained at least the usual EFI System Partition (the ESP) and the Windows partition itself. Suppose that one day I decided to get rid of it for a better OS (namely Linux), /bin/dd'd the Windows partition to an external disk (i.e. a verbatim bit-by-bit, sector-by-sector copy, probably to some massive file that I probably called Windows.img), scrubbed the original disk clean by /bin/dd'ing the whole thing with zeroes, and somehow installed some Linuxes onto it.

But now let's say I want to smush Windows back into the disk as a second (not actually second, as I have multiple Linuxes on here) operating system. Now what? I may or may not have kept a backup of the original ESP with the original bootloader inside, but assume that I did. Is there any way I can arbitrarily make some room and create a partition somewhere, /bin/dd the Windows partition to it, and somehow boot into it like old times? Does rEFInd help at all, here? Also, what if I, for some reason, forgot to backup the original ESP?

4
  • This question cannot be answered unless you tell us if you do or do not have that EFI data. Please edit your question and provide us the vital information necessary to answer this question. – Ramhound Nov 15 '18 at 1:02
  • Assume that I do, as I tend to archive as much as I can. I don't actually know, myself, as the disk is not physically available to me at the moment. – Mona the Monad Nov 15 '18 at 1:03
  • You can use DISM to apply an.WIM image to the partition, modify your current bootloader, to boot into the Windows bootloader (which will boot into your Windows installation). This prevents the Windows installer from modifying your current bootloader. A relatively simple process if you have the required data. – Ramhound Nov 15 '18 at 1:04
  • @Ramhound DISM seems to be a Windows utility, and I do not use Windows. Is there something I can do from Linux, perhaps with tools like efibootmgr and dd and whatnot? Unless you mean use a Windows installer (e.g. a CD) to "fix" the partition. – Mona the Monad Nov 15 '18 at 1:08
0

Is there any way I can arbitrarily make some room and create a partition somewhere,

If you want to make some unallocated space on a disk entirely occupied by Linux, then you'd use Linux tools to shrink the Linux filesystem, and then the partition, resulting in unallocated space to the right of the shrunk partition.

The usual one-click method for this is GParted from a live CD.

/bin/dd the Windows partition to it, and somehow boot into it like old times?

Yes.

I only wanted to know if Windows would play nice with being moved around.

It varies. Windows doesn't care about absolute offsets, but there have been occassions of it being picky about its partition number (e.g. originally partition 2, now partition 4 on the exact same disk).

Does rEFInd help at all, here?

It's just an EFI boot menu that starts either vmlinuz.efi or Microsoft\Bootmfgw.efi of your choice. It won't resize your partitions for you, and it won't have a special way of booting Windows that you wouldn't have otherwise.

Also, what if I, for some reason, forgot to backup the original ESP?

Boot from the matching Windows installation medium and use bcdboot to reinstall the Windows bootmanager into your current ESP.

1
  • Well, I'm certainly not unfamiliar with partition management. I only wanted to know if Windows would play nice with being moved around. Might be a while until I can actually try stuffing it back in. – Mona the Monad Nov 15 '18 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.