Jump to content











Photo
- - - - -

Linux from VHD How To?

linux windows boot vhd image-file howto

  • Please log in to reply
117 replies to this topic

#101 john3voltas

john3voltas

    Member

  • Members
  • 97 posts
  •  
    Portugal

Posted 30 March 2019 - 11:50 AM

I do not think u will be able to have even a view of the drive hosting the linux folder by default once in wubi linux.

 

BTW, that is completely innacurate.

I run Kubuntu from a wubiuefi install and I can easily access all data on the drive it is installed.



#102 antonino61

antonino61

    Frequent Member

  • Advanced user
  • 484 posts
  •  
    Italy

Posted 30 March 2019 - 11:58 AM

ah wubiuefi, not wubi on mbr. Sorry, I do not have uefi, so I do not know about it. all the info I have provided u with referred to mbr only.



#103 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 30 March 2019 - 12:08 PM

Arch, Slackware, Suse, Red Hat: what do we do if we want to run Fedora, OpenSuse or Archlinux from a VHD file? That's what I've been looking for a very long time.

Cheers

Starting here are the instructions for Arch Linux:

http://reboot.pro/to...ow-to/?p=200203

 

WHAT is the problem?

 

:duff:

Wonko



#104 john3voltas

john3voltas

    Member

  • Members
  • 97 posts
  •  
    Portugal

Posted 30 March 2019 - 01:41 PM

The problem?

Well, the problem is everything, Wonko.

I don't have the faintest idea on WHERE to start.

How can you run a cat /proc/cmdline without having booted the OS? So, if you have to boot the OS in order to run those commands, then you need to be able to boot the OS into the VHD file in the first place, or am I missing something here?

I can't boot the OS from another partition. I am simply not allowed because the computer is not mine. I could however boot it if I had it on a VHD file using G4D because I can chain G4D to Windows' own boot manager.

But this is looking like the story of the chicken and the egg. I gotta find a loophole otherwise I can't follow those instructions.

TIA

Cheers



#105 antonino61

antonino61

    Frequent Member

  • Advanced user
  • 484 posts
  •  
    Italy

Posted 30 March 2019 - 01:54 PM

so, u mean that if i have a vhd running with bootmgr, I can replicate this scenario in ram and save it in order to run it again on ram anytime I wish?



#106 john3voltas

john3voltas

    Member

  • Members
  • 97 posts
  •  
    Portugal

Posted 30 March 2019 - 02:03 PM

so, u mean that if i have a vhd running with bootmgr, I can replicate this scenario in ram and save it in order to run it again on ram anytime I wish?

 

Sorry but who are you addressing this question?



#107 antonino61

antonino61

    Frequent Member

  • Advanced user
  • 484 posts
  •  
    Italy

Posted 30 March 2019 - 02:05 PM

sorry about it, wrong post. 



#108 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 30 March 2019 - 02:11 PM

The problem?

Well, the problem is everything, Wonko.

I don't have the faintest idea on WHERE to start.

How can you run a cat /proc/cmdline without having booted the OS? So, if you have to boot the OS in order to run those commands, then you need to be able to boot the OS into the VHD file in the first place, or am I missing something here?

I can't boot the OS from another partition. I am simply not allowed because the computer is not mine. I could however boot it if I had it on a VHD file using G4D because I can chain G4D to Windows' own boot manager.

But this is looking like the story of the chicken and the egg. I gotta find a loophole otherwise I can't follow those instructions.

TIA

Cheers

A few posts before the one I linked to.

http://reboot.pro/to...ow-to/?p=200156

 

You can use Virtualbox from windows just fine (instead of virtualbox in Linux) AFAICT.

 

You need anyway a Linux install to be able to run Linux only commands such as mkinitcpio.

 

Of course you need to read (and re-read and re-re-read) the whole thread and provided resources, then digest what you have read and put all the info on top of some (pre-existing) slightly-more-than-basic Linux knowledge/experience.

 

If you are thinking of an automated/automagic program there isn't any (that I know of).

 

:duff:

Wonko 



#109 john3voltas

john3voltas

    Member

  • Members
  • 97 posts
  •  
    Portugal

Posted 30 March 2019 - 02:43 PM

A few posts before the one I linked to.
http://reboot.pro/to...ow-to/?p=200156


Cryptic to say the least. All I can read on that post is the quote from crashnburn where he points out most of my own question, to be honest.
It seems as if everybody that talks about this subject can't take the time to write a post on it with details on what he/she did, and WHY he/she found the need to do that.

 

You need anyway a Linux install to be able to run Linux only commands such as mkinitcpio.


I can't understand what you mean with this sentence. You mean I need to find a way to run Linux from commands such as mkinitcpio?
If so, why? To accomplish what goal? Knowing why we do stuff really helps on understanding the whole picture and learning on the subjects.
 

Of course you need to read (and re-read and re-re-read) the whole thread and provided resources, then digest what you have read and put all the info on top of some (pre-existing) slightly-more-than-basic Linux knowledge/experience.


That doesn't seem to help.
I've read and re-read the whole thread 2 times and I've gone to re-read the posts you mentioned at least another 2 times.
I just can't understand them because they are based not on knowledge about Linux as a whole but on knowledge on how Linux boots up. Redoing initramfs images, kernel boot up options, etc.
And those posts are not specific. Those just mention parts of what needs to be done.
That makes it very difficult to go find resources on the Internet. We just don't know what we're looking for...
 

If you are thinking of an automated/automagic program there isn't any (that I know of).


No, I am not looking at some automatic/automagic such as wubi to help me out. Yes, it would be nice but it's not a requirement.
What I am looking for is for resources, details on why/how to do something in order to being able to boot Linux from a VHD or raw image from G4D.

#110 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 30 March 2019 - 05:42 PM

OK.

Basic-basic instructions.

 

Get Virtualbox running on your system.

 

Create a (static) .vhd or RAW image big enough to hold the size of the ArchLinux install.

Install the ArchLinux inside the virtualbox (normally), flat files.

Add to it the needed ntfs-3g package and parted.

Repeat with another image.

 

Connect to virtualbox the first image as primary disk and the actual physicaldrive containing the second image as secondary disk.

 

Restart from here:

http://reboot.pro/to...ow-to/?p=200203

 

Loosely the ideas are:

1) make sure that the system can read/access NTFS

2) make sure that loop mounting works (if it does on the first image, it should work on the second, which is identical, as well) and mount the second image

3) insert scripts for automounting of loop devices (these go on the second image, obviously)

4) rebuild the initramfs

5) verify that needed dependencies have been actually added to it

5 bis) (missing in the original) replace the initramfs in the second image with the one you rebuilt

6) create a grub4dos menu for  booting from the second image (and of course make it so that you can chainload grub4dos when booting the first image)

7) (missing in the original) test if it works, if it does the second image should be "self-standing" and you should be able to boot it from grub4dos on the "real" machine, using the same (or similar) menu.lst entry.

 

:duff:

Wonko



#111 blackbalfur

blackbalfur

    Member

  • Members
  • 82 posts
  •  
    Netherlands

Posted 30 March 2019 - 06:50 PM

@ john3voltas are you allowed /able to boot from usb on that laptop?

 

Or is that part of not allowed to install a second disk.

 

If yes i can/may boot from usb, why you do not just use an external hd or ssd to boot windows from?

 

Or even linux from externall hd / ssd.

 

There would be no traces on the laptop (bootmanager) because the external hd / ssd would have its own bootmanager.


Edited by blackbalfur, 30 March 2019 - 06:59 PM.


#112 antonino61

antonino61

    Frequent Member

  • Advanced user
  • 484 posts
  •  
    Italy

Posted 31 March 2019 - 09:02 AM

no dice, blackbalfur, I tried everything I could to get rid of the full version of maxthon in favour of the portable one, which would not keep passwords to vital sites I have to visit everyday, though. It would have been a wonderful 2.8gb save off the vhd, if it had been feasible. 



#113 antonino61

antonino61

    Frequent Member

  • Advanced user
  • 484 posts
  •  
    Italy

Posted 31 March 2019 - 09:45 AM

sorry, wrong place for my post;

pls ignore it



#114 Imperator

Imperator
  • Members
  • 3 posts
  •  
    Austria

Posted 4 weeks ago

I've made a basic installation of a ubuntu on a VirtualBox VM, then I've installed the vdfuse as descirbed from @robbyrobby succuessful. After that I've made a boot stick and created a grub.cfg as mentioned. So far everything is fine, I'm able to boot from the stick into the grub loader and can choose the VHD entry. But when I want to boot the VHD I'll get an error ->

vdfuse: proceeding with mounting host and vdisk

ERROR: cannot autodetect disk type of /vdhost/TestVHD.vhd

...

Gave up waiting for root file system device. Common problems:
* Boot args (cat /proc/cmdline)
   * Check rootdelay = (did systen wait long enough?)
* Missing modules (cat /proc/modules; ls dev)
ALERT! /dev/vdhost/Partition1 does not exist. Dropping to shell!

If I mount the vhd-File in BusyBox there is a Partition1. 

 

I don't know what to do? Because for me it seems the grub finds the VHD and boots it, but something goes wrong.

 

May you guys help me to fix this issue? Thank you.

 

 

Here my menuentry

menuentry "Ubuntu TestVM" {
  insmod part_msdos
  insmod ext2
  set vhd='(hd0,msdos3)/TestVHD.vhd'
  set vdhost search --no-floppy -s root -t VHD -w -f $vhd
  loopback lp0 $vhd tdisk=VHD
  linux   (lp0,1)/boot/vmlinuz-5.0.0-23-generic host=/dev/sdb3 root=/dev/vdhost/Partition1 vdisk=/TestVHD.vhd quiet splash rw rootdelay=120
  initrd  (lp0,1)/boot/initrd.img-5.0.0-23-generic
}


Edited by Imperator, 4 weeks ago.


#115 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 4 weeks ago

Once said that it is not like robbyrobby last report/post is very clear (to me at least), the GRUB2 menu entry he used is very different from yours, 
http://reboot.pro/to...ow-to/?p=204004

menuentry "Ubuntu 16 nove -Regular-Install - sda7 rw" {
insmod vhd
vhd vhd0 (hd0,7)/ubuntu.16-04.x64.20170701_16gb.vhd --partitions


linux (vhd0,1)/vmlinuz host=/dev/sda7 vdisk=/ubuntu.16-04.x64.20170701_16gb.vhd root=/dev/vdhost/Partition1 quiet rw
initrd (vhd0,1)/initrd.img
}

vs:

menuentry "Ubuntu TestVM" {
insmod part_msdos
insmod ext2
set vhd='(hd0,msdos3)/TestVHD.vhd'
set vdhost search --no-floppy -s root -t VHD -w -f $vhd
loopback lp0 $vhd tdisk=VHD
linux (lp0,1)/boot/vmlinuz-5.0.0-23-generic host=/dev/sdb3 root=/dev/vdhost/Partition1 vdisk=/TestVHD.vhd quiet splash rw rootdelay=120
initrd (lp0,1)/boot/initrd.img-5.0.0-23-generic
}


 So I don't understand what you are trying to do/which posted experiment you are trying to replicate.

A good idea - particularly when dealing with experimental/partial/not fully documented methods - is to try and replicate EXACTLY the whatever report, and EXACTLY means EXACTLY, i.e. without introducing ANY variation/changes.

Once you will have (hopefully) success in replicating the setup, then (and only then) you can start introducing changes.

:duff:
Wonko

#116 Imperator

Imperator
  • Members
  • 3 posts
  •  
    Austria

Posted 4 weeks ago

Oh, I've thought you guys are Linux specialists and may adopt to my problem :)

 

I've just customized the entry for my partitions based on the this post and on https://unix.stackex...d-boot-from-vhd , but it does pretty much the same.

 

This post here is based on a module vhd, which is based on vmlite and I won't like to use a non-open-source module - it should be possilbe to boot an vhd without this module. 

 

Maybe I should open a new post.


Edited by Imperator, 4 weeks ago.


#117 Imperator

Imperator
  • Members
  • 3 posts
  •  
    Austria

Posted 4 weeks ago

Thank you - I've fixed it and it works without the vhd module. This solution is just based on https://sourceforge....rojects/vdfuse/

 

You have to customize the vdfuse files at some other positions, too. Furthermore libcurl3 and cryptsetup needs to be installed in the VM.

 

 

vdprepare.sh

#!/bin/sh
# script to install necessary files and update initramfs


echo "Installing vdfuse components"
cp ./vdfuse-minimal/sbin/vdfuse /usr/sbin
cp -R ./vdfuse-minimal/usr/lib/virtualbox /usr/lib


cp ./vdfuse-minimal/sbin/vdfuse /sbin
chmod 755 /sbin/vdfuse


chmod 755 /usr/sbin/vdfuse
chmod 755 /usr/lib/virtualbox/VBoxDDU.so
chmod 755 /usr/lib/virtualbox/VBoxRT.so


echo "Adding necessary files to initramfs"
cp ./initramfs-tools/hooks/vdfuse /usr/share/initramfs-tools/hooks
cp ./initramfs-tools/scripts/init-bottom/vdhost /usr/share/initramfs-tools/scripts/init-bottom
cp ./initramfs-tools/scripts/init-top/vdfuse /usr/share/initramfs-tools/scripts/init-top


chmod 755 /usr/share/initramfs-tools/hooks/vdfuse
chmod 755 /usr/share/initramfs-tools/scripts/init-bottom/vdhost
chmod 755 /usr/share/initramfs-tools/scripts/init-top/vdfuse


echo "Updating initramfs"
update-initramfs -k all -c


echo "vdprepare completed successfully"
exit 0

initramfs-tools/hooks/vdfuse

#!/bin/sh -e
# initramfs hook for vdfuse


PREREQ=""


# Output pre-requisites
prereqs()
{
echo "$PREREQ"
}


case "$1" in
    prereqs)
prereqs
exit 0
;;
esac




. /usr/share/initramfs-tools/hook-functions


copy_exec `which printenv` /sbin


# Copy across the vdfuse binaries
if [ -e `which vdfuse` ]; then
    copy_exec `which vdfuse` /sbin
    mkdir -p /vdhost
else
    echo "couldn't find vdfuse"
fi

initramfs-tools/scripts/init-top/vdfuse

#!/bin/sh -e
# initramfs init-top script for vdfuse


PREREQ="udev"


# Output pre-requisites
prereqs()
{
echo "$PREREQ"
}


case "$1" in
    prereqs)
prereqs
exit 0
;;
esac


if [ ! -z $vdisk ]; then
echo "vdfuse: looking for virtual disk"


mkdir /vdhost
mkdir /dev/vdhost


while [ -z "$HOSTFSTYPE" ]; do
echo "vdfuse: waiting for host..."
HOSTFSTYPE=`wait-for-root $host 30`
if [ -z "$HOSTFSTYPE" ] && ! try_failure_hooks; then
break
fi
done
if [ -e $host ]; then
echo "vdfuse: found $host with filesystem - $HOSTFSTYPE"
fi
echo "vdfuse: proceeding with mounting host and vdisk"


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


if [ -e $encroot ]; then
echo "vdfuse: found encrypted volume $encroot. Trying to mount it."




# hack to prevent kernel from mounting encrypted partition(s) automatically (which will turn wrong since the installation was done through VM and the device mapped through UUID is not valid for real-boot"
# rm -f /conf/conf.d/cryptroot


# try mounting the encrypted partition in the VHD to a temporary
# map so that it gets recognized by vgscan that follows
cryptsetup luksOpen $encroot tmproot


# Detect and activate available volume groups
/sbin/lvm vgscan
/sbin/lvm vgchange -a y --sysinit
fi


if [ -e $root ]; then
echo "vdfuse: found $root"
fi


mount $bootpart /boot
echo "vdfuse: successfully mounted required filesystems"
fi

initramfs-tools/scripts/init-bottom/vdhost

#!/bin/sh -e
# initramfs init-bottom script for vdfuse


PREREQ=""


# Output pre-requisites
prereqs()
{
echo "$PREREQ"
}


case "$1" in
    prereqs)
prereqs
exit 0
;;
esac


# Move /vdhost to the real filesystem
if [ -d ${rootmnt}/vdhost ]; then
mount -n -o move /vdhost ${rootmnt}/vdhost
fi

The GRUB2 on the boot stick was installed as described on https://www.pendrive...m-ubuntu-linux/

 

I've created my grub.cfg as followed, the variables are

  • (hd0,msdos3)/TestVHD.vhd => Partition where your VHD is located
  • (lp0,1)/boot/vmlinuz-5.0.0-23-generic => Partition and path of your loop where your vmlinuz is located and customize the versions
  • (lp0,1)/boot/initrd.img-5.0.0-23-generic => Partition and path of your loop where your initrd is located and customize the versions
  • /dev/sdb3 => Partition where your VHD is located 
  • Partition1 => The partition where your root file system of the VHD is located (PartitionX with X for your root partition)
  • /TestVHD.vhd => Path to your VHD file located on the defined host partition

 

grub.cfg

set timeout=10
set default=0

menuentry "Ubuntu TestVM" {
  insmod part_msdos
  insmod ext2
  set vhd='(hd0,msdos3)/TestVHD.vhd'
  set vdhost search --no-floppy -s root -t VHD -w -f $vhd
  loopback lp0 $vhd tdisk=VHD
  linux   (lp0,1)/boot/vmlinuz-5.0.0-23-generic host=/dev/sdb3 root=/dev/vdhost/Partition1 vdisk=/TestVHD.vhd quiet splash rw rootdelay=120
  initrd  (lp0,1)/boot/initrd.img-5.0.0-23-generic
}

Edited by Imperator, 4 weeks ago.


#118 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 3 weeks ago

Very good :), thanks for detailing your solution.

Still (IMHO) the kpartk/losetup approach (without vdfuse and limited to "static" .vhd's) is simpler.

I will post a cross reference to your post here:
http://reboot.pro/to...side-vhd/page-2
where user oxinos tried using vdfuse but failed and resorted to kpartx/losetup, succeeding this time, so that people may be able to find (and try) both approaches.

:duff:
Wonko





Also tagged with one or more of these keywords: linux, windows, boot, vhd, image-file, howto

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users