Just some Internet guy

He/him/them 🏳️‍🌈

  • 0 Posts
  • 4 Comments
Joined 2 years ago
cake
Cake day: June 25th, 2023

help-circle
  • 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 up pacstrap 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.


  • 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:

    qemu-img create -f qcow2 YourDiskImageName.qcow2 300G
    

    Then you can make the image behave like a real disk using qemu-nbd:

    sudo modprobe nbd
    sudo qemu-nbd -c /dev/nbd0 YourDiskImageName.qcow2
    

    At this point, the disk image behaves like any other disk at /dev/nbd0.

    From there create a partition table, you can use cgdisk or parted or even the GUI GParted will work on it.

    And finally, copy the partition over with dd:

    sudo dd if=/dev/sdb3 of=/dev/nbd0p2 bs=4M status=progress
    

    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:

    sudo qemu-nbd -d /dev/nbd0
    

  • I think it counts. You always have the option of taking your data with you and go elsewhere which is one of the main points of self-hosting, being in control of your data. If they jack up the prices or whatever, you just pack up, you never have to pay or else.

    Also hosting an email server at home would be an absolute nightmare, took me 10+ years to get that IP rep and I’m holding on to it as long as I can.

    I have a mix of it: private services run at home, public ones run on a bare metal server I rent. I still get the full benefits of having my own NextCloud and all. Ultimately even at home, I’d still be renting an Internet connection, unless you have a local only server.