force boot from multiple bootable virtual drives

Discussions about using Linux guests in VirtualBox.
Montagar
Posts: 11
Joined: 25. Sep 2012, 20:09

force boot from multiple bootable virtual drives

Post by Montagar »

Running Alpine Linux as a guest with two bootable virtual drives on the SATA virtual controller. I need to force the system to boot from a particular virtual drive but nothing seems to work. The SATA port number doesn't change which drive boots... sometimes it will boot from the drive on port 0 and sometimes it will boot from port 1. I can't seem to find a way to guarantee which drive it boots from. Under Linux, I have one drive configured as sda and the other as sdb so I can see which one has been used to boot.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: force boot from multiple bootable virtual drives

Post by fth0 »

Please reproduce the boot from SATA port 1 (which perhaps is unexpected behavior), provide a (zipped) VBox.log file from that run, and I'll tell you how to work around the issue. ;)

Just kidding, I'll tell you anyway (but please provide the log file nonetheless):

VirtualBox only boots from the first 4 IDE, SATA and SCSI devices. Add a few additional virtual DVD drives to the SATA controller, so that you have at least 5 devices, and move one of the virtual hard disks to the highest SATA port of the 5 devices. ;)
Montagar
Posts: 11
Joined: 25. Sep 2012, 20:09

Re: force boot from multiple bootable virtual drives

Post by Montagar »

Thanks for the reply. Unfortunately that appears to only work if there is only one bootable virtual hard drive. It is true that If you have just one virtual drive on SATA 4 (with drives on the lower SATA ports) it won't boot but I put the second drive at SATA 6 with the drive I want to boot from on SATA 0 (with DVD drives on 1-5) and it still boots from the drive on SATA 6. I remote the virtual hard drive from SATA 6 and the one attached to SATA 0 boots but as soon as I put the other drive back (SATA 6) that's the one that boots.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: force boot from multiple bootable virtual drives

Post by fth0 »

I successfully tested my suggestion myself before writing about it. Please provide a (zipped) VBox.log file from a VM run with this special configuration. Shut down the VM before copying the log file, so that the statistics are complete.
Montagar
Posts: 11
Joined: 25. Sep 2012, 20:09

Re: force boot from multiple bootable virtual drives

Post by Montagar »

I have uploaded the log file.
Attachments
VBox-post.log
(89.42 KiB) Downloaded 6 times
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: force boot from multiple bootable virtual drives

Post by fth0 »

As I wrote, I'm also interested in the statistics, and if you zip the log file, it won't be too large to attach it to the post. The statistics show how many sectors are read/written from/to each virtual hard disk ...

As an educated guess, which boot loader or boot manager do you use (GRUB?), and how does it search for the bootable partitions (by UUIDs)? If alpine_backup.vdi began as a copy of alpine.vdi, you may have shot yourself in the foot. ;)
Montagar
Posts: 11
Joined: 25. Sep 2012, 20:09

Re: force boot from multiple bootable virtual drives

Post by Montagar »

Sorry about that, I have now uploaded the complete file zipped.

Alpine uses Syslinux for the bootloader. When I was researching this from the linux side, everything seemed to point to BIOS settings so that is why I turned to posting here. I was hoping to find a way to have virtualbox force the boot order.

You are correct that alpine_backup.vdi began as a copy of alpine.vdi but that UUID has been changed, although I need to go back and check that.
Attachments
VBox-post.zip
(29.41 KiB) Downloaded 4 times
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: force boot from multiple bootable virtual drives

Post by fth0 »

Just in case, I'm talking about the Linux-specific UUIDs, not the VirtualBox-specific UUIDs.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: force boot from multiple bootable virtual drives

Post by fth0 »

Well, here's something for you to figure out: ;)
VBox-post 2.log wrote:
00:01:41.462541 /Public/Storage/AHCI0/Port0/BytesRead    27244032 bytes

00:01:41.462576 /Public/Storage/AHCI0/Port5/BytesRead   107935744 bytes
00:01:41.462578 /Public/Storage/AHCI0/Port5/BytesWritten  2418688 bytes
A professional tip: If you start the VM from within a terminal using VirtualBoxVM --startvm "alpine" --debug, you can unpause and pause the VM and watch the statistics live.
Montagar
Posts: 11
Joined: 25. Sep 2012, 20:09

Re: force boot from multiple bootable virtual drives

Post by Montagar »

If I shutdown and restart the VM a few times eventually I get the following and the VM boots from SATA 0

Code: Select all

00:00:57.295651 /Public/Storage/AHCI0/Port0/BytesRead 121007616 bytes
00:00:57.295655 /Public/Storage/AHCI0/Port0/BytesWritten  2189312 bytes

00:00:57.295720 /Public/Storage/AHCI0/Port5/BytesRead 13651968 bytes
It appears to be random with no set number of restarts and if I restart the VM after it boots correctly, it changes back to SATA 5 and so on.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: force boot from multiple bootable virtual drives

Post by fth0 »

Good candidates for a random selection are all bus or device enumerations, be it in VirtualBox or in Syslinux. I'd try to stop inside the Syslinux boot menu and investigate from which device Syslinux has been loaded, either from within Syslinux or with the VirtualBox debug mode. Depending on the results, you could then investigate what happened before or after the Syslinux boot menu.

BTW, you don't need any debugging experience for the VirtualBox debug mode. After executing the command that I provided, you simply unfold the statistics in the right window, and (un-)pause the VM in the VM window's menu, just like when running without the debug mode.
Montagar
Posts: 11
Joined: 25. Sep 2012, 20:09

Re: force boot from multiple bootable virtual drives

Post by Montagar »

Thanks for your help. I will see what I can come up with using the debug mode.
milverton
Posts: 48
Joined: 17. Apr 2022, 22:25

Re: force boot from multiple bootable virtual drives

Post by milverton »

Just looking at this topic in connection with another issue, and finding it prompts a question. Quoting from your second post (19. Apr 2022, 22:36)...
Montagar wrote:...I remove the virtual hard drive from SATA 6 and the one attached to SATA 0 boots but as soon as I put the other drive back (SATA 6) that's the one that boots.
Reading this sentence it seems that with this arrangement, namely virtual hard drives at both SATA 0 and SATA 6, effectively "bookending" or "wrapping" the other attached devices, the randomness you described in your first post is gone; and that the boot from SATA 6 is reliable, with things set up this way. Am I reading this correctly? If so it's definitely something useful to know, even if for now unexplained. Or was it merely a passing phase?
Montagar
Posts: 11
Joined: 25. Sep 2012, 20:09

Re: force boot from multiple bootable virtual drives

Post by Montagar »

milverton wrote:Just looking at this topic in connection with another issue, and finding it prompts a question. Quoting from your second post (19. Apr 2022, 22:36)...
Montagar wrote:...I remove the virtual hard drive from SATA 6 and the one attached to SATA 0 boots but as soon as I put the other drive back (SATA 6) that's the one that boots.
Reading this sentence it seems that with this arrangement, namely virtual hard drives at both SATA 0 and SATA 6, effectively "bookending" or "wrapping" the other attached devices, the randomness you described in your first post is gone; and that the boot from SATA 6 is reliable, with things set up this way. Am I reading this correctly? If so it's definitely something useful to know, even if for now unexplained. Or was it merely a passing phase?
When I add the second drive it usually boots from that one. However, that is not always the case and it will become random on subsequent reboots with both drives attached anyway. So unfortunately there is no guarantee as to which drive will boot when they are both attached.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: force boot from multiple bootable virtual drives

Post by fth0 »

Were you able to discover if the randomization takes place in VirtualBox or in Syslinux?
Post Reply