Guide - ClearOS LXC Container

ben90818532

Active Member
Sep 20, 2017
23
1
43
34
This is a guide for creating and running ClearOS in a Proxmox LXC container:

1) Install ClearOS 7.4 in a KVM virtual machine using Proxmox

2) After installation, go into the VM's terminal using Proxmox web interface and install rsync with: yum install rsync

Run these commands to enable SSH:
Code:
sed -i '/#PermitRootLogin yes/c\PermitRootLogin yes' /etc/ssh/sshd_config
sed -i '/#PasswordAuthentication yes/c\PasswordAuthentication yes' /etc/ssh/sshd_config

3) Create a new unprivileged LXC container using the CentOS 7 template and start it

4) Login to the Proxmox host running the LXC container using SSH and login to the root shell of the container using: pct enter 107 (number before this is the Proxmox LXC container number).

5) Install nano on the LXC container: yum install nano

6) Create a script in the container, we will call it: setup.sh and paste the contents below (editing as needed)

Code:
#!/bin/bash

# Install rsync in the target and destination servers
yum -y install rsync

# Copy data from the target to destination
rsync -avzp --ignore-errors --exclude="tmp" --exclude="sys" --exclude="lost+found" --exclude="mnt" --exclude="proc" --exclude="dev" --exclude="media" --exclude="etc/securetty" --exclude="etc/fstab" root@192.168.0.237:/* /

# Disable pam_limits (was causing problems with root console login and login to web gui)
sed -i '/session     required      pam_limits.so/c\#session     required      pam_limits.so' /etc/pam.d/system-auth-ac
sed -i '/session     required      pam_limits.so/c\#session     required      pam_limits.so' /etc/pam.d/password-auth-ac
sed -i '/session     required      pam_limits.so/c\#session     required      pam_limits.so' /etc/pam.d/system-auth
sed -i '/session     required      pam_limits.so/c\#session     required      pam_limits.so' /etc/pam.d/password-auth
sed -i '/session    required     pam_limits.so/c\#session    required     pam_limits.so' /etc/pam.d/sudo
sed -i '/session                required        pam_limits.so/c\##session                required        pam_limits.so' /etc/pam.d/runuser

# Enable SSH remote login including via root
sed -i '/#PermitRootLogin yes/c\PermitRootLogin yes' /etc/ssh/sshd_config
sed -i '/#PasswordAuthentication yes/c\PasswordAuthentication yes' /etc/ssh/sshd_config

7) Set the scripts permissions: chmod 755 setup.sh then run it ./setup.sh you will be prompted for the ssh password to the KVM virtual machine.

8) After script finishes running reset the root password: passwd root

9) Shutdown the LXC container using Proxmox web interface then start it again.

10) You should now be able to login to ClearOS web interface at https://lxccontainerip:81

11) Before you start configuring ClearOS, considering shutting down the container and taking a TGZ backup using the Proxmox web gui.

12) Take note of the name of the backup file in the Proxmox web interface as it is being created as afterwards you can search for it on the Proxmox host using:
1) cd /
2) find -iname vzdump-lxc-107-2018_01_19-05_07_51.tar.gz

Once you find it's path you can then move it to your storage template location, in this case it's located on the Proxmox hosts local storage:

Example command:
mv /pathtovzdump/vzdump-lxc-107-2018_01_19-05_07_51.tar.gz /var/lib/vz/template/cache/

Now you can deploy ClearOS from a template in Proxmox. :)

Note: This is not for production environments and should only be used for testing purposes, parts of ClearOS will NOT function in an LXC environment such as Samba mounts, also security may be reduced. Practical uses include as web server or mail server.

Note2: This is a pretty complicated guide that took about 15 hours of non-stop research to create. Please let me know if you find problems.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!