/
How to prepare a VM for tests with zones

How to prepare a VM for tests with zones

  1. Use this guide. Create new vm. Setup VM with:

    • CPU - 4

    • Memory - 8GB

    • Hard disk - 100GB

    • Hard disk - 8GB

    • Hard disk - 8GB

    • Hard disk - 8GB

    • Have to use DEBUG build, where we have debug macro

  2. Create new user for test:

    sudo useradd -m -d /var/ztest -g staff -s /bin/bash ztest # add password for remote ssh sudo passwd ztest sudo su echo "ztest ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/ztest
  3. Update source.list and update:

    //add this to /etc/apt/sources.list
    deb-src http://apt2.dilos.org/dilos du2-unstable main contrib non-free deb http://apt2.dilos.org/dilos dg2-unstable main contrib non-free deb http://apt2.dilos.org/dilos du2-unstable main contrib non-free #deb https://apt2.dilos.org/dilos dgdbg-unstable main contrib non-free
  4. Install ca-certificates

    admin@debug221122:~$ sudo apt update admin@debug221122:~$ sudo apt install ca-certificates //and change /etc/apt/source.list againe //add deb https://apt2.dilos.org/dilos dg2-unstable main contrib non-free // #deb https://apt2.dilos.org/dilos dgdbg-unstable main contrib non-free // deb https://apt2.dilos.org/dilos du2-unstable main contrib non-free admin@debug221122:~$ cat /etc/apt/source.list deb-src http://apt2.dilos.org/dilos du2-unstable main contrib non-free deb https://apt2.dilos.org/dilos dg2-unstable main contrib non-free deb https://apt2.dilos.org/dilos du2-unstable main contrib non-free #deb https://apt2.dilos.org/dilos dgdbg-unstable main contrib non-free admin@debug221122:~$ sudo apt update
  5. Update pkg os-upgrade and os upgrade and reboot on new BE:

    admin@debug221122:~$ sudo apt install os-upgrade admin@debug221122:~$ sudo os-upgrade
  6. Reboot system.

  7. Create new etherstub for internal network in vm:

    admin@debug221122:~$ sudo dladm create-etherstub vsw0 admin@debug221122:~$ sudo dladm show-etherstub LINK vsw0 admin@debug221122:~$ sudo dladm create-vnic -l vsw0 int0 admin@debug221122:~$ sudo dladm show-link LINK CLASS MTU STATE BRIDGE OVER e1000g0 phys 1500 up -- -- vsw0 etherstub 9000 up -- -- int0 vnic 9000 up -- vsw0 admin@debug221122:~$ sudo ifconfig int0 plumb admin@debug221122:~$ sudo ifconfig lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 e1000g0: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 1500 index 2 inet 172.21.207.71 netmask ffffff00 broadcast 172.21.207.255 ether 16:f7:25:2f:9e:72 int0: flags=1000842<BROADCAST,RUNNING,MULTICAST,IPv4> mtu 9000 index 3 inet 0.0.0.0 netmask 0 ether 2:8:20:a1:16:fe lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1 inet6 ::1/128 admin@debug221122:~$ sudo ifconfig int0 inet 192.168.0.254/24 up admin@debug221122:~$ sudo ifconfig int0 int0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 9000 index 3 inet 192.168.0.254 netmask ffffff00 broadcast 192.168.0.255 ether 2:8:20:a1:16:fe // configure new interface hostname.int0 admin@debug221122:~$ sudo nano /etc/hostname.int0 admin@debug221122:~$ cat /etc/hostname.int0 192.168.0.254 netmask 255.255.255.0 broadcast + up // configure new nat-config file admin@debug221122:~$ sudo nano /etc/ipf/ipnat.conf admin@debug221122:~$ cat /etc/ipf/ipnat.conf map e1000g0 192.168.0.0/24 -> 0/32 proxy port ftp ftp/tcp map e1000g0 192.168.0.0/24 -> 0/32 portmap tcp/udp auto map e1000g0 192.168.0.0/24 -> 0/32 admin@debug221122:~$ svcs ipfilter STATE STIME FMRI disabled 10:05:00 svc:/network/ipfilter:default admin@debug221122:~$ sudo svcadm enable ipfilter admin@debug221122:~$ svcs ipfilter STATE STIME FMRI online 10:27:29 svc:/network/ipfilter:default admin@debug221122:~$ sudo routeadm Configuration Current Current Option Configuration System State --------------------------------------------------------------- IPv4 routing disabled disabled IPv6 routing disabled disabled IPv4 forwarding disabled disabled IPv6 forwarding disabled disabled Routing services "route:default ripng:default" Routing daemons: STATE FMRI disabled svc:/network/routing/ripng:default disabled svc:/network/routing/legacy-routing:ipv4 disabled svc:/network/routing/legacy-routing:ipv6 disabled svc:/network/routing/ndp:default disabled svc:/network/routing/route:default disabled svc:/network/routing/rdisc:default admin@debug221122:~$ sudo routeadm -u -e ipv4-forwarding admin@debug221122:~$ sudo routeadm Configuration Current Current Option Configuration System State --------------------------------------------------------------- IPv4 routing disabled disabled IPv6 routing disabled disabled IPv4 forwarding enabled enabled IPv6 forwarding disabled disabled Routing services "route:default ripng:default" Routing daemons: STATE FMRI disabled svc:/network/routing/ripng:default disabled svc:/network/routing/legacy-routing:ipv4 disabled svc:/network/routing/legacy-routing:ipv6 disabled svc:/network/routing/ndp:default disabled svc:/network/routing/route:default disabled svc:/network/routing/rdisc:default

     

  8. Install zone for dhcp. dhcp will be use for another zones:

    admin@debug221122:~$ sudo zfs list NAME USED AVAIL REFER MOUNTPOINT rpool 7.85G 22.7G 31.5K /rpool rpool/ROOT 793M 22.7G 24K none rpool/ROOT/dilos_2.0.3.7 1.80M 22.7G 387M legacy rpool/ROOT/dilos_2211220213 3.05M 22.7G 383M legacy rpool/ROOT/net-set 788M 22.7G 407M legacy rpool/crash 24K 22.7G 24K /var/crash rpool/dump 5.00G 22.7G 5.00G - rpool/export 61K 22.7G 24K /export rpool/export/home 37K 22.7G 37K /export/home rpool/swap 2.06G 24.7G 12K - rpool/varcache 6.52M 22.7G 6.52M /var/cache rpool/varspool 29.5K 22.7G 29.5K /var/spool rpool/vartmp 92K 22.7G 92K /var/tmp admin@debug221122:~$ sudo zfs create -o mountpoint=/zones rpool/zones admin@debug221122:~$ sudo zfs list -r NAME USED AVAIL REFER MOUNTPOINT rpool 7.85G 22.7G 31.5K /rpool rpool/ROOT 793M 22.7G 24K none rpool/ROOT/dilos_2.0.3.7 1.80M 22.7G 387M legacy rpool/ROOT/dilos_2211220213 3.05M 22.7G 383M legacy rpool/ROOT/net-set 788M 22.7G 407M legacy rpool/crash 24K 22.7G 24K /var/crash rpool/dump 5.00G 22.7G 5.00G - rpool/export 61K 22.7G 24K /export rpool/export/home 37K 22.7G 37K /export/home rpool/swap 2.06G 24.7G 12K - rpool/varcache 6.52M 22.7G 6.52M /var/cache rpool/varspool 29.5K 22.7G 29.5K /var/spool rpool/vartmp 92K 22.7G 92K /var/tmp rpool/zones 24K 22.7G 24K /zones admin@debug221122:~$ sudo mkdir /export/builds admin@debug221122:~$ sudo cat > dhcp.cmd <<EOT create -b set zonepath=/zones/dhcp set brand=dpkg set autoboot=false set ip-type=exclusive add fs set dir="/export/home/admin" set special="/export/home/admin" set type="lofs" end add fs set dir="/export/builds" set special="/export/builds" set type="lofs" end add net set physical="iz1" set global-nic="vsw0" add property (name=ip,value="192.168.0.1") add property (name=netmask,value="255.255.255.0") add property (name=gateway,value="192.168.0.254") add property (name=primary,value="true") end add attr set name="resolvers" set type="string" set value="8.8.8.8" end verify commit EOT admin@debug221122:~$ sudo zonecfg -z dhcp -f dhcp.cmd admin@debug221122:~$ sudo zonecfg -z dhcp info zonename: dhcp zonepath: /zones/dhcp brand: dpkg autoboot: false bootargs: pool: limitpriv: scheduling-class: ip-type: exclusive hostid: fs-allowed: uuid: 46b79185-7320-4ab6-b700-15058bd49c02 fs: dir: /export/home/admin special: /export/home/admin raw not specified type: lofs options: [] fs: dir: /export/builds special: /export/builds raw not specified type: lofs options: [] net: address not specified allowed-address not specified defrouter not specified global-nic: vsw0 mac-addr not specified physical: iz1 vlan-id not specified property: (name=ip,value="192.168.0.1") property: (name=netmask,value="255.255.255.0") property: (name=gateway,value="192.168.0.254") property: (name=primary,value="true") attr: name: resolvers type: string value: 8.8.8.8 admin@debug221122:~$ sudo zoneadm list -civ ID NAME STATUS PATH BRAND IP 0 global running / dpkg shared - dhcp configured /zones/dhcp dpkg excl admin@debug221122:~$ sudo zoneadm -z dhcp install admin@debug221122:~$ sudo zoneadm list -civ ID NAME STATUS PATH BRAND IP 0 global running / dpkg shared - dhcp installed /zones/dhcp dpkg excl admin@debug221122:~$ sudo zoneadm -z dhcp boot admin@debug221122:~$ sudo mkdir /export/home/admin admin@debug221122:~$ sudo zoneadm list -civ ID NAME STATUS PATH BRAND IP 0 global running / dpkg shared 1 dhcp running /zones/dhcp dpkg excl

     

  9. Now login in zone and setting dhcp zone:

    admin@debug221122:~$ sudo zlogin dhcp [Connected to zone 'dhcp' pts/2] zlogin from global The programs included with the DilOS 2.0.3 system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. DilOS 2.0.3 comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. root@dhcp:~# ifconfig lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 iz1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 9000 index 2 inet 192.168.0.1 netmask ffffff00 broadcast 192.168.0.255 ether 2:8:20:92:59:94 lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1 inet6 ::1/128 root@dhcp:~# apt install isc-dhcp-server -y root@dhcp:~# mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bckp root@dhcp:~# cat>/etc/dhcp/dhcpd.conf <<EOT # A slightly different configuration for an internal subnet. subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.100 192.168.0.200; option subnet-mask 255.255.255.0; option domain-name-servers 8.8.8.8; # option domain-name "internal.example.org"; option routers 192.168.0.254; option broadcast-address 192.168.0.255; default-lease-time 600; max-lease-time 7200; } EOT root@dhcp:~# ifconfig lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 iz1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 9000 index 2 inet 192.168.0.1 netmask ffffff00 broadcast 192.168.0.255 ether 2:8:20:92:59:94 lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1 inet6 ::1/128 root@dhcp:~# vim /etc/default/isc-dhcp-server root@dhcp:~# cat>/etc/default/isc-dhcp-server <<EOT # Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server) # Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf). #DHCPDv4_CONF=/etc/dhcp/dhcpd.conf #DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf # Path to dhcpd's PID file (default: /var/run/dhcpd.pid). #DHCPDv4_PID=/var/run/dhcpd.pid #DHCPDv6_PID=/var/run/dhcpd6.pid # Additional options to start dhcpd with. # Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead #OPTIONS="" # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACESv4="iz1" INTERFACESv6="" EOT root@dhcp:~# svcadm enable isc-dhcp-server root@dhcp:~# svcs -xv root@dhcp:~# svcs isc-dhcp-server STATE STIME FMRI online 10:46:50 svc:/network/isc-dhcp-server:default root@dhcp:~# dhcp-lease-list To get manufacturer names please download http://standards.ieee.org/regauth/oui/oui.txt to /usr/local/etc/oui.txt Reading leases from /var/lib/dhcp/dhcpd.leases MAC IP hostname valid until manufacturer =============================================================================================== root@dhcp:~# exit logout

     

  10. Now, you must upgrade on debug build. Comment # dg2 and recommnet dgdbg-unstable:

    admin@debug221122:~$ sudo su root@debug221122:~$ cat>/etc/apt/sources.list <<EOT deb-src http://apt2.dilos.org/dilos du2-unstable main contrib non-free #deb https://apt2.dilos.org/dilos dg2-unstable main contrib non-free deb https://apt2.dilos.org/dilos du2-unstable main contrib non-free deb https://apt2.dilos.org/dilos dgdbg-unstable main contrib non-free EOT root@debug221122:~$ exit admin@debug221122:~$ sudo apt update Hit:1 http://apt2.dilos.org/dilos du2-unstable InRelease Get:2 https://apt2.dilos.org/dilos dgdbg-unstable InRelease [22.3 kB] Get:3 https://apt2.dilos.org/dilos dgdbg-unstable/main solaris-i386 Packages [96.3 kB] Fetched 119 kB in 2s (54.5 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 314 packages can be upgraded. Run 'apt list --upgradable' to see them. admin@debug221122:~$ sudo os-upgrade admin@debug221122:~$ sudo reboot
  11. Login server. Use login ztest:

    ssh ztest@172.21.207.71 ztest@debug221122:~$ sudo zoneadm list -civ ID NAME STATUS PATH BRAND IP 0 global running / dpkg shared - dhcp installed /zones/dhcp dpkg excl ztest@debug221122:~$ sudo zoneadm -z dhcp boot ztest@debug221122:~$ uname -a SunOS debug221122 5.11 2.0.3.7-20221122-1-0+int2 i86pc i386 i86pc ztest@debug221122:~$ sudo beadm BE Active Mountpoint Space Policy Created dilos_2211220213 - - 3.05M static 2022-11-22 13:14 dilos_2.0.3.7 - - 1.80M static 2022-11-22 16:31 net-set - - 3.21M static 2022-11-23 13:13 dilos_2.0.3.7-20221122-1-0-int2 NR / 975.50M static 2022-11-24 10:52 //and, create be for test os-test ztest@debug221122:~$ sudo beadm create -a os-test Activated successfully ztest@debug221122:~$ sudo beadm BE Active Mountpoint Space Policy Created dilos_2211220213 - - 3.05M static 2022-11-22 13:14 dilos_2.0.3.7 - - 1.80M static 2022-11-22 16:31 net-set - - 3.21M static 2022-11-23 13:13 dilos_2.0.3.7-20221122-1-0-int2 N / 79K static 2022-11-24 10:52 os-test R - 975.63M static 2022-11-24 11:07 // reboot ztest@debug221122:~$ sudo beadm BE Active Mountpoint Space Policy Created dilos_2211220213 - - 3.05M static 2022-11-22 13:14 dilos_2.0.3.7 - - 1.80M static 2022-11-22 16:31 net-set - - 3.21M static 2022-11-23 13:13 dilos_2.0.3.7-20221122-1-0-int2 - - 1.95M static 2022-11-24 10:52 os-test NR / 979.79M static 2022-11-24 11:07 // now create new zone. ztest@debug221122:~$ sudo zoneadm -z dhcp boot ztest@debug221122:~$ sudo zoneadm list -civ ID NAME STATUS PATH BRAND IP 0 global running / dpkg shared 1 dhcp running /zones/dhcp dpkg excl ztest@debug221122:~$ cat>zone.cmd <<EOT create set zonepath=/zones/zone set autoboot=false set ip-type=exclusive add net set physical=int1 set global-nic="vsw0" add property (name="ip",value="dhcp") add property (name="primary",value="true") end commit exit EOT ztest@debug221122:~$ sudo zonecfg -z zone -f zone.cmd ztest@debug221122:~$ sudo zoneadm list -civ ID NAME STATUS PATH BRAND IP 0 global running / dpkg shared 1 dhcp running /zones/dhcp dpkg excl - zone configured /zones/zone dpkg excl ztest@debug221122:~$ sudo zoneadm -z zone install ztest@debug221122:~$ sudo zoneadm -z zone boot ztest@debug221122:~$ sudo zoneadm list -civ ID NAME STATUS PATH BRAND IP 0 global running / dpkg shared 1 dhcp running /zones/dhcp dpkg excl 2 zone running /zones/zone dpkg excl ztest@debug221122:~$ sudo zlogin -l root dhcp dhcp-lease-list To get manufacturer names please download http://standards.ieee.org/regauth/oui/oui.txt to /usr/local/etc/oui.txt Reading leases from /var/lib/dhcp/dhcpd.leases MAC IP hostname valid until manufacturer =============================================================================================== 02:08:20:a0:5a:92 192.168.0.100 dhcp 2022-11-24 10:20:34 -NA- ztest@debug221122:~$ sudo zlogin -l root zone ifconfig lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 int1: flags=1004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4> mtu 9000 index 2 inet 192.168.0.100 netmask ffffff00 broadcast 192.168.0.255 ether 2:8:20:a0:5a:92 lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1 inet6 ::1/128 // install pkg for os-test ztest@debug221122:~$ uname -a SunOS debug221122 5.11 2.0.3.7-20221122-1-0+int2 i86pc i386 i86pc

Related content