Building my development environment – Part 3

In this post I am describing how I install operating systems on virtual machines.
Whenever I get a new release of an operating system, I sometimes encounter a few inconveniences. I need to reconcile my own requirements with what I get with this new distribution. So sometimes I need to try and learn before I find the right way of installing an operating system.

After I have created an empty VM-image for an operating system installation, I am making a backup of it, because it is much more time consuming to create a new image after I have screwed it compared to restoring it from the backup.

My VM-images reside in the path /data/vm and there VMware creates another sub-directory for each image. Currently it looks like this:

yael@never-mind:/data$ ls -lR vm
vm:
total 8
drwxr-xr-x 2 yael yael 4096 Feb 28 12:11 FreeB
drwxr-xr-x 2 yael yael 4096 Feb 28 12:11 rhel-7

vm/FreeB:
total 20971536
-rw------- 1 yael yael 4261412864 Feb 28 00:07 FreeB-h0-f001.vmdk
-rw------- 1 yael yael 4261412864 Feb 28 00:08 FreeB-h0-f002.vmdk
-rw------- 1 yael yael 2214592512 Feb 28 00:08 FreeB-h0-f003.vmdk
-rw------- 1 yael yael        563 Feb 28 00:08 FreeB-h0.vmdk
-rw-r--r-- 1 yael yael 4261412864 Feb 28 00:10 FreeB-h1-f001.vmdk
-rw-r--r-- 1 yael yael 4261412864 Feb 28 00:11 FreeB-h1-f002.vmdk
-rw-r--r-- 1 yael yael 2214592512 Feb 28 00:11 FreeB-h1-f003.vmdk
-rw-r--r-- 1 yael yael        563 Feb 28 00:11 FreeB-h1.vmdk
-rw-r--r-- 1 yael yael          0 Feb 28 00:08 FreeB.vmsd
-rwxr-xr-x 1 yael yael       1372 Feb 28 00:14 FreeB.vmx
-rw-r--r-- 1 yael yael        260 Feb 28 00:08 FreeB.vmxf

vm/rhel-7:
total 31457504
-rw------- 1 yael yael 4261412864 Feb 27 23:10 rhel-7-h0-f001.vmdk
-rw------- 1 yael yael 4261412864 Feb 27 23:11 rhel-7-h0-f002.vmdk
-rw------- 1 yael yael 4261412864 Feb 27 23:12 rhel-7-h0-f003.vmdk
-rw------- 1 yael yael 4261412864 Feb 27 23:14 rhel-7-h0-f004.vmdk
-rw------- 1 yael yael 4261412864 Feb 27 23:16 rhel-7-h0-f005.vmdk
-rw------- 1 yael yael 4261412864 Feb 27 23:17 rhel-7-h0-f006.vmdk
-rw------- 1 yael yael 4261412864 Feb 27 23:19 rhel-7-h0-f007.vmdk
-rw------- 1 yael yael 2382364672 Feb 27 23:20 rhel-7-h0-f008.vmdk
-rw------- 1 yael yael        766 Feb 27 23:20 rhel-7-h0.vmdk
-rw------- 1 yael yael       8684 Feb 27 23:22 rhel-7.nvram
-rw-r--r-- 1 yael yael          0 Feb 27 23:21 rhel-7.vmsd
-rwxr-xr-x 1 yael yael       2522 Feb 27 23:22 rhel-7.vmx
-rw-r--r-- 1 yael yael        261 Feb 27 23:21 rhel-7.vmxf
-rw-r--r-- 1 yael yael     204488 Feb 27 23:22 vmware.log
yael@never-mind:/data$ 

I am always allocating the full space for all my disk-images, because then I am not experiencing surprises, because they won’t grow any more.

Compressing these empty files takes a few minutes, but the result is pretty small. The inflation of the compressed tar-file to its original size in contrast is very fast.

yael@never-mind:/data/vm$ du -sh *
21G     FreeB
31G     rhel-7

Is being deflated to a tenth of a percent.

yael@never-mind:/run/media/yael/TOSHIBA EXT/backup/vm$ du -sh *
20M     FreeB.tgz
30M     rhel-7.tgz

Well, for an empty image this is an acceptable result, but as soon as we have installed operating systems this ratio will be lost. Then we will need to to make a compromise between time and consumed storage space.

After I finally screwed an installation, I can restore the backup with the following commands:

yael@never-mind:/data/vm$ mv FreeB FreeB.old
yael@never-mind:/data/vm$ ls -l
total 8
drwxr-xr-x 2 yael yael 4096 Feb 28 12:11 FreeB.old
drwxr-xr-x 2 yael yael 4096 Feb 28 12:11 rhel-7
yael@never-mind:/data/vm$ tar xvzf /run/media/yael/"TOSHIBA EXT"/backup/vm/FreeB.tgz
# I spare you the output of my tar-command
yael@never-mind:/data/vm$ ls -l
total 12
drwxr-xr-x 2 yael yael 4096 Feb 28 12:11 FreeB
drwxr-xr-x 2 yael yael 4096 Feb 28 12:11 FreeB.old
drwxr-xr-x 2 yael yael 4096 Feb 28 12:11 rhel-7
yael@never-mind:/data/vm$ rm -rf FreeB.old

Please always have enough space left to perform such a restore!

This is it actually for this article. Now I can mess around with my images and screw them as I like. Whenever I reach a level I am happy with, I am doing a backup of that image, so that I easily can restore that stage.

Depending on the compression ratio, I may see myself forced to replace the z-parameter with a ‘j’ for bzip2 or a ‘J’ for xz-compression. Of course these two compression algorithms will require more time to reach their results.