Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

Create a dataset for your zones if you have not done it (do it ones)


zfs create -o mountpoint=/zones rpool/zones

Use zonecfg(1M) command to configure a new DPKG zone:


zonecfg -z t4

zonecfg:t4> create -t SUNWdpkg
zonecfg:t4> set zonepath=/zones/t4

zonecfg:t4> add net
zonecfg:t4:net> set address=172.16.92.4/16
zonecfg:t4:net> set defrouter=172.16.90.1
zonecfg:t4:net> set physical=e1000g0
zonecfg:t4:net> end

zonecfg:t4> add fs
zonecfg:t4:fs> set dir=/export/home/admin
zonecfg:t4:fs> set special=/export/home/admin
zonecfg:t4:fs> set type=lofs
zonecfg:t4:fs> end

zonecfg:t4> add fs
zonecfg:t4:fs> set dir=/export/builds
zonecfg:t4:fs> set special=/export/builds
zonecfg:t4:fs> set type=lofs
zonecfg:t4:fs> end

zonecfg:t4> commit
zonecfg:t4> verify
zonecfg:t4> exit

In this example we configured a shared IP-address, this means that the zone will share the IP stack with the host system. From time to time you may want to assign an exclusive IP-address.

In this case the net block could look like:

exclusive IP
zonecfg:t4> set ip-type="exclusive"
zonecfg:t4> add net
zonecfg:t4:net> set physical=vnic0
zonecfg:t4:net> set mac-addr=""
zonecfg:t4:net> set global-nic="vsw0"
zonecfg:t4:net> add property (name="gateway",value="172.16.0.1")
zonecfg:t4:net> add property (name="netmask",value="255.255.255.0")
zonecfg:t4:net> add property (name="ip",value="172.16.0.2")
zonecfg:t4:net> add property (name="primary",value="true")
zonecfg:t4:net> end

Like above we need to specify a link that will be used by the zone (vnic0). We mean that the nic is virtual (aka vnic) which has a parent interface, in this example it is a virtual switch (vsw0) or etherstub that is marked as global-nic. We can generate some MAC-address for the new NIC or leave this field empty, it will be filled automatically. Also we need to specify network properties (gateway, usualy it is IP-address in the host; netmask; ip is the address that will be assigned to the NIC inside the zone)

Also you can add a name server to the zone:

add resolver
zonecfg:t4> add attr
zonecfg:t4:attr> set name=resolvers
zonecfg:t4:attr> set type=string
zonecfg:t4:attr> set value="192.168.0.1"
zonecfg:t4:attr> end                    

Install the zone:

zoneadm -z t4 install

And boot it:

zoneadm -z t4 boot

Login to the zone for configuration:

zlogin -e\# -C t4

Hint:

type '#.' for exit from 'zlogin'

The root's password by default is "123". You can do "zlogin <zonename>" to log in into the new zone and then you can change the root password by the command passwd.

Login by 'root' for next modifications:

t4 console login:root
Password: <your own>

You can add local 'admin' user with the same UID/GID from global zone.

INFO:

Before steps below you have to identify UID and GID of user 'admin' on global zone by command:

# id admin

uid=1000(admin) gid=10(staff) groups=10(staff)

# useradd -u 1000 -g staff -d /export/home/admin -s /bin/bash admin
# passwd admin

You be able to login to your new zone by SSH from global zone or another comp by command:

$ ssh admin@<your ip>

Creating dpkg zone from zfs stream


use the zfs list command to find a dataset with your zone:

zfs list
#sudo zfs list | grep t4

rpool/zones/t4            400M  27.0G     31.5K  /zones/build_zone
rpool/zones/t4/ROOT       400M  27.0G       24K  legacy
rpool/zones/t4/ROOT/zbe   400M  27.0G      400M  legacy

now using zfs get all you need to find the active be for this zone:

zfs get all
#sudo zfs get all | grep t4

rpool/zones/t4/ROOT/zbe                   org.opensolaris.libbe:active    on                                                local
rpool/zones/t4/ROOT/zbe                   org.opensolaris.libbe:parentbe  fea60694-a58d-4828-be5d-6e8b39f64c44              local

after finding the active dataset, you can create a snapshot:

#sudo zfs snapshot  rpool/zones/t4/ROOT/zbe@copy_t4

#sudo zfs list -t | grep zbe@copy_t4

rpool/zones/build_zone/ROOT/zbe@check_dpkg           0B      -      400M  

#sudo zfs send rpool/zones/t4/ROOT/zbe@copy_t4 > /var/tmp/copy_t4.zfs

now you need to prepare the dataset for copying the zone:

#sudo zfs create -o mountpoint=/zones/copy_t4 rpool/zones/copy_t4

#mkdir -p /zones/copy_t4/root

#chmod 700 /zones/copy_t4

#chmod 755 /zones/copy_t4/root

#sudo zfs create -o mountpoint=legacy rpool/zones/copy_t4/ROOT

#sudo zfs create -o mountpoint=legacy rpool/zones/copy_t4/ROOT/zbe

now you need to export the zone configuration to a file:

#sudo zonecfg -z t4 export -f /var/tmp/copy_t4.cmd

#cat /var/tmp/copy_t4.cmd

create -b
set zonepath=/zones/t4
set brand=dpkg
set autoboot=false
set ip-type=exclusive
set uuid=da66d114-f97b-4b2b-a969-219ebcf56a19
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="vnic1"
set mac-addr="02:08:20:1b:ea:6b"
set global-nic="stub0"
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="192.168.0.254"
end

now let's change this configuration so that we can create a zone via zonecfg.

You must remove the following settings from the template:

  1. delete uuid because it is generated and registered in the zone configuration file when it starts (/etc/zones/name_zone.xml).
  2. delete mac address because it is generated and registered in the zone configuration file when it starts (/etc/zones/name_zone.xml).
  3. change name global vnic
  4. change ip address
  5. change zonepath
create -b
set zonepath=/zones/copy_t4
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="vnic2"
set global-nic="stub0"
add property (name=ip,value="192.168.0.2")
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="192.168.0.254"
end

now use the zonecfg and zoneadm commands to create and start a zone:

#zonecfg -z copy_t4 -f /var/tmp/copy_t4.cmd

#zoneadm -z copy_t4 install -u -a /var/tmp/copy_t4.zfs

#zoneadm -z copy_t4 boot
  • No labels