virt-manager / virt-bootstrap

GNU General Public License v3.0
78 stars 21 forks source link

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

Open maratbn opened 6 years ago

maratbn commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

Queuecumber commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

@dinoRkz What is the output of:

$ mkdir /tmp/test
$ skopeo copy docker://ubuntu:latest dir:/tmp/test
dinotumu commented 5 years ago

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 commented 5 years ago

@rst0git Please have a look at https://github.com/containers/skopeo/issues/181

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

I tried executing the above command, and it worked.

dinotumu commented 5 years ago

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 commented 5 years ago

Do you have libvirt-sandbox installed?

dinotumu commented 5 years ago

Thank you and sorry for bothering you. I realised that I have to delete ubuntu. Installed fedora. Followed all the steps mentioned above including https://github.com/virt-manager/virt-bootstrap/issues/2#issuecomment-407006369

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 commented 5 years ago

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

dinotumu commented 5 years ago

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

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