this post was submitted on 06 Apr 2025
30 points (94.1% liked)
Linux
53032 readers
376 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
What you're trying to do is called a P2V (Physical to Virtual). You want to directly copy the partition as going through a file share via Linux will definitely strip some metadata Windows wants on those files.
First, make a disk image that's big enough to hold the whole partition and 1-2 GB extra for the ESP:
Then you can make the image behave like a real disk using qemu-nbd:
At this point, the disk image behaves like any other disk at
/dev/nbd0
.From there create a partition table, you can use
cgdisk
orparted
or even the GUI GParted will work on it.And finally, copy the partition over with
dd
:You can also copy the ESP/boot partition as well so the bootloader works.
Finally once you're done with the disk image, unload it:
I wasn't expecting a Step-by-Step, amazing, Thanks for your effort!
Metadata is something I would've never thought of but besides that seems like my guess wasn't that far off which im happy for
I also wanted to put an emphasis on how working with virtual disks is very much the same as real ones. Same well known utilities to copy partitions work perfectly fine. Same cgdisk/parted and dd dance as you otherwise would.
Technically if you install the
arch-install-scripts
package on your host, you can even install ArchLinux into a VM exactly as if you were in archiso with the comfort of your desktop environment and browser. Straight uppacstrap
it directly into the virtual disk.Even crazier is, NBD (Network Block Device) is generic so it's not even limited to disk images. You can forward a whole ass drive from another computer over WiFi and do what you need on it, even pass it to a VM boot it up.
With enough fuckery you could even wrap the partition in a fake partition table and boot the VM off the actual partition and make it bootable by both the host and the VM at the same time.
Learning to use QEMU I started to grasp those possibilities actually, now getting these tips I do feel like I could dive into lots of "sandboxing" and generally be able to try anything with it, my only constrain now shall be disk space