VirtualBox doesn't write on the original EFI system partition (ESP)

Discussions related to using VirtualBox on Windows hosts.
Post Reply
ecccc3
Posts: 20
Joined: 1. Aug 2022, 03:02

VirtualBox doesn't write on the original EFI system partition (ESP)

Post by ecccc3 »

Hi

Because win32-loader.exe 0.10.4 and 0.10.6 doesn't work ( https://forums.debian.net/viewtopic.php ... 9acbf15fd7 ) I tried to physically install Debian on my PC's hard disk drive with Windows 10 , firmware-testing-amd64-netinst.iso , VirtualBox and the command lines :

cd C:\Program Files\Oracle\VirtualBox
VBoxManage internalcommands createrawvmdk -filename "C:\Users\0\VirtualBox VMs\0\0.vmdk" -rawdisk \\.\PhysicalDrive0

// otherwise VirtualBox crash after continue " write the changes to disks? "
diskpart
sel disk 0
sel part 1
assign letter=b

everything works except GRUB isn't installed on the original ESP ( EFI system partition ) with EFI\Microsoft\Boot etc ( although e.g. win32-loader.exe 0.10.6 can write on it ) but installing GRUB on another ESP worked .
So VirtualBox can't write on the original ESP ? By a security lock ? Bug ? Is it possible to enable this ? By command line maybe ?

Thanks for your free and open source work .
Last edited by ecccc3 on 2. Aug 2022, 13:50, edited 1 time in total.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VirtualBox doesn't write on the original ESP

Post by mpack »

Cross posting is against forum rules, hence I have deleted your copy of this question posted to Window Guests. In future please just ask if you want us to move a topic.

You are describing an application of raw disk access. We don't usually help people with that since, as the user manual says, this is a dangerous experts-only feature. On Windows hosts access will be interfered with by Windows permissions (i.e. you need admin rights and the drive has to be offlined). Also, VirtualBox does not add data to make the drive bootable as is, you need to do that yourself.
ecccc3
Posts: 20
Joined: 1. Aug 2022, 03:02

Re: VirtualBox doesn't write on the original ESP

Post by ecccc3 »

Sorry for posting on Window Guests it was a mistake and I couldn't delete ( bug ? ) .
ecccc3
Posts: 20
Joined: 1. Aug 2022, 03:02

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by ecccc3 »

diskpart
sel disk 0
sel vol 4 // the ESP
offline vol

You may not take an OEM, ESP, or recovery partition offline.
The volume you have selected can not be taken offline.
Please select another volume and try again.

or bluntly

diskpart
sel disk 0
offline disk

Virtual Disk Service error:
Disk attributes may not be changed on the boot disk.

VirtualBox and its guest can't write on a partition if it's online for the host ? If yes why , I don't understand ?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by scottgus1 »

Diskpart errors and issues may be troubleshot using a Microsoft forum, as Diskpart is a Windows app.

Windows does not allow partitions alone to be taken offline for Virtualbox Raw Disk Access, only whole disks. And Windows does not allow the host's booting disk to be taken offline. So you may be stuck trying to offline the EFI system partition.

Lest we chase an "XY problem", could you please explain exactly what result you want? Based on your post and linked forum topic on debian.net, it appears that you want a basic Windows/Debian dual-boot. I'm not sure where Virtualbox comes in.
ecccc3
Posts: 20
Joined: 1. Aug 2022, 03:02

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by ecccc3 »

I put diskpart to show it can't offline the ESP .

Yes I just wanna install Debian in dual-boot with Windows 10 without using an external memory ( USB stick , DVD-RW ... ) , normally possible with win32-loader.exe ( and maybe terminal debootstrap , cdebootstrap on Windows Subsystem for Linux but I rather prefer here GUI ) which doesn't work and not fully processed on Windows ; I may effectively take a look on internet during the installation to get info on something .

And what about : VirtualBox and its guest can't write on a partition if it's online for the host ? If yes why , I don't understand ?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by scottgus1 »

ecccc3 wrote:what about : VirtualBox and its guest can't write on a partition if it's online for the host ? If yes why , I don't understand ?
Windows hosts require that the whole disk be offlined in Windows Disk Management for Virtualbox to do Raw Disk Access on the disk. And Windows will not allow the boot disk to be offlined. These are Windows requirements, not Virtualbox requirements.

As a result, if the partition of the disk you want to Raw Disk Access is on the boot disk, then you're stuck.
ecccc3
Posts: 20
Joined: 1. Aug 2022, 03:02

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by ecccc3 »

I wanted to add " normally possible with win32-loader.exe , setup.exe on a .iso Debian installer ( ... ) which don't " but too late to edit .
Windows hosts require that the whole disk be offlined in Windows Disk Management for Virtualbox to do Raw Disk Access on the disk.
Well no : as I said success to install Debian on my hard disk ( create ext2 , swap partitions and install Debian on ext2 ) with firmware-testing-amd64-netinst.iso on VirtualBox but failure : GRUB isn't installed on the original ESP : no EFI\debian\ , and I even edited some files on the ext2 with .iso's terminal ( nano /target/etc/passwd , nano /target/usr/lib/systemd/system/getty@.service ) .
The ext2 is offlined for Windows 10 but the ESP is online for it ; e.g. I can't open EFI\Microsoft\Boot\BCD on notepad " The process cannot access the file because it is being used by another process. " , also C: .
So no need to offline the whole disk , just a partition it works .
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by mpack »

ecccc3 wrote: And what about : VirtualBox and its guest can't write on a partition if it's online for the host ? If yes why , I don't understand ?
I think there's a misunderstanding here: because in fact VirtualBox itself is not writing to anything. VirtualBox calls host OS APIs to write to host devices. If the host OS refuses (which is what actually happens here) then of course there is nothing VirtualBox can do. Scott outlined the circumstances that would be needed for the host OS to stop refusing.
ecccc3
Posts: 20
Joined: 1. Aug 2022, 03:02

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by ecccc3 »

With a Debian live ( e.g. debian-live-11.4.0-amd64-xfce+nonfree.iso ) on VirtualBox I can only read the original ESP , C: , D: but I didn't succeed to mount the ext2 " can't read superblock on /dev/sda3 " ( I don't understand why ) but as I said I can read / write on it with firmware-testing-amd64-netinst.iso , and the Debian live " real " on a SD card I obliviously can read / write on all partitions so conclusion the theory :

If a partition is online for the host : partition is read-only for the guest .
If a partition is offline for the host : partition is read / write for the guest .

Is it true ? If yes why ( why Windows 10 would refuse to write on C: , D: ) ? Only for Windows hosts ? VirtualBox ?

Is it possible for VirtualBox that its guest can write itself on a online-for-the-host partition without calling host OS APIs ( like writing on the offline-for-the-host ext2 , knowing that Windows 10 doesn't support natively ext2 ) ? Maybe the writethrough option in Virtual Media Manager ( tried it doesn't work ) ?

And I didn't find how to offline the original ESP on Windows .
ecccc3
Posts: 20
Joined: 1. Aug 2022, 03:02

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by ecccc3 »

Well I finally discovered VirtualBox is ( according to Wikipedia ) a type-2 , hosted hypervisor , and I'd need a Windows host type-1 , native , bare-metal hypervisor : there's Hyper-V but the physical disk need to be offline for the Windows host for access ... Or maybe qemu but it seems to not support physical disk access ?
Is a Windows host ( native ? ) hypervisor which support online-for-the-host physical partition write access exists ?
Maybe updating VirtualBox ( I wrote a ticket https://www.virtualbox.org/ticket/21054 I can't edit viewtopic.php?f=9&t=106755 ) ? Because of a regression https://www.virtualbox.org/ticket/14425 ?

Sorry multiOS you replied my old reply when I was editing it .
Last edited by ecccc3 on 12. Aug 2022, 14:03, edited 1 time in total.
multiOS
Volunteer
Posts: 800
Joined: 14. Sep 2019, 16:51
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: WIN11,10, 7, Linux (various)
Location: United Kingdom

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by multiOS »

MS Windows already has its own Type 1 Hypervisor, Hyper-V, if that's really what you need. So does Oracle, but not free to use.

See the summary of main options: https://docs.oracle.com/cd/E50245_01/E5 ... visor.html
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by scottgus1 »

As a 'frame challenge', there appear to be ways to edit the host EFI system partition without requiring a virtual machine, google "edit efi system partition app".

Using a VM to do this is like trying to use a separate PC to do it. Using an app on the primary PC might be easier.
ecccc3
Posts: 20
Joined: 1. Aug 2022, 03:02

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by ecccc3 »

scottgus1 you don't understand the problem .

Well I found a solution of my problem : see https://forums.debian.net/viewtopic.php?f=17&t=152402 .
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VirtualBox doesn't write on the original EFI system partition (ESP)

Post by scottgus1 »

ecccc3 wrote:scottgus1 you don't understand the problem .
You're right there... I definitely don't understand why one would attempt to edit the physical PC's boot partition from within a VM. One could try, but when it goes against the VM hypervisor's manual, well, it may not work. And it didn't.
ecccc3 wrote:I found a solution of my problem
eccc3's link wrote:I copied pasted the firmware-testing-amd64-netinst.iso content in a PC's mass memory ( hard disk ) FAT32 partition
scottgus1 wrote:Using an app on the primary PC might be easier.
QED.
Post Reply