In this section we will look at a concept called Snapshots.
In the previous question we mounted via a loop device a disk image
/images/usbimg1.dd. However, we could only mount this read only.
Taking a disk image and then forensically examining it, while making
sure it is not changed, is important as this ensures we are not introducing
things into evidence accidentally.
However, sometimes a disk image needs to be changed as part of an investigation.
This could be to correct an error which is stopping us conducting the investigation. An example of this could be that the partition table is damaged and thus
we cannot access the partitions and files. There are tools available to correct
damaged partition tables, but these require write access to the image.
One approach to solving this would be to take a second disk copy and make
changes to that, but that could easily be hundreds of gigabytes or more.
Instead, we will look at a way of accessing a read only image in a way
that writes seem to work, but with the writes going to a seperate file.
In this way the original image is still safe, and we can make changes to
the way we see this disk in a safe and efficient manner.
For the purposes of learning about snapshots, we are going to mount the usbimg1.dd
disk image in a way that the image itself is read only, but that we can add
a small file to the mount data.
Firstly, create a small file to hold any changes made. The changes are held
at the block level, so the file needs to be large enough to hold all the blocks
which will be changed. For simplicity, make this file 2MB in size.
To do this, use the "dd" command to create 2mb of empty data. Write this
into the /root directory, and to do this you will need to use sudo.
dd if=/dev/zero of=/root/changes bs=512 seek=4095 count=1
A trick here is to use "seek" to jump straight to the last block.
This tricks Linux into creating a file which can hold 2mb, but which actually
only has a size equal to the amount of changes made. It is called a sparse data
file, and is very efficient if dealing with gb of data.
Use an admin level "ls" command, with the flags "-lhs" on /root. This
reports:
???? -rw-r--r-- 1 root root 2.0M 2012-02-13 13:20 changes
The "????" indicates the size which this file is actually taking up on disk,
while it says that it could take "2.0M" of data. What size is it ACTUALLY
taking up? The test is case sensitive, so if the size is in capital letters
make sure you do that in your answer here.
Actual usage: