SmartOS Random Stuff

Adding and removing disks

Add Disk

Get disk info about vm

# vmadm get UUID | json disks

The below json example file will add a disk to a KVM and has an option to add it to any pool you wish very handy

{
 "add_disks": [
 {
 "media": "disk",
 "model": "virtio",
 "size": 100000,
 "boot": false,
 "zpool": "backups"
 }
 ]
 }

Use this command to add the disk NOTE you need to stop the vm safety first.

 vmadm update UUID -f /opt/json/add-disks-backups.json

Remove disk

Again you probably want to list the disks used by your VM then remove the disk you do not want

# vmadm get UUID | json disks

echo '{"remove_disks": ["/dev/zvol/rdsk/zones/UUID-disk1"]}' | vmadm update UUID

Random stuffs

madm boot UUID order=cd,once=d cdrom=/boot.iso,ide

vmadm update UUID <<< ‘{“resolvers”:[“127.0.0.1”, “8.8.8.8”, “8.8.4.4”]}’

Above requires a reboot

mkdir .ssh vi .ssh/authorized_keys enter key from pagent apt-get update && apt-get dist-upgrade

Making transportable backups

vmadm send UUID | gzip > /backups/vms/UUID.backup.tgz

gunzip -c /backups/vms/UUID.backup.tgz | vmadm receive

Checking json files for errors

cat file.json | json

Just a note for anybody looking for a workaround for the logadm email

To see all logs in logadm:

logadm -V

To remove the offending log files:

logadm -r /zones/<uuid>/root/tmp/vm.log

Make sure you only delete logs for VMs that have already been destroyed.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.