Skip to content

Instantly share code, notes, and snippets.

@aortmannm
Forked from reiddraper/zone-clone.markdown
Created November 26, 2013 16:44
Show Gist options
  • Save aortmannm/7661647 to your computer and use it in GitHub Desktop.
Save aortmannm/7661647 to your computer and use it in GitHub Desktop.

on the guest SmartOS VM

pkg_add http://pkgsrc.joyent.com/sdc6/2012Q1/i386/All/smtools
# note this is going to shut down the VM
sm-prepare-image

on the global zone

# b996c578-c4fc-46ef-81cc-d2eb3489ebc6 is the UUID
# of the zone I want to snapshot and clone. `uuid`
# returns a new UUID.
zfs snapshot zones/b996c578-c4fc-46ef-81cc-d2eb3489ebc6@`uuid`

# we can see the snapshot we made
zfs list -t snapshot

# create a new UUID for the clone
export CLONE_UUID=`uuid`

# clone!

# the UUID after the `@` is the UUID for from our snapshot version
zfs send zones/b996c578-c4fc-46ef-81cc-d2eb3489ebc6@81e67092-cb63-11e1-b0f3-fbc4021003b3 | zfs recv zones/$CLONE_UUID

# now you should be able to use $CLONE_UUID as a "dataset_uuid" in a VM json spec.

Getting ssh access again

After stopping and running the prepare script on my machine, I was unable to log in via ssh again. I saw this ssh error:

Unable to negotiate a key exchange method

I fixed this by zlogin'ing back into the machine and running the following:

ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
svcadm restart ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment