Jump to content











Photo
- - - - -

How to transfer control from bootmgr (host-store) to 'grldr/grldr.mbr' and/or bootmgr (vhd-store) inside VHD ?


  • Please log in to reply
40 replies to this topic

#26 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 374 posts
  •  
    India

Posted 25 August 2014 - 08:22 AM

Of course the grldr will boot from a floppy image :), but the exercise is about 

After defragment of 'VHD.vhd' , Will 'grldr' load within from 'VHD.vhd' ?



#27 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13602 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 25 August 2014 - 09:26 AM

After defragment of 'VHD.vhd' , Will 'grldr' load within from 'VHD.vhd' ?

Sure it will.

 

Though the scope of the exercise is NOT to boot the grldr inside the .vhd, it is about loading the grldr on the "host" in order to boot the BOOTMGR inside the .vhd.

In any case, for both there is the need to map in grub4dos the .vhd to a BIOS drive, and in order to do so the .vhd must be contiguous. 

 

Let's try to recap what you should have right now:

BIOS->MBR->PBR of active partition->BOOTMGR (on host)->\boot\BCD and BOOT.INI (on host)->Choices:

Choice #1: "Normal" Windows booting <- inside the \boot\BCD (on host) that will chainload WINLOAD.EXE (or *whatever*) (on host)

Choice #2: "Native .vhd booting <- inside the \boot\BCD (on host) that will mount the .vhd and chainload the WINLOAD.EXE (or *whatever*) (inside the .vhd)

Choice #3: "Can you see the following line?" <- "bogus" entry in \BOOT.INI (on host)

Choice #4: "grub4dos" <- entry in \BOOT.INI (on host) chainloading the grldr (on host)

Choice #5: "If you can see it, it means that the BOOTMGR on the host" <- "bogus" entry in \BOOT.INI (on host)

Choice #6: "is involved in the booting." <- "bogus" entry in \BOOT.INI (on host)

 

Let's see what is the expected outcome of the experiment:

BIOS->MBR->PBR of active partition->BOOTMGR (on host)->\boot\BCD and BOOT.INI (on host)->Choices-> choose "grub4dos"

map the .vhd to a BIOS drive and chainload the BOOTMGR (inside the .vhd) ->\boot\BCD and BOOT.INI (inside the .vhd)->Choices:

 

Choice #1: "Native .vhd booting <- inside the \boot\BCD (inside the .vhd) that will mount the .vhd and chainload the WINLOAD.EXE(or *whatever*) (inside the .vhd)

Choice #2: "Can you see the following line?" <- "bogus" entry in \BOOT.INI (inside the .vhd)

Choice #3: "grub4dos" <- entry in \BOOT.INI (on host) chainloading the grldr (inside the .vhd)

Choice #4: "If you can't see it, it means that the BOOTMGR inside the .vhd" <- "bogus" entry in \BOOT.INI (inside the .vhd)

Choice #5: "is not involved in the booting." <- "bogus" entry in \BOOT.INI (inside the .vhd)

 

Will it work? :unsure:

Who knows? :dubbio:

The idea of an experiment is to try and see what happens. :)

 

:duff:

Wonko



#28 cdob

cdob

    Gold Member

  • Expert
  • 1326 posts

Posted 25 August 2014 - 04:49 PM

C:\bootmgr -> C:\boot\bcd -> C:\Easy2Boot.vhdx -> \grldr -> \menu.lst -> Easy2Boot

BCDedit.exe /store C:\boot\bcd /create {ntldr} /d "VHD embedded grldr"
BCDedit.exe /store C:\boot\bcd /set {ntldr} device vhd=[locate]\Easy2Boot.vhd
BCDedit.exe /store C:\boot\bcd /set {ntldr} path \grldr
BCDedit.exe /store C:\boot\bcd /displayorder {ntldr} /addlast
However the chain ends here: grldr dosn't find menu.lst

Reconnect the chain: Edit menu.lst embedded inside the file [Easy2Boot.vhd]\grldr:
map Easy2Boot.vhd to a virtual hard disk

#29 devdevadev

devdevadev

    Frequent Member

  • Advanced user
  • 374 posts
  •  
    India

Posted 26 August 2014 - 02:33 PM

What code lines should I have to use within 'menu.lst' embedded inside the file [Easy2Boot.vhd]:\ in order to map Easy2Boot.vhd to a virtual hard disk ?



#30 cdob

cdob

    Gold Member

  • Expert
  • 1326 posts

Posted 26 August 2014 - 03:18 PM

What code lines should I have to use within 'menu.lst' embedded inside the file [Easy2Boot.vhd]:\ in order to map Easy2Boot.vhd to a virtual hard disk ?

I don't know Easy2Boot requirements at given condition.
There maybe conflicts with previous mapped drives.

A idea, not tested
timeout 3

title boot vhd
set VHDfile=/Easy2Boot.vhd
cat --length=0 %VHDfile% > nul || find --set-root --ignore-floppies --ignore-cd %VHDfile%
map %VHDfile% (hd0,0)
map --hook
root (hd0,0)
configfile /menu.lst


#31 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13602 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 26 August 2014 - 04:07 PM

What code lines should I have to use within 'menu.lst' embedded inside the file [Easy2Boot.vhd]:\ in order to map Easy2Boot.vhd to a virtual hard disk ?

 

I give up. :(

 

Normally it is not an option :ph34r:, and it is against the unwritten Rules, but in extraordinary cases, it is better go playing Calvinball :yahoo:

http://www.bartel.org/calvinball/

http://calvinandhobb...wiki/Calvinball

 

:duff:

Wonko


  • JonnyHotkeys likes this

#32 oxynos

oxynos
  • Members
  • 6 posts
  •  
    Japan

Posted 18 January 2017 - 04:03 AM

This thread has not been active for some time and WonkoTheSane may have gave up but I have some promising results...

I am just blocked near the endline!

 

What I want to do is is boot from a vhd containing Linux (the vhd is on a usb memory)

So what I did is:

USB MBR->bootmgr->grub4dos->map vhd -> chainload grub on linux partition of the vhd

 

I used settings similar to those provided by WonkoTheSane to map the vhd and it worked! That is:

grub>map /Linux.vhd (hd0)

grub>map --hook

grub>root (hd0,1) #Linux is on the second partition of vhd

grub>kernel /boot/grub/i386-pc/core.img

grub>boot

 

Everything works fine: grub4dos finds the vhd, maps it as a hard drive, grub on the linux partition is loaded UNTIL the boot fails and the (initramfs) is given.

 

I also tried to boot linux directly from its kernel:

grub>kernel /vmlinuz root=/dev/sda

grub>initrd /initrd.img

grub>boot

 

but it does not work either, linux boots but the same (initramfs) prompt appears.

This time however, I can see all the boot messages and it appears that the problem is that Linux is too smart!

 

During the boot, linux ignores grub mappings and re-defines itself what are /dev/sda, etc. drives.

 

So I tried to force the root folder as:

grub> kernel /vmlinuz root=(hd0,1)

 

but it did not work either :(

 

Any Idea how I could tell Linux to use the partition mapped by grub4dos as root?



#33 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13602 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 18 January 2017 - 09:32 AM

 

Any Idea how I could tell Linux to use the partition mapped by grub4dos as root?

Sure. :)

Wonko (the Sane) never gives up :w00t:, it is only attempting to communicate with devdevadev that has been deemed as a lost cause and abandoned.  :(

 

Here (basically you need to map the vhd in Linux and pass the right parameters to the kernel, for kpartx/losetup, you will need to boot the kernel and initrd directly, not going through GRUB2, which - though probably possible - adds an unneeded layer ):
http://reboot.pro/to...rom-vhd-how-to/

 

Your mileage may vary depending on the Linux distro you are using.

And of course the .vhd needs to be of the "fixed" type (please read as RAW image with a Conectix footer appended).

 

:duff:

Wonko



#34 oxynos

oxynos
  • Members
  • 6 posts
  •  
    Japan

Posted 18 January 2017 - 10:49 AM

Thank you for your help Wonko!

 

As you suggested, to mount/map the vhd in Linux, I used vdfuse.

I installed the script mounting the vhd in initrd.img like described below:

https://stackoverflo...nd-load-the-sys

 

and now I have a linux booting in "Emergency Mode" which is quite a progress since:

- the NTFS partition containing the vhd on my usb drive is mounted with success

- my .vhd is mounted within Linux with success

- the linux partition in the .vhd is mounted as root within linux with succes

  (I checked my filesystem and it looks good)

 

I do not know yet why it does not boot all the way and starts in Emergency mode, searching some clues in the boot log files...

 

Did I forget something?

 

Note: I checked that the vhd is "fixed" (although since I am using vdfuse, an util from virtualbox, the only restriction to boot a "dynamic" vhd would be on the grub4dos side, not on the Linux side?)



#35 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13602 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 18 January 2017 - 11:39 AM

Thank you for your help Wonko!

 

As you suggested, to mount/map the vhd in Linux, I used vdfuse.

I installed the script mounting the vhd in initrd.img like described below:

https://stackoverflo...nd-load-the-sys

 

and now I have a linux booting in "Emergency Mode" which is quite a progress since:

- the NTFS partition containing the vhd on my usb drive is mounted with success

- my .vhd is mounted within Linux with success

- the linux partition in the .vhd is mounted as root within linux with succes

  (I checked my filesystem and it looks good)

 

I do not know yet why it does not boot all the way and starts in Emergency mode, searching some clues in the boot log files...

 

Did I forget something?

 

Note: I checked that the vhd is "fixed" (although since I am using vdfuse, an util from virtualbox, the only restriction to boot a "dynamic" vhd would be on the grub4dos side, not on the Linux side?)

There is some support for "dynamic" VHD's in recent grub4dos versions (BTW, which EXACT version are you using?), but FORGET about this support and use a "fixed" one.

If it wasn't clear from the given thread, there is NOT one (sensible) reason in the world to use dynamic .vhd's, they only represent an added complexity.

 

For the record, I don't think I ever suggested using vhdfuse (though most probably it can be made working fine) but rather kpartx/losetup, as in the given thread:
http://reboot.pro/to...rom-vhd-how-to/

 

Usual questions:

Which commands are you using in grub4dos and what parameters are you passing to the kernel?

Or are you still going through core.img/GRUB2, and if this is the case which commands/parameters do you have in grub.cfg?

What is your setup? (there is the possibility of a mismatch between grub4dos/BIOS and GRUB2/Linux device enumeration, also talked about in the given thread)

Which specific distro are you using? (parameters/cheatcodes may be different in different distro's)

 

It is strange that it boots in Emergency Mode AND everything seems fine:





- the NTFS partition containing the vhd on my usb drive is mounted with success

- my .vhd is mounted within Linux with success

- the linux partition in the .vhd is mounted as root within linux with succes

it is very possible that there is *some other* initial boot files that have *something* hardcoded that needs to be adapted/changed, as you said, checking the log files is next step :).

 

 

:duff:

Wonko



#36 oxynos

oxynos
  • Members
  • 6 posts
  •  
    Japan

Posted 19 January 2017 - 04:19 AM

>There is some support for "dynamic" VHD's in recent grub4dos versions (BTW, which EXACT version are you using?), but FORGET about this support and use a "fixed" one.

>If it wasn't clear from the given thread, there is NOT one (sensible) reason in the world to use dynamic .vhd's, they only represent an added complexity.

 

No problem, I was not trying to poke you about dynamic VHDs, I was just wondering if there was still a technical issue there

For the record, I also prefer fixed VHDs because beyond the complexity, they have also much worse performances

 

 

> For the record, I don't think I ever suggested using vhdfuse (though most probably it can be made working fine) but rather kpartx/losetup, as in the given thread: http://reboot.pro/to...rom-vhd-how-to/

Sorry, I was refereeing to the strategy of mapping the vhd from within Linux

 

 

> Usual questions:

> Which commands are you using in grub4dos and what parameters are you passing to the kernel?

> Or are you still going through core.img/GRUB2, and if this is the case which commands/parameters do you have in grub.cfg?

> What is your setup? (there is the possibility of a mismatch between grub4dos/BIOS and GRUB2/Linux device enumeration, also talked about in the given thread)

No, I stopped trying to chain to Grub2 in the vhd and am now booting the kernel directly

My commands are:

map /Linux.vhd (hd0)
root (hd0, 1)
kernel /vmlinuz host=/dev/sdb1 vdisk=/Linux.vhd vtype=VHD root=/dev/vdhost/Partition2 debug
initrd /initrd/img
boot

The 'host', 'vdisk', 'vtype' parameters are used in my initramfs script to mount the vhd:

ntfs-3g $host /vdhost/
vdfuse -t $vtype -f /vdhost$vdisk /dev/vdhost

> Which specific distro are you using? (parameters/cheatcodes may be different in different distro's)

I'm using Ubuntu 16.04 (LTS)

 

> It is strange that it boots in Emergency Mode AND everything seems fine:

Well, considering that yesterday I had nothing, booting into (initramfs) prompt and then into "Emergency Mode" with fully mounted partitions,

everything was not fine but the finish line looked quite close to me

 

> it is very possible that there is *some other* initial boot files that have *something* hardcoded that needs to be adapted/changed, as you said, checking the log files is next step :).

I have some answers here:

One message was "Failed to start Remount Root and Kernel File systems"

So I thought: maybe a problem with fstab not compatible between the setup in virtual machine and the new setup within vhd

=> One problem was that I referenced the first partition of the vhd but did not mounted it from /dev/vdhost/Partition1

 

After correction, I am not in Emergency Mode anymore but booting into console mode, no X11 because the partition is mounted as read-only :(

I thought about a problem on the ext3 partition that switches into read-only mode after errors but fsck did not reveal any problem :(

(/run/initramfs/fsck.log was clean also at boot time)

I also tried to clean the partition at startup using:

shutdown -r now -F

but so success either.

 

What kind of *initial boot* file do you think I should check?

In the logs, the "Failed to start Remount Root and Kernel File systems" persists but I cannot figure out why...



#37 oxynos

oxynos
  • Members
  • 6 posts
  •  
    Japan

Posted 19 January 2017 - 04:21 AM

correction: I prefer fixed VHDs because they have much BETTER performances!

 

and my grub4dos exact version is 0.4.6a



#38 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13602 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 19 January 2017 - 12:45 PM

I have no idea about the issue at hand, everything seems fine, it is possible that simply there is an issue with vhdfuse being not "compatible" with being a boot volume or however not "signaling" properly the device/volume to *something else*.

Why don't you try with kpartx/losetup INSTEAD of vhdfuse?

You seem like proficient enough in Linux scripts to adapt those scripts to your distro if needed. :)

I am not convinced about the device mapping in grub4dos, but since you manage to boot (even without X11) that cannot bethe issue.

What I would use (not necessarily "better") mind you:
find --set-root /Linux.vhd
map /Linux.vhd (hd2)
map --hook
root (hd2, 1)
kernel /vmlinuz host=/dev/sdb1 vdisk=/Linux.vhd vtype=VHD root=/dev/vdhost/Partition2 debug
initrd /initrd/img
boot

Some random notes/doubts:
The /dev/sdb1 in the host value should mean that the /Linux.vhd is on first partition of second disk, right?
The vtype=VHD is correct? Is it needed? (the stackoverflow example doesn't use it)
The vdisk=/Linux.vhd is correct? (the stackoverflow example uses vloop=)

All I can say (as a general advice) is that the idea of such examples are that you first need to replicate them EXACTLY and only once the original, unmodified setup works (and only then) introduce any variation.

BTW user195342 on stackoverflow never talked of GUI, so for all we know he may well have booted command line/terminal only. :dubbio:


:duff:
Wonko
 



#39 oxynos

oxynos
  • Members
  • 6 posts
  •  
    Japan

Posted 20 January 2017 - 01:11 AM

I have no idea about the issue at hand, everything seems fine, it is possible that simply there is an issue with vhdfuse being not "compatible" with being >a boot volume or however not "signaling" properly the device/volume to *something else*.

You may be right, vdfuse may be the problem. It looks like it worked on the stackoverflow example though. Maybe some *special* settings when using a different linux distribution...

 

Why don't you try with kpartx/losetup INSTEAD of vhdfuse?

I did not know about kpartx/losetup before you mention it in your earlier post.

As a matter of fact, your advice paid! I successfully booted my linux inside a vhd on a usb memory using losetup.

In fact it was easier than vdfuse since fewer dependencies had to be added to initrd!

 

To be fair to vdfuse, vdfuse could be very interesting to mount vmdk, vdi, encrypted drives...

I am not interested by this feature but, if someone wanted to do it, I guess the kernel and linux initrd would have to be copied out of the virtual drive since grub4dos would be unable to open this virtual drive to use them... (3 files to move around instead of 1?)

What do you think Wonko?

 

You seem like proficient enough in Linux scripts to adapt those scripts to your distro if needed. :)

I don't know about that, but hopefully, I did manage to adapt the initramfs scripts to use losetup :)

 

I am not convinced about the device mapping in grub4dos, but since you manage to boot (even without X11) that cannot bethe issue.

If I understand your device mapping, you map the vhd on another drive (hd2 instead of hd0) to prevent conflicts, right?

 

The /dev/sdb1 in the host value should mean that the /Linux.vhd is on first partition of second disk, right?

Yes, since /dev/sdb1 is in fact the usb drive containing the vhd on its first partition

I am considering passing the UUID of the usb drive, to be more "portable" in case the host computer has 2 fixed drives or other usb drives connected...

 

The vtype=VHD is correct? Is it needed? (the stackoverflow example doesn't use it)

Yes, I tried like the stackoverflow said but vdfuse does not recognize the VHD type on its own, so I had to force it

and, since vdfuse is supposed to manage multiple types of virtual drives, I just set it up as a setting passed to the kernel...

 

The vdisk=/Linux.vhd is correct? (the stackoverflow example uses vloop=)

The stackoverflow was a little buggy with my environment and I needed some verbosing to debug, so I modified it a bit and ended up using my variable names but it works the same

 

BTW user195342 on stackoverflow never talked of GUI, so for all we know he may well have booted command line/terminal only. :dubbio:

It works also with GUI for me.

Once the remount as read/write succeeded, my Ubuntu booted just as usual.

 

Thanks again for your help Wonko! I would still be sweating on it without your tips!


  • ndog37 likes this

#40 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13602 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 20 January 2017 - 10:22 AM

Good (everything is well that ends well) :).

 

About vdfuse, maybe it needs some added parameter to create a r/w device or maybe something else must be added in the mounting command, if you unmount and remount it works (I hadn't got that from your earlier post) then there must be *something* either missing or "wrong" in the first mount. :unsure:

 

Maybe stupid question, but is it not possible to automate the unmount and remount?

 

About the need of extracting the kernel and initrd, possibly using (instead of the "fixed" vhd) other kinds of virtual image formats, as long as a VMDK or a VDI is "fixed" there won't be much problems with them.

I believe it is entirely possible to find the addresses of the kernel and initrd (as long as they are "contiguous" as they normally would be) and do some "mapping tricks" with grub4dos, in the worst case one could add a (still contiguous) small .iso or small fat volume imaeg with a copy of kernel and initrd inside the vdk or vmdk.

 

Also - it depends on versions I believe - there are (besides good OLD .pln files + descriptor file) .vmdk that are actually (very confusingly) a .vmdk that is a RAW image + .vmdk descriptor file and - though it's a lot of time I checked one of them, there are "fixed" .vdi's that are again RAW images with a header prepended, ant the same should apply to those (still "fixed") .vmdk that are "a single file":
http://reboot.pro/to...k-disk-volumes/

http://reboot.pro/to...ge-file-offset/

There are of course no problems in mapping the RAW .vmdk file and only a very slight complication in mapping the other type of .vmdk and that particular kind of .vdi in grub4dos by using a sector offset in the mapping commands...

 

In any case, if you have time and will, it would be useful if you could continue your tests with vdfuse and - hopefully - manage to solve the problem, it could be a very valid alternative method.

 

:duff:

Wonko


  • ndog37 likes this

#41 oxynos

oxynos
  • Members
  • 6 posts
  •  
    Japan

Posted 24 January 2017 - 06:17 AM

No problem running vdfuse manually after boot, mounting and unmounting but still errors at boot time :(

Like you said, maybe the partition needs to be unmounted specifically using vdfuse rather than using the automatic boot sequence remount...

but I haven't dived that much into the working of booting to do it myself yet...

 

I would like to find out what is going on, but to be honest, I have spent already too much time working on this issue!

Maybe if the incentive of using vdfuse was stronger...

 

There are of course no problems in mapping the RAW .vmdk file and only a very slight complication in mapping the other type of .vmdk and that

particular kind of .vdi in grub4dos by using a sector offset in the mapping commands

Interesting method! I guess that as long as the virtual drive is *contiguous* and *not encrypted*, this method will work...

 

Anyways, thanks again for your help Wonko!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users