projects:livenet:server

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revisionBoth sides next revision
projects:livenet:server [2018/03/12 23:37] nicolaprojects:livenet:server [2018/03/13 00:26] nicola
Line 1: Line 1:
-===== Software richiesto =====+===== Requirements =====
 ** HW**: 2 nic device ** HW**: 2 nic device
  
-**Sistema operativo**: Ubuntu server 17.10+**OS**: Ubuntu server 17.10
  
 <code>apt install bash debootstrap schroot syslinux nfs-kernel-server tftpd-hpa xorriso pigz  zfsutils-linux</code> <code>apt install bash debootstrap schroot syslinux nfs-kernel-server tftpd-hpa xorriso pigz  zfsutils-linux</code>
  
-**software facoltativo ma usato nel test**+**Optional config**
  
 <code>apt install isc-dhcp-server </code> <code>apt install isc-dhcp-server </code>
-===== Preparazione ambiente livenet =====+ 
 +**network config ** 
 +nano /etc/netplan/01-netcfg.yaml  
 + 
 +<code> 
 +# This file describes the network interfaces available on your system 
 +# For more information, see netplan(5). 
 +network: 
 +  version: 2 
 +  renderer: networkd 
 +  ethernets: 
 +    ens3: 
 +      dhcp4: no 
 +      addresses: [10.1.22.2/24] 
 +      gateway4: 192.168.122.1 
 +      nameservers: 
 +        addresses: [8.8.8.8,8.8.4.4] 
 +    ens4: 
 +      dhcp4: yes 
 + 
 + 
 + 
 +</code> 
 + 
 +<code>netplan apply</code> 
 +===== Build livenet environment =====
 ==== Preparazione dell'ambiente zfs ==== ==== Preparazione dell'ambiente zfs ====
  
Line 17: Line 42:
  
 Download package  git clone https://github.com/scipioni/livenet-server.git Download package  git clone https://github.com/scipioni/livenet-server.git
 +edit /etc/default/livenet like this
 +
 +<code>
 +# folder that contains livenet system
 +BASE=/livenet
 +IMAGES=${BASE}/images
 +BOOT=${BASE}/boot
 +</code>
 +
 +==== Trivial FTP ====
 +edit /etc/default/tftp-hpa
 +<code>
 +TFTP_USERNAME="tftp"
 +TFTP_DIRECTORY="/zfsp_livenet/boot"
 +TFTP_ADDRESS="0.0.0.0:69"
 +TFTP_OPTIONS="--secure"
 +</code>
 +
 +<code>mkdir /livenet/boot/pxelinux.cfg
 +
 +cp -a /usr/lib/syslinux/* /livenet/boot
 +
 +cp /livenet/boot/modules/efi64/* /livenet/boot </code>
 +
 +edit /livenet/boot/pxelinux.cfg/default
 +<code>
 +default menu.c32
 +prompt 0
 +#timeout 100
 +
 +menu title PXE Special Boot Menu
 +MENU AUTOBOOT Starting Livenet in # seconds
 +
 +label bootlocal
 +   menu label ^Boot local disk
 +   menu default
 +   localboot 0
 +
 +label nfs
 +   menu label Ubuntu 18.04 - diskless
 +   kernel /bionic/kernel
 +   append initrd=/bionic/initrd ro livenet_root=10.1.22.2:/zfsp_livenet/images/bionic livenet_profile=default
 +
 +label nfs
 +   menu label Ubuntu 14.04 - install
 +   kernel /trusty/kernel
 +   append initrd=/trusty/initrd ro livenet_root=10.0.254.240:/images/trusty livenet_profile=default livenet_action=install livenet_action_end=reboot
 +
 +</code>
 +
 +
 +
 +
 +
 +
 +===== BUILD IMAGE CLIENT ====
 +zfs create livenet/images/bionic
 +debootstrap --arch amd64 bionic /zfsp_livenet/images/bionic/ http://archive.ubuntu.com/ubuntu
 +
 +cd /livenet/images
 +run ....
 +<code>
 +R=bionic
 +cat > ${R}/etc/hosts <<QWK
 +127.0.0.1   localhost livenet-host
 +::1     localhost ip6-localhost ip6-loopback
 +ff02::    ip6-allnodes
 +ff02::    ip6-allrouters
 +QWK
 +
 +chroot ${R} lsb_release -c | awk '{print $2}' > ${R}/etc/debian_chroot
 +chroot bionic/
 +chroot ${R} apt-get -y -q install locales dialog
 +chroot ${R} locale-gen en_GB.UTF-8
 +chroot ${R} locale-gen it_IT.UTF-8
 +chroot ${R} update-locale LANG=it_IT.UTF-8 LANGUAGE=it:en_US:en
 +echo Europe/Rome > ${R}/etc/timezone
 +cp ${R}/usr/share/zoneinfo/Europe/Rome ${R}/etc/localtime
 +cat > ${R}/usr/sbin/policy-rc.d <<QWE
 +#!/bin/sh
 +
 +# dpkg/apt not start any daemons when things are installed in the chroot
 +
 +if [ ! "\\\`cat /etc/hostname\\\`" = "\\\`hostname\\\`" ]; then
 +    exit 101
 +fi
 +QWE
 +
 +chmod +x ${R}/usr/sbin/policy-rc.d
 +</code>
 +
 +<code>mount --bind /zfsp_livenet/images/bionic/boot/ /zfsp_livenet/boot/bionic</code>
 +
 +<code>
 +DISTR=bionic
 +
 +cat > /etc/apt/sources.list <<QWE
 +#############################################################
 +################### OFFICIAL UBUNTU REPOS ###################
 +#############################################################
 +###### Ubuntu Main Repos
 +deb http://archive.ubuntu.com/ubuntu/ ${DISTR} main restricted universe multiverse 
 +###### Ubuntu Update Repos
 +deb http://archive.ubuntu.com/ubuntu/ ${DISTR}-security main restricted universe multiverse 
 +deb http://archive.ubuntu.com/ubuntu/ ${DISTR}-updates main restricted universe multiverse 
 +deb http://archive.ubuntu.com/ubuntu/ ${DISTR}-proposed main restricted universe multiverse 
 +deb http://archive.ubuntu.com/ubuntu/ ${DISTR}-backports main restricted universe multiverse 
 +###### Ubuntu Partner Repo
 +deb http://archive.canonical.com/ubuntu ${DISTR} partner
 +QWE
 +</code>
 +
 +<code>
 +apt update apt -y upgrade
 +apt -y install initramfs-tools  python-passlib pv screen byobu lsof pigz rsync nfs-common libpam-script xloadimage conntrack
 +</code>
 +
 +==== install livenet client package ====
 +<code>
 +git clone  https://github.com/scipioni/livenet-client.git
 +mv .git /
 +git status
 +find / -maxdepth 1 > .gitignore
 +
 +</code>
 +inside git directory
 +<code>rsync -avb etc/ /etc/
 +rsync -avb usr/ /usr/
 +apt-get -y install linux-generic
 +</code>
 +
 +==== etc/initramfs-tools/hooks/livenet ====
 +<code>
 +#!/bin/sh -e
 +# initramfs hook for livenet
 +#set -x
 +PREREQ=""
 +
 +# Output pre-requisites
 +prereqs()
 +{
 +       echo "$PREREQ"
 +}
 +
 +case "$1" in
 +    prereqs)
 +       prereqs
 +       exit 0
 +       ;;
 +esac
 +
 +. /usr/share/initramfs-tools/hook-functions
 +
 +rm ${DESTDIR}/bin/cpio # importante! altrimenti rimane un cpio troppo semplificato
 +copy_exec /bin/cpio /bin
 +
 +mkdir -p ${DESTDIR}/conf
 +cp /etc/livenet/livenet.conf ${DESTDIR}/conf
 +[ -f /etc/livenet/livenet.conf.override ] && cp /etc/livenet/livenet.conf.override ${DESTDIR}/conf
 +cp /etc/initramfs-tools/scripts/functions-livenet ${DESTDIR}/conf
 +
 +manual_add_modules aufs
 +manual_add_modules overlayfs
 +auto_add_modules net
 +auto_add_modules nfsv4
 +
 +# pulizia di firmware non necessario e pesante
 +set +e
 +rm -f ${DESTDIR}/lib/firmware/* >/dev/null 2>&1
 +set -e
 +
 +### qui sotto andrebbe commentato in produzione ###
 +
 +# tastiera italiana in initram
 +# attivata da do_debug_shell (loadkeys /etc/boottime.kmap.gz)
 +#cp -au /etc/console-setup/cached.kmap.gz ${DESTDIR}/etc/boottime.kmap.gz
 +
 +# nfs4
 +#copy_exec /usr/sbin/rpc.idmapd /bin
 +#copy_exec /sbin/mount.nfs /bin
 +#cp -au /etc/netconfig ${DESTDIR}/etc/netconfig
 +
 +#cat > ${DESTDIR}/etc/passwd <<EOF
 +#nobody::65534:65534:nobody:/nonexistent:/bin/sh
 +#EOF
 +#cat > ${DESTDIR}/etc/group <<EOF
 +#nogroup:x:65534:
 +#EOF
  
 +# debug purpose ################
 +# ricordati di mettere FRAMEBUFFER=n in /etc/initramfs-tools/conf.d/splash
 +#copy_exec /sbin/ifconfig
 +#copy_exec /sbin/lsmod /bin
 +#copy_exec /usr/bin/lspci /bin
 +#################################
  
 +# wireless #####################
 +#copy_exec /sbin/iwconfig
 +#copy_exec /sbin/iwlist
 +#copy_exec /sbin/iwpriv
 +#copy_exec /sbin/iwevent
 +#copy_exec /sbin/iwgetid
 +#copy_exec /sbin/iwspy
 +#copy_exec /usr/sbin/rfkill
 +#cp -au /lib/firmware/iwl*-[13].ucode ${DESTDIR}/lib/firmware
 +#################################
 +</code>
  
 +===Rebuild initramfs image ===
 +ln-mng --kernel
  
 ===== DHCP ===== ===== DHCP =====
  • projects/livenet/server.txt
  • Last modified: 2018/03/21 11:56
  • by scipio