Vnx-rootfslxccentos

From VNX
Revision as of 02:19, 5 August 2017 by David (talk | contribs) (Created page with "{{Title|How to create a LXC CentOS root filesystem for VNX}} == Basic installation == Follow this procedure to create a CentOS based LXC root filesystem for VNX. The procedu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

How to create a LXC CentOS root filesystem for VNX

Basic installation

Follow this procedure to create a CentOS based LXC root filesystem for VNX. The procedure has been tested with CentOS version 7.

  • Create the rootfs with:
  • sudo apt-get install yum
    lxc-create -t centos -n vnx_rootfs_lxc_centos -- -R 7 -a x86_64
    
  • Change root password (e.g. xxxx):
  • chroot /var/lib/lxc/vnx_rootfs_lxc_centos/rootfs passwd
    
  • Move the rootfs to VNX filesystems directory:
  • mv /var/lib/lxc/vnx_rootfs_lxc_centos /usr/share/vnx/filesystems/vnx_rootfs_lxc_centos64-7-v025
    
    li>Edit the rootfs configuration file (/usr/share/vnx/filesystems/vnx_rootfs_lxc_ubuntu-16.04/config) to reflect the directory change:
    lxc.rootfs = /usr/share/vnx/filesystems/vnx_rootfs_lxc_centos64-7-v025/rootfs
    
  • Create fstab file (if not created):
  • touch vnx_rootfs_lxc_centos64-7-v025/fstab
    
  • Start the new rootfs to configure it and install new software:
  • lxc-start -n vnx_rootfs_lxc_centos64-7-v025 -F -f /usr/share/vnx/filesystems/vvnx_rootfs_lxc_centos64-7-v025/config
    
  • Once the VM has started, make login (root/xxxx) and:
    • Add VNX user and change the passwords:
    • adduser vnx
      passwd vnx
      
    • Update and install software:
    • yum update
      yum install perl telnet wget openssh-clients traceroute tcpdump net-tools
      
    • Change VM name in hosts and hostname files:
    • sudo vi /etc/hosts         # change name to vnx
      sudo vi /etc/hostname      #     "
      
    • Add commands to create /dev/kvm and /dev/net/tun devices at startup (/etc/rc.local):
    • sed -i -e "/exit 0/d" /etc/rc.local
      echo "# /dev/net/tun" >> /etc/rc.local
      echo "mkdir -p /dev/net/" >> /etc/rc.local
      echo "mknod -m 666 /dev/net/tun c 10 200" >> /etc/rc.local
      echo "" >> /etc/rc.local
      echo "# /dev/kvm" >> /etc/rc.local
      echo "mknod -m 660 /dev/kvm c 10 232" >> /etc/rc.local
      
    • Delete command history:
    • history -c
      
    • Stop the VM with:
    • halt
      
    • If you want to pack the root filesystem into a tar file, use the following command:
    • tar --numeric-owner -czpf vnx_rootfs_lxc_centos64-7-v025.tgz vnx_rootfs_lxc_centos64-7-v025
      
    • Optionally, create a short link to the rootfs:
    • cd /usr/share/vnx/filesystems
      ln -s vnx_rootfs_lxc_centos64-7-v025 rootfs_lxc_centos64