linka-cloud / d2vm

Build Virtual Machine Image from Dockerfile or Docker image
Apache License 2.0
208 stars 31 forks source link

Error on VirtualBox image #9

Closed geneoes closed 1 year ago

geneoes commented 1 year ago

When running :

d2vm build -p MyP4Ssw0rd -f ubuntu.Dockerfile -o ubuntu.vdi .
Building docker image from ubuntu.Dockerfile
Inspecting image d2vm-4dca598b-8f4d-4c6e-b6c2-c36d145dcb2a
No network manager specified, using distribution defaults: netplan
Docker image based on Ubuntu 22.04.1 LTS (Jammy Jellyfish)
Building kernel enabled image
Creating vm image
Creating raw image
Mounting raw image
Build failed
Unmounting raw image
Failed to unmount
Error: losetup --show -f /tmp/d2vm/834629c7-f718-4d96-bbea-c7890c7a1a09/disk0.d2vm.raw: stdout:  stderr: losetup: cannot find an unused loop device
 error: exit status 1

I am running this inside an Ubuntu VirtualBox with a Windows host

Adphi commented 1 year ago

The relevant error is:

losetup: cannot find an unused loop device

Can you list the loop devices inside your vm ?

sudo losetup -a

If there is none, can you ensure the kernel module is enabled ?

sudo modprobe loop
Adphi commented 1 year ago

Ah... you have to use sudo to build the image...

geneoes commented 1 year ago

Ah... you have to use sudo to build the image...

Ahh right! I didn't because when using sudo: sudo: d2vm: command not found I installed it through brew install linka-cloud/tap/d2vm

Adphi commented 1 year ago

I always forget... since ubuntu 20.04 the user's $PATH is not preserved by sudo, so you need to run with the -E flag:

sudo -E d2vm ...
geneoes commented 1 year ago

hey yeah I tried but same message

sudo: d2vm: command not found

Adphi commented 1 year ago

what is the output of which d2vm ?

geneoes commented 1 year ago

what is the output of which d2vm ?

/home/linuxbrew/.linuxbrew/bin/d2vm

Adphi commented 1 year ago

can you show me your $PATH ?

echo $PATH
geneoes commented 1 year ago

/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

Adphi commented 1 year ago

Can you try sudo env "PATH=$PATH" d2vm ... ?

geneoes commented 1 year ago

That worked and the build finished successfully, thank you!

Adphi commented 1 year ago

You're welcome !