I have a persistent USB drive installation that I've been using to boot an old Intel MacBook Air for some time now. I'll soon be retiring the old MacBook, as my work is issuing me a new M2 Mac laptop. Obviously, I won't be able to boot directly off the flash key any more, since Apple Silicon isn't a supported architecture. However, I would still like to be able to use boot the flash key MX install on my new Mac using VirtualBox.
I've found a number of guides online for booting a USB key install in VirtualBox on the Mac, but most if not all of them pertain to live installation media rather than persistent Linux installations. I was wondering if there are any tips, tricks, or concerns that I should be aware of if I try setting up VirtualBox to boot my MX flash key on the Mac, especially if I still want to be able to use the flash key to boot other physical hardware later on. I don't want to lose any data or banjax any of my MX system configurations that will be important in booting up a physical machine in the future.
Thanks so much!
Question on booting a persistent USB installation in Virtualbox
Re: Question on booting a persistent USB installation in Virtualbox
These are from my own notes.
Adapted from https://www.pendrivelinux.com/boot-a-us ... irtualbox/
See also: https://askubuntu.com/questions/693719/ ... virtualbox
1) Ensure VirtualBox is installed, but NOT RUNNING. Mount the bootable USB / HDD.
2) Determine the drive letter ( sdx ) of your USB – eg run sudo fdisk -l
The result appropriate to the target USB might look something like:
Disk /dev/sdb: 28.7 GiB, 30752636928 bytes, 60063744 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos ( or msdos / mbr / / gpt )
Disk identifier: 0xf93371a0
OR, run the following in the terminal lshw -short -class disk,volume
Note the emmc disc drives will have the nomenclature /mmcblk0.
3) The VboxManage tool is used to create a small VMDK file which allows the HOST OS to access the USB GUEST as if it were an installed drive.
Run this script in a terminal in the directory where you want the VMDK file to be stored:
sudo vboxmanage internalcommands createrawvmdk -filename usb.vmdk -rawdisk /dev/sdx
Or, in general ... -filename /path/to/where/the/vmdk/is_to_be/stored/usb.vmdk …
“usb” is the label for the .vmdk file and you can label it in any suitable way without white spaces.
This is necessary if you use more than one bootable drive.
4) Start VirtualBox.
Click on New to create a new Virtual Machine.
5) When prompted for a Virtual Hard Disk, select use existing hard disk,
Then browse to the directory where the path points to and select usb.vmdk
6) Once you've finished creating your New Virtual Machine, click Start as per usual.
Choose Linux as the OS, and the variant from the drop-down box as usual.
If the Vbox does not find the OS, close the machine down and change the EFI flag:
Settings –> System –> Enable EFI ( Special OSs only )
7) To change USBs, unmount first.
It is possible that the any other USB plugged in will end up with a different drive letter, in which case the script in (3) will need to be run again.
Other related References
What is a VMDK file? (and how to load one in Windows)
https://techathlon.com/how-to-run-a-vmd ... irtualbox/
How to load a VMDK file in Linux: https://osxdaily.com/2019/08/12/open-vmdk-virtualbox/
Thick & Thin Provisioning of image disks prior to Virtualization
https://www.nakivo.com/blog/thick-and-t ... ifference/
Main HDD OS as GUEST where the USB contains the HOST
https://opensource.com/article/21/1/vir ... dows-linux
.
Adapted from https://www.pendrivelinux.com/boot-a-us ... irtualbox/
See also: https://askubuntu.com/questions/693719/ ... virtualbox
1) Ensure VirtualBox is installed, but NOT RUNNING. Mount the bootable USB / HDD.
2) Determine the drive letter ( sdx ) of your USB – eg run sudo fdisk -l
The result appropriate to the target USB might look something like:
Disk /dev/sdb: 28.7 GiB, 30752636928 bytes, 60063744 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos ( or msdos / mbr / / gpt )
Disk identifier: 0xf93371a0
OR, run the following in the terminal lshw -short -class disk,volume
Note the emmc disc drives will have the nomenclature /mmcblk0.
3) The VboxManage tool is used to create a small VMDK file which allows the HOST OS to access the USB GUEST as if it were an installed drive.
Run this script in a terminal in the directory where you want the VMDK file to be stored:
sudo vboxmanage internalcommands createrawvmdk -filename usb.vmdk -rawdisk /dev/sdx
Or, in general ... -filename /path/to/where/the/vmdk/is_to_be/stored/usb.vmdk …
“usb” is the label for the .vmdk file and you can label it in any suitable way without white spaces.
This is necessary if you use more than one bootable drive.
4) Start VirtualBox.
Click on New to create a new Virtual Machine.
5) When prompted for a Virtual Hard Disk, select use existing hard disk,
Then browse to the directory where the path points to and select usb.vmdk
6) Once you've finished creating your New Virtual Machine, click Start as per usual.
Choose Linux as the OS, and the variant from the drop-down box as usual.
If the Vbox does not find the OS, close the machine down and change the EFI flag:
Settings –> System –> Enable EFI ( Special OSs only )
7) To change USBs, unmount first.
It is possible that the any other USB plugged in will end up with a different drive letter, in which case the script in (3) will need to be run again.
Other related References
What is a VMDK file? (and how to load one in Windows)
https://techathlon.com/how-to-run-a-vmd ... irtualbox/
How to load a VMDK file in Linux: https://osxdaily.com/2019/08/12/open-vmdk-virtualbox/
Thick & Thin Provisioning of image disks prior to Virtualization
https://www.nakivo.com/blog/thick-and-t ... ifference/
Main HDD OS as GUEST where the USB contains the HOST
https://opensource.com/article/21/1/vir ... dows-linux
.
- dolphin_oracle
- Developer
- Posts: 22400
- Joined: Sun Dec 16, 2007 12:17 pm
Re: Question on booting a persistent USB installation in Virtualbox
If you have an iso with the same kernel as the usb, you can start boot from the iso and hand off to the live usb with the from=hd boot code. That’s what I usually do.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
lenovo ThinkPad X1 Extreme Gen 4 - MX-23
FYI: mx "test" repo is not the same thing as debian testing repo.
Re: Question on booting a persistent USB installation in Virtualbox
I just wanted to say thank you to both of you for such rapid and thorough responses. This is tremendously helpful. I will report back once I have the new machine and get everything up and running (or, of course, if I fail miserably and have further questions
).
But whatever the case I’m really grateful for your help. My favorite thing about MX is the community.
But whatever the case I’m really grateful for your help. My favorite thing about MX is the community.
Re: Question on booting a persistent USB installation in Virtualbox
I can usually boot a usb flash drive containing an MX-Live-usb system by setting the VirtualBox virtual machine setting for system to Enable EFI and giving the mounted USB drive to VirtualBox VM with the USB icon on the VM "task bar." I don't do any creating of files or special directories other than making a VM for EFI booting of a live-usb with the right settings in the "Oracle VM VirtualBox Manager." I've been able to do updates, save persistence, and even remaster running this way. There is no permanent storage of this on the hard drive other than the permanent dummy LiveUSB_EFI VM I set up for this purpose.
I don't know how or why it works, but I got to this point through trial and error. VirtualBox is pretty smart (invasive?) and if the flash drive is mounted and available to VirtualBox, it seems to look for EFI boot files and will find them. When booting the VM with EFI set, it runs a little EFI program (??) where I either press escape or let it time out, then type exit, then a menu appears and one of the items will be Boot Manager, from which you can see and select your flash drive.
I don't know how or why it works, but I got to this point through trial and error. VirtualBox is pretty smart (invasive?) and if the flash drive is mounted and available to VirtualBox, it seems to look for EFI boot files and will find them. When booting the VM with EFI set, it runs a little EFI program (??) where I either press escape or let it time out, then type exit, then a menu appears and one of the items will be Boot Manager, from which you can see and select your flash drive.
Re: Question on booting a persistent USB installation in Virtualbox
Reporting back! I used @figueroa's method on my Intel ThinkPad to successfully boot into a persistent USB install in VirtualBox. However, I wasn't able to do the same on the new M3 MacBook Air. The issue turned out to be not with the method, but with the fact that the Apple Silicon version of VirtualBox is very, very beta at the moment.
Thank you all, regardless, for your help! Being able to boot into my USB install via VirtualBox on my Intel machine still gives me a lot more flexibility than I had before. Greatly appreciated.
Thank you all, regardless, for your help! Being able to boot into my USB install via VirtualBox on my Intel machine still gives me a lot more flexibility than I had before. Greatly appreciated.