Jump to content











Photo
- - - - -

Boot Kali Linux from VHDX

kali vhd boot

  • Please log in to reply
36 replies to this topic

#26 zammibro

zammibro

    Member

  • Members
  • 59 posts
  •  
    United States

Posted 17 August 2020 - 04:46 PM

While we are at it, the job would be incomplete without fixing USB Thumb boot from BIOS. Is there anything I can amend with Bootice in that department to access Grub2 menu?


Edited by zammibro, 17 August 2020 - 04:47 PM.


#27 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 17 August 2020 - 04:46 PM

Maybe it is a botched install, or really Kali Linux has changed something in the vmlinuz. :dubbio:

 

Can you try with the 2020.2 version? That one is surely working, at least the Live .iso with grub4dos:

https://cdimage.kali.org/kali-2020.2/

 

That EXT4 partition is a logical volume inside extended, I have no idea of what "boot flag" you are talking about :unsure:, that volume won't ever "boot" (unless a bootsector is written to it AND it is chainloaded by something else).

 

:duff:

Wonko



#28 zammibro

zammibro

    Member

  • Members
  • 59 posts
  •  
    United States

Posted 17 August 2020 - 06:18 PM

I'm running Kali 2020.2 now, at least it was when ISO downloaded. It booted perfect with latest Grub4DOS as mentioned in previous post, though bypassed Grub 2 menu. I doubt it was a botched install, in fact it was quite comprehensive one, the entire package slowly but surely from a Rufus thumb drive. Anyway, there should be some standard way to get to the thumb's partition Grub2 menu from Grub4DOS? It offered to install Grub2 to the main drive which I politely declined, and selected the USB volume instead. No errors posted.But there should be ways to fix it?


Edited by zammibro, 17 August 2020 - 06:25 PM.


#29 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 18 August 2020 - 08:57 AM

I'm running Kali 2020.2 now, at least it was when ISO downloaded. It booted perfect with latest Grub4DOS as mentioned in previous post, though bypassed Grub 2 menu. I doubt it was a botched install, in fact it was quite comprehensive one, the entire package slowly but surely from a Rufus thumb drive. Anyway, there should be some standard way to get to the thumb's partition Grub2 menu from Grub4DOS? It offered to install Grub2 to the main drive which I politely declined, and selected the USB volume instead. No errors posted.But there should be ways to fix it?

 

I lost you. :w00t:

 

I am not sure to understand what you did (exactly).

 

GRUB2 is normally installed to a disk (the MBR+hidden sectors) and what goes to a volume (on the same disk) the binaries and configuration files, but it may also be installed to a volume bootsector.

.

If you do have a GRUB2 core.img in your build, it is easy to chainload it from grub4dos (the path to core.img may change deepending on distro/install):

 

find --set-root /boot/grub/core.img
kernel /boot/grub/core.img
boot

 

Have a look also at this (in practice the only GRUB2 guide I can understand):

https://web.archive....h Commands.html

 

And to this post:

https://forums.hak5....e-config-files/

 

As always your mileage may vary.

 

:duff:

Wonko



#30 zammibro

zammibro

    Member

  • Members
  • 59 posts
  •  
    United States

Posted 18 August 2020 - 08:30 PM

I lost you. :w00t:


I found myself redeemed. :D Kali Install ISO was unable to fix the botched Grub2 USB install it did. Bootice wasn't smart enough to get G2 pieces together. Grub4DOS while installed in USB thumb MBR by Bootice failed to boot Kali from the USB, and generally failed at all counts executing commandline. The only winner I found after sleepless nights was, of course, venerable ship captain from Outside of the Asylum with best links around, but also... a step behind... Boot Repair Disk.

While booted both in VMWare or from Rufus scalped USB thumb by BIOS, it created comprehensive and quite readable report about multiple bootable entities on my PC, and - the most important - pinpointed the problem namely with Kali USB, suggesting to reinstall Grub2 on it. I reluctantly agreed knowing many possible undesirable consequences for my entire system. But - a minute later Kali USB was fixed, no other drives touched at all.

And the next moment I already booted Kali USB installed distro from BIOS. Basically, Boot Repair Disk substituted something dropped on disk by Kali Installer with very capable Grub 2, both in MBR and the right partition folders. Now inhabitants of this ship have bright record, and morally fully prepared to storm "boot kali from VHD" fortress. :ph34r:


Edited by zammibro, 18 August 2020 - 09:23 PM.


#31 zammibro

zammibro

    Member

  • Members
  • 59 posts
  •  
    United States

Posted 20 August 2020 - 11:52 AM

I found you. :o

 

And for a good reason. While attempting to run the installed Kali image, it transpired images posted on the main download page are hardly useful due to being buggy and... obsolete, with missing headers, so at times no way to compile new code like WiFi adapter drivers. Kali forum community suggests weekly images instead, which are surprisingly different, with new kernel and working Grub install including boot.img and numerous modules in \boot\grub\i386-pc .

 

That requires of course editing Grub4DOS menu to boot the new Kali install, so here's the question: is it possible to edit and save Menu.lst from Grub4DOS commandline, and how?


Edited by zammibro, 20 August 2020 - 12:04 PM.


#32 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 21 August 2020 - 12:59 PM

That requires of course editing Grub4DOS menu to boot the new Kali install, so here's the question: is it possible to edit and save Menu.lst from Grub4DOS commandline, and how?

No.

There is no editor (capable of saving to file) in grub4dos.

It is much easier to edit it in *any* text editor, under Windows or Linux.

More than anything else, the issue is that grub4dos cannot normally create files[1], in theory on existing file it i possible to use write or cat --replace commands, but it is not at all easy/error proof/etc.

Example (of a half-@§§ed solution, aimed to hex values):

http://reboot.pro/to...ite-hex-values/

 

Something that you can do easily (if you don't want to go all the way of jolting down the sequence of working commands on a piece of paper and write them to menu.lst once booted) it i to do the tests in a VM such a Virtualbox, that together with Imdisk provides an easy way to make experiments and save results, JFYI:
https://msfn.org/boa...comment=1181069

 

:duff:

Wonko

 

[1] though there is an external fat module that allows creating files on FAT12/16 and possibly even 32 bit



#33 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 24 August 2020 - 09:24 AM

And in the meantime 2020.3 ha been released:

https://www.kali.org...2020-3-release/

 

:duff:

Wonko



#34 Amitabh

Amitabh
  • Members
  • 4 posts
  •  
    India

Posted 11 August 2021 - 02:33 PM

Is this issue only for UEFI systems and not BIOS / MBR ?

 

Because I have been native booting a couple of linux VHDs since many years by creating the BCD entries using EasyBCD in Bios / MBR mode (not UEFI) *

 

Have recently shifted to using UEFI since I installed Windows 11 and now I find that EasyBCD won't work with UEFI, so have tried AIO Boot, Ventoy, Grub2win, clover and a few more before settling on grub2win finally which boots linux/win fine with secureboot enabled (using shim.efi)

 

Am trying to use BootICE to create BCD entries for linux VHD but am stuck there.

 

I tihnk EasyBCD used neogrub or chainloading or some shit to boot the linux VHDs and didnt ask for any boot file, just the path to VHD, while BootICE seems to need some boot file (like grub.efi / shim.efi / ubuntu.efi i guess)

 

Before wasting time in all sorts of permutations/combinations I just wanted to check whether anyone knows how to create BCD entry for a linux vhd boot ? Installing to VHD was not a problem earlier at least.

 

If i remember correctly (the vhds were created a couple of years back - been just updating them since then) i had done the linux VHD installations with Hyper-V or by creating a file as a raw disk image with DD and formating and mounting it and then chrooting into it before running the linux installation.

Then converting the raw image file using qemu utility into vhd. (Windows 8/10 installs were by shift+F10 and attach vhd then continue install method)

 

 

* I keep a few Linux & windows VHDs archived on external HDD and copy 1 or 2 to my SSD when I need to boot them - usually for some sort of R&D thats sure to screw up the install or at times to try out some cracked sw which has malware or other stuff that office IT doesnt feel happy about.

 

There's only enough space on SSD to boot  win11 from 1 partition and elementary linux from 2nd and keep a 3rd data partition. So VHDs were good as compared to using say 65GB USB3 pendrive etc which were much slower compared to SSD.


  • crashnburn likes this

#35 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 11 August 2021 - 04:22 PM

There is no such thing as a "BCD entry for Linux in VHD".

There is - maybe - a "BCD entry chainloading another loader".

 

EasyBCD uses/used a ripped grub4dos (senselessly renamed to neogrub) and automated the rest[1].

 

BUT the BIOS bootmgr/BCD had an option to boot "legacy" systems by means of chainloading a bootsector and either grldr or grldr.mbr could be chainloaded this way.

 

So you could have:

1) BOOTMGR as "main" boot manager
2) grub4dos as "secundary" boot manager or loader for Linux

 

Since grub4dos is NOT UEFI compatible, you need another loader instead (and we have now grub4uefi or grub4dos for UEFI, besides GRUB2):
http://reboot.pro/in...showtopic=22400

 

With BootICE you need theoretically to go in two steps:
1) add to the BCD a grub4UEFI (or other loader) entry (if possible, I don't think it is)
2) create a suitable configuration file for grub4uefi (or the other loader you use) to load the Linux (in the VHD)

 

You have to understand however how grub4dos for UEFI is still largely experimental, so there is not yet any (AFAIK) complete guide to use it for Linux booting inside a VHD

 

Most probably right now it would be easier to use other means (motherboard UEFI/NVRAM entries) to boot NOT to the BOOTMGR, but rather the grub2 or grub4dos for UEFI  :unsure: or however use not the bootmgr/bcd as "main" bootmanager, using instead GRUB2 (or grub4dos for UEFI or *whatever*) and use it to either chainload it the bootmgr/bcd (i.e. boot Windows, but this may or may not be possible wtih TPM, secreboot and what not) or boot the Linux (normal or in vhd).

 

:duff:

Wonko

 

 

 

 

[1] the rest consists in creating a *whatever* configuration file for the loader, in the case of the "classic" grub4dos is menu.lst, it has remained the same in grub4uefi but is located in another directory, if I recall correctly, since the syntax is - while not exactly the same - very, very similar you can use your old grub4dos menu,lst with some little modifications


  • Amitabh likes this

#36 Amitabh

Amitabh
  • Members
  • 4 posts
  •  
    India

Posted 12 August 2021 - 10:50 AM

Ya you are right, there's a grldr pre-filled in the boot file field of BootICE but I wasnt sure what that is.

I am using grub2win currently because that seemed closest to Grub2 and I personally found it better than the clover/aioboot/etc in terms of not having it populate 10 entries everytime one of my usb disks is attached.

Grub2win does let me create chainload entries and I could also use grub-customizer on my linux partition to create the Grub2 entry but offcourse I have no clue how to refer to the VHD disk in grub, like we do (hd0,1) or /dev/sda1 etc. Maybe mount loop back the VHD image provided it doesnt need some module to be included in the United etc.

Have found someone's grub config for this, will try that and update. Else i guess I'll just use AIOboot or Clover to boot the vhd or ventoy from usbpendrive.

Thanks for the info
  • crashnburn likes this

#37 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 12 August 2021 - 12:20 PM

UEFI Secure Multi-Boot of Windows 10 and Linux in VHD using Grub2 and viskchain was realised and described in

 

How to make Linux VHD for Multi-Boot with Windows using Grub2 and vdiskchain

 

in VHD_WIMBOOT PDF page 10 and 11 (Experts Only if you know what you are doing ....)

 
-  KALI Linux has 600 Forensic and Penetration Testing Tools and is based on Debian Linux

  • Amitabh and crashnburn like this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users