Skip to content

Commit

Permalink
docs: add post - Run libvirt in distrobox
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Dec 19, 2022
1 parent a25d8b7 commit a1be45d
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 13 deletions.
10 changes: 5 additions & 5 deletions distrobox-create
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# DBX_CONTAINER_IMAGE
# DBX_CONTAINER_MANAGER
# DBX_CONTAINER_NAME
# DBX_CONTAINER_ENTRY
# DBX_CONTAINER_GENERATE_ENTRY
# DBX_NON_INTERACTIVE
# DBX_SUDO_PROGRAM

Expand All @@ -51,7 +51,7 @@ container_name_default="my-distrobox"
container_init_hook=""
container_manager="autodetect"
container_manager_additional_flags=""
container_entry=1
container_generate_entry=1
container_name=""
container_pre_init_hook=""
container_user_custom_home=""
Expand Down Expand Up @@ -105,7 +105,7 @@ done
[ -n "${DBX_CONTAINER_IMAGE}" ] && container_image="${DBX_CONTAINER_IMAGE}"
[ -n "${DBX_CONTAINER_MANAGER}" ] && container_manager="${DBX_CONTAINER_MANAGER}"
[ -n "${DBX_CONTAINER_NAME}" ] && container_name="${DBX_CONTAINER_NAME}"
[ -n "${DBX_CONTAINER_ENTRY}" ] && container_entry="${DBX_CONTAINER_ENTRY}"
[ -n "${DBX_container_generate_entry}" ] && container_generate_entry="${DBX_container_generate_entry}"
[ -n "${DBX_NON_INTERACTIVE}" ] && non_interactive="${DBX_NON_INTERACTIVE}"
[ -n "${DBX_SUDO_PROGRAM}" ] && distrobox_sudo_program="${DBX_SUDO_PROGRAM}"

Expand Down Expand Up @@ -215,7 +215,7 @@ while :; do
;;
--no-entry)
shift
container_entry=0
container_generate_entry=0
;;
-d | --dry-run)
shift
Expand Down Expand Up @@ -728,7 +728,7 @@ if eval ${cmd} > /dev/null; then

# We've created the box, let's also create the entry
if [ "${rootful}" -eq 0 ]; then
if [ "${container_entry}" -ne 0 ]; then
if [ "${container_generate_entry}" -ne 0 ]; then
"$(dirname "$(realpath "${0}")")/distrobox-generate-entry" "${container_name}"
fi
fi
Expand Down
14 changes: 9 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ graphical apps (X11/Wayland), and audio.
- [Build a Gentoo distrobox container](distrobox_gentoo.md)
- [Build a Dedicated distrobox container](distrobox_custom.md)
- [Posts](posts/posts.md)
- [Run Libvirt using distrobox](posts/run_libvirt_in_distrobox.md)
- [Run latest GNOME and KDE Plasma using distrobox](posts/run_latest_gnome_kde_on_distrobox.md)
- [Integrate VSCode and Distrobox](posts/integrate_vscode_distrobox.md)
- [Execute a command on the Host](posts/execute_commands_on_host.md)
Expand All @@ -103,9 +104,12 @@ graphical apps (X11/Wayland), and audio.
- [Japanese input on Clear Linux with Mozc via Ubuntu container with Distrobox](https://impsbl.hatenablog.jp/entry/JapaneseInputOnClearLinuxWithMozc_en)
- [MID (MaXX Interactive Desktop) on Clear Linux via Ubuntu container with Distrobox](https://impsbl.hatenablog.jp/entry/MIDonClearLinuxWithDistrobox_en)
- [Running Other Linux Distros with Distrobox on Fedora Linux - bandithijo's blog](featured_articles.md)
- [Talks](featured_articles.md#talks)
- [Talks and Videos](featured_articles.md#talks)
- [Linux App Summit 2022 - Distrobox: Run Any App On Any Distro - BoF](https://github.com/89luca89/distrobox/files/8598433/distrobox-las-talk.pdf)
- [Opensource Summit 2022 - Distrobox: Run Any App On Any Distro](https://www.youtube.com/watch?v=eM1p47tow4o)
- [A "Box" Full of Tools and Distros - Dario Faggioli @ OpenSUSE Conference 2022](https://www.youtube.com/watch?v=_RzARte80SQ)
- [Podman Community Meeting October 4, 2022](https://www.youtube.com/watch?v=JNijOHL4_Ko)
- [Distrobox opens the Steam Deck to a whole new world (GUIDE) - GamingOnLinux](https://www.youtube.com/watch?v=kkkyNA31KOA)
- [Podcasts](featured_articles.md#podcasts)

---
Expand Down Expand Up @@ -267,11 +271,11 @@ Example configuration file:

```conf
container_always_pull="1"
container_user_custom_home="$HOME/.local/share/container-home-test"
container_image="registry.opensuse.org/opensuse/toolbox:latest"
container_generate_entry=0
container_manager="docker"
container_name="test-name-1"
container_entry=0
container_image_default="registry.opensuse.org/opensuse/toolbox:latest"
container_name_default="test-name-1"
container_user_custom_home="$HOME/.local/share/container-home-test"
container_init_hook="~/.local/distrobox/a_custom_default_init_hook.sh"
container_pre_init_hook="~/a_custom_default_pre_init_hook.sh"
non_interactive="1"
Expand Down
1 change: 0 additions & 1 deletion docs/posts/run_latest_gnome_kde_on_distrobox.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

---


⚠️ **BE CAREFUL**:⚠️ THIS IS EXPERIMENTAL, JUST FOOD FOR TOUGHTS

# Using a stable-release distribution
Expand Down
76 changes: 76 additions & 0 deletions docs/posts/run_libvirt_in_distrobox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
- [Distrobox](../README.md)
- [Run Libvirt using distrobox](run_libvirt_in_distrobox.md)
- [Prepare the container](#prepare-the-container)
- [Connect from the host](#connect-from-the-host)

# Using an immutable distribution

If you are on an immutable distribution (Silverblue/Kionite, MicroOS) chances are that
installing lots and lots of packages on the base system is not advisable.

One way is to use a distrobox for them.

## Prepare the container

To run libvirt/qemu/kvm we need a systemd container and we need a **rootful** container
to be able to use it, see [this tip](../useful_tips.md#using-init-system-inside-a-distrobox)
to have a list of compatible images.
We will use in this example AlmaLinux 8:

```console
:~> distrobox create --root --init --image quay.io/almalinux/8-init:8 --name libvirtd-container
:~> distrobox enter --root libvirtd-container
```

Let it initalize, then we can install all the packages we need:

```console
:~> distrobox enter --root libvirtd-container
:~$ # We're now inside the container
:~$ sudo dnf groupinstall Virtualization Host --allowerasing
...
:~$ sudo systemctl enable --now libvirtd
```

Now we need to allow host to connect to the guest's libvirt session, we will use
ssh for it:

```console
:~$ # We're now inside the container
:~$ sudo dnf install openssh-server
:-$ echo "ListenAddress 127.0.0.1
Port 2222" | sudo tee -a /etc/ssh/sshd_config
:-$ sudo systemctl enable --now sshd
:-$ sudo systemctl restart sshd
:~$ sudo su -
:~# passwd
```

Now set a password for root user.

## Connect from the host

You can now install VirtManager, you can either use a normal (non root) distrobox, and export the app

Now you will need to **Add a connection**:

![image](https://user-images.githubusercontent.com/598882/208441337-4dbade85-4c72-4342-b9ee-acd76b9b1675.png)

Then set it like this:

![image](https://user-images.githubusercontent.com/598882/208441499-e612868f-d9d1-452c-8bfb-110440e2e891.png)

- Tick the "Use ssh" option
- username: root
- hostname: 127.0.0.1:2222

Optionally you can set it to autoconnect.

Now you can simply double click the connection to activate it, you'll be prompted
with a password, insert the one you used in the `passwd` step previously:

![image](https://user-images.githubusercontent.com/598882/208441932-f561af0b-9c19-45f7-bacc-d690d80b75e1.png)

And you should be good to go!

![image](https://user-images.githubusercontent.com/598882/208442009-fe9df606-e6a8-44f9-94c2-1c2bfba4ca15.png)
6 changes: 4 additions & 2 deletions docs/useful_tips.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- [Distrobox](README.md)
- [Launch a distrobox from you applications list](#launch-a-distrobox-from-you-applications-list)
- [Create a distrobox with a custom HOME directory](#create-a-distrobox-with-a-custom-home-directory)
- [Mount additional volumes in a distrobox](#mount-additional-volumes-in-a-distrobox)
- [Use a different shell than the host](#use-a-different-shell-than-the-host)
Expand All @@ -17,8 +18,6 @@
- [Container save and restore](#container-save-and-restore)
- [Check used resources](#check-used-resources)
- [Pre-installing additional package repositories](#pre-installing-additional-package-repositories)
- [Build a Gentoo distrobox container](distrobox_gentoo.md)
- [Build a Dedicated distrobox container](distrobox_custom.md)
- [Apply resource limitation on the fly](#apply-resource-limitation-on-the-fly)

---
Expand Down Expand Up @@ -214,6 +213,9 @@ Example of such images are:
- docker.io/almalinux/8-init
- registry.access.redhat.com/ubi7/ubi-init
- registry.access.redhat.com/ubi8/ubi-init
- registry.access.redhat.com/ubi9/ubi-init
- registry.opensuse.org/opensuse/leap:latest
- registry.opensuse.org/opensuse/tumbleweed:latest
You can use such feature using:
Expand Down

0 comments on commit a1be45d

Please sign in to comment.