Mk Kid Disks

Similar resources

(Additional review may be warranted, to see if large portions of guides an be combined. (A similar process may be described in a later part of this guide: making a child disk.) (For now, it is recommended to just ignore that hyperlink; the resource will be referred to later.)

Rationale

The main purpose of this first machine was to create the parent disk images, and that's been done now. However, the virtual machine could be usable. Sometimes it is nice to have a virtual machine that is readily available for use, but without concern about making undesirable modifications to a machine that has come relatively important.

However, if we do decide to use this virtual machine, then there's no reason to use an old crummy uncompressed disk image. Actually, what we'll probably want to do, in the near-ish future, is to just delete the uncompressed disk images. However, until the compressed versions have been verified as working and usable, let's keep those uncompressed disk images around. We won't delete them.

Stopping the virtual machine

This section was written to be part of a tutorial. Normally, the process of creating a child image (which is described by Virtual Machine Disk Image Snapshots) involves making sure that the virtual machine is stopped. If the previous action was to compress the disk images, then stopping the “virtual machine” may be an action that has already been done. (If the virtual machine was stopped, in order to compress the disk, and the virtual machine hasn't been restarted, then there is not likely any strong need to be re-checking that the virtual machine is still stopped. If there is a reasonable possibility that the machine may have been started, perhaps by another authorized user, then checking is worthwhile.)

Childing the second disk

This process will child the second disk's image first, before this process childs the first disk's image.

These instructions presume that the virtual machine variables are still set.

These instructions also assume that the following variables have just been set (when performing the compressing a “virtual machine” disk image process to compress a file, perhaps near the conclusion of preparing for offspring). As a result, the following variables are presuemd to be set:

${VMDskDir}

If this got unset, then simply re-set it.

Others
  • These instructions, as written, may assume that ${VMDskEnd} points to the first disk filename where the image is supposed to be turned into a “child image”. Presumably, that will be the filename for the “disk image” file that is being used as a virtual machine's second disk.

    If ${VMDskEnd} is not currently set to that value, then either appropriately adapt from the instructions or, even simpler, just set that variable and then follow the instructions.

  • ${VMDskBeg} is also presumed to also still be set, though these instructions don't rely on that.

The goal of this section is the adjust the files that were recently created, so that the virtual machine will start to use a new child image that is based on the recently created copies.

Define what disk to work on

Because ${VMDskEnd} might already be pointing to a useful filename for the second disk image, we'll start by handling the image for the virtual machine's second disk.

This guide will start with VMCrDsNm set to 2.

export VMCrDsNm=2
Perform common steps

This first step is probably unnecessary. (The variable must be unset, but it probably already is.)

unset VMDskMom

The prior steps were just preperation for this:

OLDER NOTES
(Skip these... they will be removed after some further confirmation of the newer text) (Might want to keep the rationale?) VMDskImg VMDskImg=${VMDskDir}/${VMLILNAM}2.qc2

As is, the virtual machine is set to use a file named . If those values weren't recently erased, those values might not being changed; the variables may be set to the new value, but the new value might just be the same as the old value. They are just being set to show the values that are expected to be probable, and to make these instructions more identical to the next set of instructions that do require changing the values.

The ${VMDskEnd} variable is used for pointing to the compressed disk image, since childing is sensible to do after compression and so ${VMDskEnd} might already be set (from the compression process).

The ${VMDskKid} is a variable to point to the desired child image.

We'll start with the second disk, since the variables may presumably already be set to point to those file locations.

echo VMDskDir=${VMDskDir}
[ "X${VMDskDir}" = "X" ] && export VMDskDir=${VMDirBas}/diskimgs/baseimgs/${VMGenNam}/${VMLILNAM}/.
echo VMDskDir=${VMDskDir}
ls -Fltr ${VMDskDir}
echo Older VMDskKid value, if any =${VMDskKid}
export VMDskKid=${VMDskDir}/${VMLILNAM}2.qc2
echo Newer VMDskKid value=${VMDskKid}

Move the file.

Rationale behind moving the file

We're about to create a new file named ${VMDskKid}. To make sure that no desirable data is erased, make sure that there is not currently a file using that name. At this point, there probably is a file using that name, so that file will get moved out of the way. (The other option, as an alternative, would be to delete the file. That probably should be done eventually, after verifying that the newer file, which is about to get created, works as intended.)

sudo mv -i ${VMDskKid} ${VMDskDir}/${VMLILNAM}2-parent-old-uncompressed.qc2

If you are asked a question about overwriting the file, then the safest course of action is probably to say “n” (and pressing Enter... that answers “no” to the question), and then manually move the file to a unique filename.

ls -Fltr ${VMDskDir}

The virtual machine is now set to use ${VMDskKid}, but no such file exists. So let's fix that, by making a child image.

echo Older VMDskEnd value=${VMDskEnd}
export VMDskEnd=${VMDskDir}/${VMLILNAM}2-parent-compressed.qc2
echo Newer VMDskEnd value=${VMDskEnd}
echo About to create VMDskKid=${VMDskKid}
ls -Fltr ${VMDskDir}

Make the child...

( sudo qemu-img create -f qcow2 -o backing_file=${VMDskEnd} ${VMDskKid} ; echo Result=${?} ) 2>&1 | sudo -n tee -a ${VMDskKid}-creation-log.txt
echo ${?}
cat ${VMDskKid}-creation-log.txt
ls -Fltr ${VMDskDir}
END OLDER NOTES
Childing the first disk

Did that work well? Great. Do the same process to make a child image of the first disk.

Define what disk to work on

Because ${VMDskEnd} might already be pointing to a useful filename for the second disk image, we'll start by handling the image for the virtual machine's second disk.

Set VMCrDsNm 1.

export VMCrDsNm=1
Perform common steps

Unlike the last time this was recommended, this first step is probably necessary this time.

unset VMDskMom

The prior steps were just preperation for this:

OLDER NOTES (DISK 1)
(Skip these... they will be removed after some further confirmation of the newer text)
echo VMDskDir=${VMDskDir}
[ "X${VMDskDir}" = "X" ] && export VMDskDir=${VMDirBas}/diskimgs/baseimgs/${VMGenNam}/${VMLILNAM}/.
echo VMDskDir=${VMDskDir}
ls -Fltr ${VMDskDir}
echo Older VMDskKid value, if any =${VMDskKid}
export VMDskKid=${VMDskDir}/${VMLILNAM}1.qc2
echo Newer VMDskKid value=${VMDskKid}

Move the file:

sudo mv -i ${VMDskKid} ${VMDskDir}/${VMLILNAM}1-parent-old-uncompressed.qc2

If you are asked a question about overwriting the file, then the safest course of action is probably to say “n” (and pressing Enter... that answers “no” to the question), and then manually move the file to a unique filename.

ls -Fltr ${VMDskDir}

The virtual machine is now set to use ${VMDskKid}, but no such file exists. So let's fix that, by making a child image.

echo VMDskEnd=${VMDskEnd}
export VMDskEnd=${VMDskDir}/${VMLILNAM}1-parent-compressed.qc2
echo VMDskEnd=${VMDskEnd}
echo About to create VMDskKid=${VMDskKid}
ls -Fltr ${VMDskDir}

Make the child...

( sudo qemu-img create -f qcow2 -o backing_file=${VMDskEnd} ${VMDskKid} ; echo Result=${?} ) 2>&1 | sudo -n tee -a ${VMDskKid}-creation-log.txt
echo ${?}
cat ${VMDskKid}-creation-log.txt
ls -Fltr ${VMDskDir}
END OLD NOTES (DISK1)

Now the virtual machine is using much smaller disk images (because the files that it is directly using are child images).

However, an even bigger, beautiful, great aspect to this whole process is that the parent images are set to “read only” status. Not only are they being used for the “child” images of this machine, but they can also be used as parent images for other machines too.

This guide is intentionally leaving some of the environment variables set.