Difference between revisions of "CentOS 7.x installing lxc"

From Notes_Wiki
(Created page with "<yambe:breadcrumb>CentOS_7.x_lxc|CentOS 7.x lxc</yambe:breadcrumb> =CentOS 7.x installing lxc= To install lxc use following steps: # Install lxc package using #:<pre> #::...")
 
m
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
<yambe:breadcrumb>CentOS_7.x_lxc|CentOS 7.x lxc</yambe:breadcrumb>
[[Main Page|Home]] > [[CentOS]] > [[CentOS 7.x]] > [[CentOS 7.x virtualization|Virtualization]] > [[CentOS 7.x lxc|Lxc]] > [[CentOS 7.x installing lxc]]
=CentOS 7.x installing lxc=


To install lxc use following steps:
To install lxc use following steps:
Line 33: Line 32:




<yambe:breadcrumb>CentOS_7.x_lxc|CentOS 7.x lxc</yambe:breadcrumb>
==Get more space for lxc containers==
 
To get more space for lxc-containers from other partition which by default use /var use following steps:
'''(Replace /mnt/data1 in below steps and commands with mount-point where more space is available in your installation)'''
# Stop all running containers.  Verify 'lxc-ls --active'
# mkdir /mnt/data1/lxc-files
# mkdir /mnt/data1/lxc-files/{var_cache_lxc,var_lib_lxc}
# mv /var/cache/lxc/* /mnt/data1/lxc-files/var_cache_lxc/
#:The above command can generate "No such file or directory" error if the cache is empty.  This is likely on a new machine where no container has been created yet.
# rmdir /var/cache/lxc
# ln -s /mnt/data1/lxc-files/var_cache_lxc/ /var/cache/lxc
# mv /var/lib/lxc/* /mnt/data1/lxc-files/var_lib_lxc/
#:The above command can generate "No such file or directory" error if the lib_lxc folder is empty.  This is possible if there are no containers running or stopped on current machine.
# rmdir /var/lib/lxc
# ln -s /mnt/data1/lxc-files/var_lib_lxc/ /var/lib/lxc
# lxc-ls
# Start a few containers and test
 
 
==Additional configuration==
 
After basic installation and getting more space for lxc containers consider doing:
* Disable SELinux
* [[CentOS 7.x lxc container networking]] '''or'''
*: [[Creating bridge interfaces (br0) for virtual hosts to use shared interface]]
* Read [[CentOS 7.x lxc container hanging issue]] and create centos containers accordingly.
* [[CentOS 7.x lxc package installation issue]]
* Issue [[CentOS 7.x 100% CPU usage issue with CentOS7 or fedora lxc containers]] does not seems to happen on new installations so the correponding change may not be required in new installations.
 
 
 
[[Main Page|Home]] > [[CentOS]] > [[CentOS 7.x]] > [[CentOS 7.x virtualization|Virtualization]] > [[CentOS 7.x lxc|Lxc]] > [[CentOS 7.x installing lxc]]

Latest revision as of 09:03, 25 August 2022

Home > CentOS > CentOS 7.x > Virtualization > Lxc > CentOS 7.x installing lxc

To install lxc use following steps:

  1. Install lxc package using
    yum -y install epel-release
    yum -y install debootstrap perl libvirt libcap-devel libcgroup wget bridge-utils
    yum -y install lxc lxc-templates lxc-extra
  2. Check that system supports lxc
    lxc-checkconfig
    Before booting a new kernel its support for lxc-can be checked using:
    CONFIG=/boot/config-3.10.0-514.2.2.el7.x86_64 /bin/lxc-checkconfig
    where config-3.10.0-514.2.2.el7.x86_64 should be replaced with configuration file for new kernel
  3. Start and enable lxc on boot
    systemctl start lxc.service
    systemctl enable lxc.service
    systemctl status lxc.service
  4. Reboot base host for more stability


Refer:


Get more space for lxc containers

To get more space for lxc-containers from other partition which by default use /var use following steps: (Replace /mnt/data1 in below steps and commands with mount-point where more space is available in your installation)

  1. Stop all running containers. Verify 'lxc-ls --active'
  2. mkdir /mnt/data1/lxc-files
  3. mkdir /mnt/data1/lxc-files/{var_cache_lxc,var_lib_lxc}
  4. mv /var/cache/lxc/* /mnt/data1/lxc-files/var_cache_lxc/
    The above command can generate "No such file or directory" error if the cache is empty. This is likely on a new machine where no container has been created yet.
  5. rmdir /var/cache/lxc
  6. ln -s /mnt/data1/lxc-files/var_cache_lxc/ /var/cache/lxc
  7. mv /var/lib/lxc/* /mnt/data1/lxc-files/var_lib_lxc/
    The above command can generate "No such file or directory" error if the lib_lxc folder is empty. This is possible if there are no containers running or stopped on current machine.
  8. rmdir /var/lib/lxc
  9. ln -s /mnt/data1/lxc-files/var_lib_lxc/ /var/lib/lxc
  10. lxc-ls
  11. Start a few containers and test


Additional configuration

After basic installation and getting more space for lxc containers consider doing:


Home > CentOS > CentOS 7.x > Virtualization > Lxc > CentOS 7.x installing lxc