In 2018, I used VirtualBox to upgrade a hard drive to be used in my Tivo. It worked great and shortly after that, I used the same technique to install Windows XP on a solid-state drive (SSD) for use in another machine and then Mageia on another drive destined for anoter machine.
I found myself in need of the same proceedure and pulled up my old page and found that Oracle had updated the command involved. The one on my old page,
$ VBoxManage internalcommands createrawvmdk -filename /path/to/source_sdk.vmdk -rawdisk /dev/sdk
has been superseded by:
$ VBoxManage createmedium disk --filename=VirtualBox VMs/Tiny10-Install/Tiny10.vmdk --variant=RawDisk --format=VMDK --property RawDrive=/dev/sdd
This change allows some nice new features that might be useful to me in the future, but it did take me a while to figure things out, especially since the solutions offered to the problems I encountered were mostly for Debian-based distros (and many were ancient posts) and had no real applicability to Mageia Linux, hence my documentation here.
One of the first problems, an annoyance really, was that VirtualBox creates a /home directory for the virtual machine files that, by default, has a space in the name. That's fine for MS Windows, but annoying for Linux. That issue can be addressed in several ways. The most common on the command line is to enclose the path entirely in quotes, or to escape the space with a backslash. I prefered in this case to create a symlink to the name-with-a-space with a name-without-a-space so any commands on the command line don't have an issue. Interestingly, Oracle does provide an option under File>Preferences to create a custom directory instead of "VirtualBox VMs" with a space; you just need to set that up manually before you create you very first virtual machine. Why can't Oracle just eliminate the space, at least for their Linux version?
As before, I connected the SSD and looked at dmesg to see that my system identified it as /dev/sdd.
After I changed to the virtual machine's root directory (to make paths simpler), the new incantation for me was:
$ VBoxManage createmedium disk --filename=tiny10.vmdk --variant=RawDisk --format=VMDK --property RawDrive=/dev/sdd
But because of my many errors to get to that point, I had some other issues pop up, and here are the solutions:
1. Fix File and Directory Ownership
$ sudo chown -R hoyt:hoyt /home/hoyt/VirtualBoxVMs/Tiny10-Install/2. Update File Permissions
Set directory permissions:
$ chmod 755 "/home/hoyt/VirtualBoxVMs/Tiny10-Install/
Set file permissions:
$chmod 644 /home/hoyt/VirtualBoxVMs/Tiny10-Install/Tiny10.vmdk
3. Check User Groups
Add yourself to the group -- it may not yet exist:
$ sudo usermod -aG vboxusers hoyt
4. Our Special Case: Raw Disk Access
Since this is a special case of accessing a physical drive instead of a virtual drive, add the user to the disk group:
$sudo usermod -aG disk hoyt
And grant temporary permission to the drive:
$ sudo chmod 666 /dev/sdd
After doing all this, log out and log back in again to work the magic. After you move the drive and everything is OK, just delete the VM you used. Some of these steps may not be necessary for you, but they did fix all my issues.
When you do install MS Windows on a drive that will be moved to another machine, you must stop the install process JUST AS it reboots while running in the virtual machine. Windows continues its install on reboot that needs to be tailored to the machine it will eventually be run on.
RESOURCES
Use Virtualbox to mount drives and transfer data for Tivo Disk Upgrades
Comments