Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How would I install 'virt-bootstrap' on Ubuntu 18.04? #2

Open
maratbn opened this issue Jul 16, 2018 · 14 comments
Open

How would I install 'virt-bootstrap' on Ubuntu 18.04? #2

maratbn opened this issue Jul 16, 2018 · 14 comments

Comments

@maratbn
Copy link

maratbn commented Jul 16, 2018

I'm using virt-manager on Ubuntu 18.04, and I specified in the virt-manager UI to create a new Libvirt-LXC virtual machine that is an operating system container. The UI then asks me to provide an existing OS root directory, but also implies that such a directory can be created with the message "To enable OS directory tree creation, please install virt-bootstrap".

2018-07-15--01--screenshot--create-a-new-virtual-machine--re--virt-bootstrap

I could not find a .deb package for this project, so I suppose it would be done manually, or perhaps by installing another package that includes it? What would be the procedure to install this software on Ubuntu 18.04 and configuring it so that virt-manager could use it?

Thanks,
Marat

@rst0git
Copy link
Collaborator

rst0git commented Jul 16, 2018

Hi Marat,
virt-bootstrap does not have a debian package yet, but you can install it using the following steps:

$ git clone https://github.com/virt-manager/virt-bootstrap
$ cd virt-bootstrap
$ sudo python setup.py install

Note that virt-bootstrap has the following dependencies: libvirt, libvirt-sandbox, skopeo, python-guestfs, python-passlib

@maratbn
Copy link
Author

maratbn commented Jul 19, 2018

Thanks @rst0git , the installation procedure worked after I also did apt install python-setuptools python-passlib python-guestfs for the Python dependencies.

@Queuecumber
Copy link

But you still need to do a lot to actually make it functional. For example, skopeo I had to get from this ppa or I had an error.

Now I am getting the following error from virt-manager when trying to run docker://docker.io/ubuntu:18.04 as a test

Unable to complete install: 'virt-bootstrap did not complete successfully'

Command 'virt-sandbox -c qemu:///session --name=bootstrap_8019 -m host-bind:/mnt=/home/max/.local/share/libvirt/filesystems/container1 -- /bin/tar xf /home/max/.cache/virt-bootstrap/docker_images/7996ebd2246a962c134071d90f00119b8e4d228b66e4e2afc80991dd9ac1726a -C /mnt --exclude dev/* --overwrite --absolute-names' returned non-zero exit status 1
Checking layer: /home/max/.cache/virt-bootstrap/docker_images/7996ebd2246a962c134071d90f00119b8e4d228b66e4e2afc80991dd9ac1726a
Untar layer: /home/max/.cache/virt-bootstrap/docker_images/7996ebd2246a962c134071d90f00119b8e4d228b66e4e2afc80991dd9ac1726a
Call command:
virt-sandbox -c qemu:///session --name=bootstrap_8019 -m host-bind:/mnt=/home/max/.local/share/libvirt/filesystems/container1 -- /bin/tar xf /home/max/.cache/virt-bootstrap/docker_images/7996ebd2246a962c134071d90f00119b8e4d228b66e4e2afc80991dd9ac1726a -C /mnt --exclude dev/* --overwrite --absolute-names
Stderr:
libvirt-sandbox-init-qemu: mount_9pfs: cannot mount sandbox:root on /tmproot (9p): Invalid argument

any idea what I'm missing here?

@rst0git
Copy link
Collaborator

rst0git commented Jul 23, 2018

Hi @Queuecumber,

The error message:

libvirt-sandbox-init-qemu: mount_9pfs: cannot mount sandbox:root on /tmproot (9p): Invalid argument

shows that the mount syscall failed to mount 9p filesystem.
To fix it, try to:

modprobe 9pnet
modprobe 9pnet_virtio

Or you can run virt-manager/virt-bootstrap as root. This will make virt-bootstrap use LXC driver of libvirt instead of qemu-session when extracting the rootfs of the contianer image.

@Queuecumber
Copy link

Same error even after loading those modules and verifying that they are loaded. I run libvirt as my local user so that it can interface with pulseaudio, could that be the problem?

@dinotumu
Copy link

dinotumu commented Mar 2, 2019

Hey @rst0git @maratbn @Queuecumber @giuseppe @Antique
Can you please help me resolve this error?

username@PC:~/Downloads/virt-bootstrap-master/src/virtBootstrap$ sudo python virt_bootstrap.py docker://ubuntu:latest /home/dino/Downloads/ubuntu-rootfs
INFO : Checking cached layers
INFO : Downloading container image
Traceback (most recent call last):
File "virt_bootstrap.py", line 350, in
sys.exit(main())
File "virt_bootstrap.py", line 338, in main
progress_cb=args.status_only)
File "virt_bootstrap.py", line 152, in bootstrap
progress=prog).unpack(dest)
File "/usr/local/lib/python2.7/dist-packages/virtBootstrap/sources/docker_source.py", line 301, in unpack
self.fetch_layers()
File "/usr/local/lib/python2.7/dist-packages/virtBootstrap/sources/docker_source.py", line 289, in fetch_layers
self.download_image()
File "/usr/local/lib/python2.7/dist-packages/virtBootstrap/sources/docker_source.py", line 153, in download_image
self.read_skopeo_progress(skopeo_copy)
File "/usr/local/lib/python2.7/dist-packages/virtBootstrap/sources/docker_source.py", line 259, in read_skopeo_progress
raise subprocess.CalledProcessError(proc.returncode, ' '.join(cmd))
subprocess.CalledProcessError: Command 'skopeo copy docker://ubuntu:latest dir:/tmp/tmpP83wgwvirt-bootstrap' returned non-zero exit status 1

@rst0git
Copy link
Collaborator

rst0git commented Mar 2, 2019

@dinoRkz What is the output of:

$ mkdir /tmp/test
$ skopeo copy docker://ubuntu:latest dir:/tmp/test

@dinotumu
Copy link

dinotumu commented Mar 2, 2019

Hey, thanks for replying. This is the output of the above commands after execution.

FATA[0000] Error loading trust policy: open /etc/containers/policy.json: no such file or directory

I tried to open the /etc/containers directory, but it does not exist.

@dinotumu
Copy link

dinotumu commented Mar 3, 2019

@rst0git Please have a look at containers/skopeo#181

$ skopeo --insecure-policy copy docker://ubuntu:latest dir:/tmp/test

I tried executing the above command, and it worked.

@dinotumu
Copy link

dinotumu commented Mar 3, 2019

I tried to do some alternative fix from here https://github.com/containers/skopeo/blob/master/default-policy.json

And then I executed the command sudo python virt_bootstrap.py docker://ubuntu:latest /home/dino/Downloads/ubuntu-rootfs

The output of the above command is shown below. Could you please help me to resolve this error?

dino@Dinesh-PC:~/Downloads/virt-bootstrap-master/src/virtBootstrap$ sudo python virt_bootstrap.py docker://ubuntu:latest /home/dino/Downloads/ubuntu-rootfs
INFO : Checking cached layers
INFO : Extracting container layers
INFO : Extracting layer (1/4) with size: 30.87 MiB
Traceback (most recent call last):
File "virt_bootstrap.py", line 350, in
sys.exit(main())
File "virt_bootstrap.py", line 338, in main
progress_cb=args.status_only)
File "virt_bootstrap.py", line 152, in bootstrap
progress=prog).unpack(dest)
File "/usr/local/lib/python2.7/dist-packages/virtBootstrap/sources/docker_source.py", line 307, in unpack
utils.untar_layers(self.layers, dest, self.progress)
File "/usr/local/lib/python2.7/dist-packages/virtBootstrap/utils.py", line 344, in untar_layers
safe_untar(tar_file, dest_dir)
File "/usr/local/lib/python2.7/dist-packages/virtBootstrap/utils.py", line 287, in safe_untar
execute(virt_sandbox + params)
File "/usr/local/lib/python2.7/dist-packages/virtBootstrap/utils.py", line 254, in execute
stderr=subprocess.PIPE
File "/usr/lib/python2.7/subprocess.py", line 394, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

@rst0git
Copy link
Collaborator

rst0git commented Mar 3, 2019

Do you have libvirt-sandbox installed?

@dinotumu
Copy link

dinotumu commented Mar 3, 2019

Thank you and sorry for bothering you. I realised that I have to delete ubuntu. Installed fedora. Followed all the steps mentioned above including #2 (comment)

So, I have tried to run program using root, but, this error showed up:

[root@localhost virtBootstrap]# sudo python virt_bootstrap.py docker://ubuntu:latest /home/dino/Downloads/ubuntu-rootfs
INFO : Checking cached layers
INFO : Extracting container layers
INFO : Extracting layer (1/4) with size: 30.87 MiB
Traceback (most recent call last):
File "virt_bootstrap.py", line 350, in
sys.exit(main())
File "virt_bootstrap.py", line 338, in main
progress_cb=args.status_only)
File "virt_bootstrap.py", line 152, in bootstrap
progress=prog).unpack(dest)
File "/usr/lib/python2.7/site-packages/virtBootstrap/sources/docker_source.py", line 307, in unpack
utils.untar_layers(self.layers, dest, self.progress)
File "/usr/lib/python2.7/site-packages/virtBootstrap/utils.py", line 344, in untar_layers
safe_untar(tar_file, dest_dir)
File "/usr/lib/python2.7/site-packages/virtBootstrap/utils.py", line 287, in safe_untar
execute(virt_sandbox + params)
File "/usr/lib/python2.7/site-packages/virtBootstrap/utils.py", line 264, in execute
raise subprocess.CalledProcessError(proc.returncode, cmd_str)
subprocess.CalledProcessError: Command 'virt-sandbox -c lxc:/// --name=bootstrap_7997 -m host-bind:/mnt=/home/dino/Downloads/ubuntu-rootfs -- /bin/tar xf /var/cache/virt-bootstrap/docker_images/6cf436f81810f067c6d4ffca6793eae7cb6d38456715b0707d8a5a2d1acccf12 -C /mnt --exclude dev/* --overwrite --absolute-names --acls --xattrs --selinux' returned non-zero exit status 1

[root@localhost virtBootstrap]# virt-sandbox -c lxc:/// --name=bootstrap_7997 -m host-bind:/mnt=/home/dino/Downloads/ubuntu-rootfs -- /bin/tar xf /var/cache/virt-bootstrap/docker_images/6cf436f81810f067c6d4ffca6793eae7cb6d38456715b0707d8a5a2d1acccf12 -C /mnt --exclude dev/* --overwrite --absolute-names --acls --xattrs --selinux
2019-03-03 14:21:46.356+0000: 1: error : virCommandExec:2190 : cannot execute binary /etc/libvirt-sandbox/scratch/.libs/libvirt-sandbox-init-lxc: Permission denied
Failure in libvirt_lxc startup: cannot execute binary /etc/libvirt-sandbox/scratch/.libs/libvirt-sandbox-init-lxc: Permission denied

==============================================================================

EDIT: Screenshot of the output is here:

screenshot from 2019-03-03 14-25-58

@rst0git
Copy link
Collaborator

rst0git commented Mar 3, 2019

I think that the Permission denied error is caused by selinux, could you try with setenforce 0?

@dinotumu
Copy link

dinotumu commented Mar 4, 2019

Done!
Thanks for all your help. I hope this thread helps someone.

screenshot from 2019-03-04 21-17-58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants