LXC Container in Centos7

https://der-linux-admin.de/2014/08/centos-7-centos-7-im-lxc-container/
http://libvirt.org/drvlxc.html

mkdir /zone1/dnshp/etc/yum.repos.d/ -p

cat /etc/yum.repos.d/CentOS-Base.repo |sed s/’$releasever’/7/g > /zone1/dnshp/etc/yum.repos.d/CentOS-Base.repo

yum groupinstall core –installroot=/zone1/dnshp –nogpgcheck -y

yum install plymouth libselinux-python bind –installroot=/zone1/dnshp –nogpgcheck -y

# yum install bind –installroot=/zone1/dnshp –nogpgcheck -y

chroot /zone1/dnshp

echo pw |passwd root –stdin

# login console

echo „pts/0“ >>/etc/securetty

sed -i s/“session    required     pam_selinux.so close“/“#session    required     pam_selinux.so close“/g /etc/pam.d/login

sed -i s/“session    required     pam_selinux.so open“/“#session    required     pam_selinux.so open“/g /etc/pam.d/login

sed -i s/“session    required     pam_loginuid.so“/“#session    required     pam_loginuid.so“/g /etc/pam.d/login

# login ssh

sed -i s/“session    required     pam_selinux.so close“/“#session    required     pam_selinux.so close“/g /etc/pam.d/sshd

sed -i s/“session    required     pam_loginuid.so“/“#session    required     pam_loginuid.so“/g /etc/pam.d/sshd

sed -i s/“session    required     pam_selinux.so open env_params“/“#session    required     pam_selinux.so open env_params“/g /etc/pam.d/sshd

cat > /etc/sysconfig/network << EOF

NETWORKING=yes

HOSTNAME=lxc.der-linux-admin.de

EOF

cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF

DEVICE=eth0

BOOTPROTO=dhcp

ONBOOT=yes

EOF

systemctl enable sshd

systemctl disable avahi-daemon

systemctl disable auditd

exit

yum install virt-install

yum install libvirt libvirt-client

yum install libvirt-daemon-lxc.x86_64 libvirt-daemon-driver-lxc.x86_64 

systemctl enable libvirt-guests

systemctl enable libvirtd

systemctl start libvirt-guests

systemctl start libvirtd

LXC setzt ein aktiviertes SE-Linux vorraus. Wir können dies aber etwas vereinfachen 

indem wir SE-Linux in dem permissive Modus versetzten. 

Dazu die Datei /etc/selinux/config wie folgt abändern.

SELINUX=permissive

Anschliessen muss das System einmal neu gestartet werden!

virt-install –connect lxc:/// –name dnshp –ram 1024 –vcpu 1  -b br0 –filesystem /zone1/dnshp,/ –noautoconsole

virsh –connect lxc:/// console dnshp

# start

virsh –connect lxc:/// start dnshp

# stop

virsh –connect lxc:/// destroy dnshp

# löschen

virsh –connect lxc:/// undefine dnshp

brctl addbr br0

brctl addif br0 enp2s0f1

Raspberry drives Stepper

# 5 wire Steppermotor  with driver uln2003 and i2c portmultiplexer pcf8574
# compile with
# gcc -o go_step go_step.c
# pcf8574 p0 -> uln2003 in1 and so on.
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <linux/i2c.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>


char Device[] = "/dev/i2c-1";
int fd;
int res;
int  address = 0x20;
char Buffer[1];




int main(int argc, char** argv)                                                // Programmstart
{
int i;
int t;
unsigned char ca[8];

ca[0]= 0x08;
ca[1]= 0x12;
ca[2]= 0x04;
ca[3]= 0x06;
ca[4]= 0x02;
ca[5]= 0x03;
ca[6]= 0x01;
ca[7]= 0x09;


        fd = open(Device, O_RDWR);

        if (ioctl(fd, I2C_SLAVE, address) < 0)                                 // Set the port options and set the address of the device we wish to speak to
        {
                printf("Unable to get bus access to talk to slave\n");
                exit(1);
        }

        //res = write(fd, argv[1], 1);
       for(t=0; t<3600;t++)
      {
       i=0;
       while ( i<8)
       {
       //     printf("%d \n", i);
       //sprintf(Buffer,"%d",i);
       Buffer[0]=ca[i]; 
        res = write(fd, Buffer, 1);
        i++;
        usleep(6000);
//not less then 1500 } } close(fd); return 0; }

NFS Howto

am Client

apt-get install nfs-common

 mount -t nfs 192.168.178.97:/hd /mnt

Am Server 

https://help.ubuntu.com/community/SettingUpNFSHowTo

/etc/exports

/hd   192.168.178.0/24(rw,insecure,no_subtree_check,async)

 service nfs-kernel-server restart

Disable suspend

root@pcpn64:~# su – Debian-gdm -s /bin/sh
$ export $(dbus-launch)
$ GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.session idle-delay 0
$ GSETTINGS_BACKEND=dconf gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type ’nothing‘
$