In the previous sections we've built a base VM image that contains the packages we want in all our guest VMs and some of the common configuration that will make administration easier like LDAP integration for user authentication. Now we go over a process to create an image that we can clone into as many new guest VMs as we like.
You can take a look at the contents of the goat-lin001.webber.net root file system we created in the previous post. It's best to shut the guest down to create an image from this:
You can take a look at the contents of the goat-lin001.webber.net root file system we created in the previous post. It's best to shut the guest down to create an image from this:
1
2
3
4
| gsw@goat-lin: /etc/xen-tools $ sudo mount /dev/roots-vg/goat-lin001 .webber.net-disk /mnt/test gsw@goat-lin: /etc/xen-tools $ ls /mnt/test/ bin dev home initrd.img.old lib64 media opt root sbin sys usr vmlinuz boot etc initrd.img lib lost+found mnt proc run srv tmp var vmlinuz.old |
gsw@goat-lin:/etc/xen-tools$ sudo mount /dev/roots-vg/goat-lin001.webber.net-disk /mnt/test gsw@goat-lin:/etc/xen-tools$ ls /mnt/test/ bin dev home initrd.img.old lib64 media opt root sbin sys usr vmlinuz boot etc initrd.img lib lost+found mnt proc run srv tmp var vmlinuz.oldNow let's try a couple of approaches to generating an image, firstly using dd then tar:
1
2
3
4
5
6
7
8
9
| gsw@goat-lin: /etc/xen-tools $ sudo umount /mnt/test gsw@goat-lin: /etc/xen-tools $ sudo dd if = /dev/roots-vg/goat-lin001 .webber.net-disk bs=16K conv=noerror, sync status=progress | gzip -c > /mnt/scratch/goat-lin/base_vm_guest_install .20180925.img.gz gsw@goat-lin: /etc/xen-tools $ sudo tar cf - /mnt/test | gzip -c > /mnt/scratch/goat-lin/base_vm_guest_install .20180925. tar .gz gsw@goat-lin: /etc/xen-tools $ ls -alk /mnt/scratch/goat-lin/base_vm_guest_install .20180925.* -rwxrwxrwx 1 gsw gsw 500904092 Sep 25 17:41 /mnt/scratch/goat-lin/base_vm_guest_install .20180925.img.gz -rwxrwxrwx 1 gsw gsw 234499286 Sep 25 17:49 /mnt/scratch/goat-lin/base_vm_guest_install .20180925. tar .gz |
gsw@goat-lin:/etc/xen-tools$ sudo umount /mnt/test gsw@goat-lin:/etc/xen-tools$ sudo dd if=/dev/roots-vg/goat-lin001.webber.net-disk bs=16K conv=noerror,sync status=progress | gzip -c > /mnt/scratch/goat-lin/base_vm_guest_install.20180925.img.gz gsw@goat-lin:/etc/xen-tools$ sudo tar cf - /mnt/test | gzip -c > /mnt/scratch/goat-lin/base_vm_guest_install.20180925.tar.gz gsw@goat-lin:/etc/xen-tools$ ls -alk /mnt/scratch/goat-lin/base_vm_guest_install.20180925.* -rwxrwxrwx 1 gsw gsw 500904092 Sep 25 17:41 /mnt/scratch/goat-lin/base_vm_guest_install.20180925.img.gz -rwxrwxrwx 1 gsw gsw 234499286 Sep 25 17:49 /mnt/scratch/goat-lin/base_vm_guest_install.20180925.tar.gzAs expected, you can see that the tar is significantly smaller so you may prefer this in situations where you don't need a block for block copy of a disk.
Next: Flexible server Part VI: cloning an image
No comments:
Post a Comment