Skip to main content
## Overview This Tutorial is on how to build a custom LXC template with a desktop environment and audio working in xrdp. This method can be used to build custom templates with or without GUI desktop. Building custom template will take less than 30 minutes, mostly for downloading new software. Go to section * [Introduction](#introduction) * [Installing apps and tools](#installing-apps-and-tools) * [Installing GUI desktop Environment](#installing-gui-desktop-environment) * [Fixing the sound output](#fixing-the-sound-output) * [Creating LXC template](#creating-lxc-template) * [Conclusion ](#conclusion ) * [References](#references ) *** ## Introduction Creating custom templates with your favorite software and settings will save you time when deploying new containers because you don't have to keep changing, updating and installing the same software on each new container. In the example below, after installing the desktop environment the template size was 690M. I hope this tutorial will be useful to those that like to use graphics GUI desktop and don't have time or hardware resource to install VMs. I spent a lot of time researching and reading other peoples posts over the internet, unfortunately, i didn't find a clear direction, how to use LXC desktop at least to my level of understanding. See the reference section for sites that were helpful in developing this tutorial . I also put the instructions here [Link](https://tech.taha.us/2020/07/create-desktop-environment-container-in.html) so that i can track and update issues i encountered as i learn more about proxmox and LXC. The only remaining problem i have is getting to sound output to work in the container after each restart. Right now i have to reset the pulseaudio in the container every time i reboot/start the container. Maybe a custom Corn job to automate this audio output restart. if someone has a better way of getting the sound to work please let me know. *** ## Installing apps and tools 1. create a container, give it 4G of storage, 2 cores, 2048 RAM, specify the IP (ex: 192.168.1.20/24), Gateway (ex: 192.168.1.1). This settings are just temporary. 2. once you start the new LXC container. Log in as root and edit source list by adding the following sources: `nano /etc/apt/sources.list` ```bash deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse deb http://archive.canonical.com/ubuntu focal partner deb-src http://archive.canonical.com/ubuntu focal partner ``` 3. install Firefox browser or any software you like to have in your templates (for example terminator, openssh-server...) `sudo apt-get install firefox -y` `sudo apt-get install terminator -y` # Installing GUI desktop Environment 4. install the desktop environment: during the install you will see a pop-up screen asking which desktop you want : select lighdm. ``` sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils ``` since we want to access the container through remote RDP, install XRDP ``` sudo apt install xrdp ``` 5. Verify xrdp installed correctly and is running: ``` sudo systemctl status xrdp ``` 6. once RDP is installed we need to add this code, so that desktop manager know what to use for display: ``` update-alternatives --set x-session-manager /usr/bin/xfce4-session ``` 7. if you wanted to use ubuntu Mate desktop environment use the following: ``` sudo apt install lightdm ubuntu-mate-core ubuntu-mate-desktop -y ``` ``` sudo update-alternatives --set x-session-manager /usr/bin/mate-session ``` # Fixing the sound output First get latest download link of the script "xrd-installer-1.2" from this [website](https://www.c-nergy.be/products.html): ```bash cd /opt wget http://c-nergy.be/downloads/xRDP/xrdp-installer-1.2.zip unzip xrdp* chmod +x xrdp-installer-1.2.sh ``` 8. create a new user if you don't already have one: ```bash adduser admin usermod -aG sudo admin su admin ./xrdp-installer-1.2.sh -s ``` 9. reboot container. ``` reboot ``` 10. After rebooting the container, you may still have a Dummy output in the Volume control and no sound output. To fix the issue restart pulseaudio server in the container by running the following command: `pulseaudio -k` After pulseaudio is restarted, the sound should start to work with xrdp sink appearing in the volume control. *** # Creating LXC template 11. crate a backup of the new created LXC as as GZIP. first, turn off the LXC container and then do the backup from Proxmox GUI. Pve-> select container_ —> Backup now—> compression select GZIP (good) 12. once the backup is completed. Go the Shell of Proxmox: copy the new file created to the folder where Proxmox saves templates and give it a new name. Template and Backup folders depend on original Proxmox setup. in my case for example: /Template/folder: /zfs-pool/zfs-iso-template/template/cache /Backup/folder/file: /zfs-pool/zfs-backups/dump/vzdump-lxc-.tar.gz ``` cp /backup/folder/file-.tar.gz /template/folder/new-name.tar.gz ``` 13. That's it! Now when you go to create a new container, you will have the new template with your custom settings per-installed. *** # Conclusion LXC uses less resources and is a good alternative to VMs for those that are primarily testing in Linux and don't have many cores to spare. Hopefully, this tutorial will make you more efficient and save your time for more-important testing. *** # References: [https://github.com/neutrinolabs/xrdp](https://github.com/neutrinolabs/xrdp) [https://linuxize.com/post/how-to-install-xrdp-on-ubuntu-18-04/](https://linuxize.com/post/how-to-install-xrdp-on-ubuntu-18-04/) [https://github.com/bmullan/ciab-remote-desktop/blob/master/mk-cn1-environment.sh](https://github.com/bmullan/ciab-remote-desktop/blob/master/mk-cn1-environment.sh) [https://linuxconfig.org/8-best-ubuntu-desktop-environments-18-04-bionic-beaver-linux](https://linuxconfig.org/8-best-ubuntu-desktop-environments-18-04-bionic-beaver-linux) [http://c-nergy.be/blog/?p=14888](http://c-nergy.be/blog/?p=14888) [https://www.closingtags.com/custom-lxc-container-templates-in-proxmox-5-0/](https://www.closingtags.com/custom-lxc-container-templates-in-proxmox-5-0/) [https://blog.simos.info/how-to-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/](https://blog.simos.info/how-to-run-graphics-accelerated-gui-apps-in-lxd-containers-on-your-ubuntu-desktop/)

Comments

Popular posts from this blog

Create a desktop environment container in Proxmox and set it up as template

test Overview This Tutorial is on how to build a custom LXC template with a desktop environment and audio working in xrdp. This method can be used to build custom templates with or without GUI desktop. Building custom template will take less than 30 minutes, mostly for downloading new software. Go to section: Introduction Installing apps and tools Installing GUI desktop Environment Fixing the sound output Creating LXC template Conclusion References Introduction Creating custom templates with your favorite software and settings will save you time when deploying new containers because you don’t have to keep changing, updating and installing the same software on each new container. In the example below, after installing the desktop environment the template size was 690M. I hope this tutorial will be useful to those that like to use graphics GUI desktop and don’t have time or hardware resource to install VMs. I spent a lot of time researching and reading ...

Getting the sound to work in LXC container with RDP

As a followup to my last post (link) for creating a container with desktop environment in proxmox, i will try to share a solution i found in getting the sound to work. The solution came from the folks at Griffon’s IT Library: link Per the developers of the script: “The xRDP installer script can ease the installation of xRDP packages on Ubuntu machines. The xRDP installer script perform additional post configuration actions that provides the best remote Desktop user experience.” The sound problem appear to be a common issue with some users of ubuntu 19.10 and in xrdp as reported in this site . In any case, the script by Griffon provides a quick fix to the sound in xRDP on Ubuntu. I found that his quick fix works in LXC container too! Here are the steps: get latest download link of xrd-installer-1.2 from this website: cd opt wget http://c-nergy.be/downloads/xRDP/xrdp-installer-1.2.zip unzip xrdp* chmod +x xrdp-installer-1.2.sh create a new user if you don’t already have one: adduser...