Friday, March 12, 2010

Copying a zone

I wanted to play a bit with the KDE4 build flags and I needed a playground. The idea I had was to use a copy of the existing KDE build zone, so as to save time configuring it and downloading all the dependencies.

Well, I have to admit I sort of failed in this one ...

zoneadm clone wasn't really an option as I need to have freedom creating and destroying snapshots on both zones. zoneadm clone -m copy probably never worked.
I spent a lot of time with zfs send|zfs receive, esp. with the idea of

# /usr/sbin/zfs snapshot -r tank/zones/build@1move
# /usr/sbin/zfs send tank/zones/build/ROOT/zbe@1move > build.backup
# zfs create tank/zones/debugbuild
# zonecfg -z debugbuild
zonecfg:debugbuild> export
create -b                                                              
set zonepath=/tank/zones/debugbuild                               
set brand=ipkg                                                         
set autoboot=true                                                      
set ip-type=shared                                                     
add fs                                                                 
set dir=/home                                                          
set special=/export/home                                               
set type=lofs                                                          
end                                                                    
add net                                                                
set address=10.10.2.44                                                 
set physical=e1000g0                                                   
end

# cat build.backup|zoneadm -z debugbuild attach  -r zfs
but it never worked. I spent hours trying, looking into the scripts in /usr/lib/brand/ipkg/, but it was probabaly not meant to be working anyway.

So in the end I hacked it like this:

# /usr/sbin/zfs snapshot -r tank/zones/build@1move
# /usr/sbin/zfs send tank/zones/build/ROOT/zbe@1move > build.backup
# zfs create tank/zones/debugbuild
# chmod 700  tank/zones/debugbuild
# zonecfg -z debugbuild
# zoneadm -z debugbuild install
# cat build.backup| pfexec /usr/sbin/zfs receive -F tank/zones/debugbuild/ROOT/zbe@1test
# zoneadm -z debugbuild boot

Not really a clean way, since I had to waste some extra bandwidth and time, but a working one.

No comments:

Post a Comment