пятница, 29 ноября 2019 г.

orel установка lxc

FireJail и LXC
$ sudo apt install bridge-utils
$ ip a
192.168.0.120
$ sudo nano /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback
#auto eth0
#iface eth0 inet dhcp
#iface  eth0 inet static
#address 192.168.0.120
#netmask 255.255.255.0
#gateway 192.168.0.1
#dns-nameservers 8.8.8.8

##Bridge  Name ###
auto br0

# Bridge setup
iface br0 inet static
   bridge_ports  eth0
       address 192.168.0.120
       broadcast 192.168.0.255
       netmask 255.255.255.0
       gateway 192.168.0.1
   bridge_stp off
   bridge_fd 9

Сохранить.

$ sudo reboot


$ sudo apt install lxc lxc-dev cgroup-tools
$ sudo apt install lxc-astra
$ sudo nano /etc/default/lxc-net

USE_LXC_BRIDGE="false"

$ sudo nano /etc/lxc/default.conf

lxc.network.type = veth
lxc.network.link = br0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx

$ sudo service lxc-net restart

$ sudo lxc-create -t astralinux-ce -n astra

$ sudo lxc-start -n astra
#$ sudo lxc-stop -n astra
#$ sudo lxc-destroy -n astra
$ sudo lxc-ls -f
NAME  STATE   AUTOSTART GROUPS IPV4         IPV6
astra RUNNING 0         -      192.168.0.73 -

$ sudo lxc-console -n astra
admin
astralinux

$ sudo nano /etc/apt/sources.list
Изменить на http
$ sudo apt update
$ sudo apt install apt-transport-https
$ sudo nano /etc/apt/sources.list
Изменить на https
$ sudo apt update
$ sudo dpkg-reconfigure locales
## Выбираем ru_RU.UTF-8
$ sudo dpkg-reconfigure tzdata
$ sudo apt install keyboard-configuration
## dpkg-reconfigure keyboard-configuration
$ sudo apt install mc ssh fly-data fly-wm
$ sudo reboot
$ sudo lxc-console -n astra

Можно заходить по xrdp

Перенос контейнера lxc в lxd на другую машину

$ sudo -i
# cd /var/lib/lxc/astra/
# tar --numeric-owner -jcvf astra.tar.bz2 rootfs/


$ lxc launch images:debian/9 ast
$ lxc stop ast
$ sudo -i
$ cd /var/lib/lxd/containers/ast
# ls -n

# rm -rf  /var/lib/lxd/containers/ast/rootfs/
# tar jxfv /home/user/astra.tar.bz2


# exit

$ nano changeuid.sh

#!/bin/bash
####################################################
# This Skript changed all uids & gids in the path of
# '$1' to BASE_UID + uid & BASE_GID + gid
#
# License: GPLv3 or higher
####################################################

###
# You might need to change these:
BASE_UID=100000
BASE_GID=100000
###

# Params & Usage
DIR=$1
if [ -z "$DIR" ] ; then
    echo "Usage: $0 <Directory>"
    exit 1
fi

IFS=$'\n'
echo "Starting chown on $DIR... this might take a while..."
for line in $(find $DIR -exec stat -c '%n:%u:%g' {} \;) ; do
    # Split line into variables
    file=$(echo $line | cut -f1 -d:)
    old_owner=$(echo $line | cut -f2 -d:)
    old_group=$(echo $line | cut -f3 -d:)

    # Skip if something went wrong
    [ -z "$file" -o -z "$old_owner" -o -z "$old_group" ] && continue

    # Calculate new uids/gids
    new_owner=$old_owner
    new_group=$old_group
    if [ $old_owner -lt $BASE_UID ] ; then
        new_owner=$(($BASE_UID + $old_owner))
    fi

    if [ $old_group -lt $BASE_GID ] ; then
        new_group=$(($BASE_GID + $old_group))
    fi

    # Set new owner/group if it has to be changed
    if [ $new_owner -ne $old_owner -o $new_group -ne $old_group ] ; then
        echo "Changing: $file from $old_owner:$old_group to $new_owner:$new_group"
        chown $new_owner:$new_group "$file"
    fi
done

echo "DONE!"
exit 0

Сохранить.

$ sudo sh changeuid.sh /var/lib/lxd/containers/ast/rootfs/

$ sudo -i
$ cd /var/lib/lxd/containers/ast
# ls -n
$ lxc copy ast astra
$ lxc config set astra security.privileged true
$ lxc start astra
$ lxc exec astra bash
# nano /etc/apt/sources.list
http
Сохранить.
# apt update
# apt install apt-transport-https
# nano /etc/apt/sources.list
https
Сохранить.
# apt update
# apt install mc ssh
# dpkg-reconfigure locales
## Выбираем ru_RU.UTF-8
# dpkg-reconfigure tzdata
# apt install keyboard-configuration
## dpkg-reconfigure keyboard-configuration
# apt install fly-data fly-wm
$ sudo reboot
$ lxc exec astra bash

# apt install fly-data fly-wm
# apt install xrdp
# restart







Комментариев нет:

Отправить комментарий