Snapshots restore files on Writetrough Disk

Discussions related to using VirtualBox on Windows hosts.
Post Reply
CyanCetus
Posts: 7
Joined: 6. Aug 2022, 22:23

Snapshots restore files on Writetrough Disk

Post by CyanCetus »

Hello dear community,
Writetrough disks should be excluded from the snapshot. Deleted files should not be recovered on Writetrough disks, right?
I have 2 disk on my VM: Normal (VDI) and Writetrough (VDI). I expect file recovery only on Normal disk type.
But files are restored on both disks. Why?
CyanCetus
Posts: 7
Joined: 6. Aug 2022, 22:23

Re: Snapshots restore files on Writetrough Disk

Post by CyanCetus »

I totally don't understand what's going on... The virtualbox help says (chapter 5.4. Special Image Write Modes):
"Write-through hard disks are completely unaffected by snapshots. Their state is not saved when a snapshot is taken, and not restored when a snapshot is restored."
I use two VDI on my VM. First VDI: Normal type. Created for system using (OS, applications, system configuration). I want to take snapshots only from Normal disk type.
Second VDI: Write-through type. Created for file storage. I don't want to take snapshot from Write-through disk.
But files are restored on Write-through disk... I do not understand anything.
Please check me step by step. I will try to be as detailed as possible.
1. I created new VM with new VDI (Normal type for system using). Capacity 30GB. Screenshot https://www.dropbox.com/s/gy764nib8kljr ... 8.png?dl=0
2. I created new VDI (Write-through type for file storage). Capacity 50GB. https://www.dropbox.com/s/2g2cfr621yuqo ... 2.png?dl=0
3. Check attached to VM disks. First https://www.dropbox.com/s/8ospntq1fx4w9 ... 6.png?dl=0 second https://www.dropbox.com/s/8zr79tm9zp6a2 ... 7.png?dl=0
4. Now I'm install Windows 10 on 30GB disk (Normal type) https://www.dropbox.com/s/g0uk8bkozy51s ... 8.png?dl=0
5. Initialization wright-trough disk after Windows installation https://www.dropbox.com/s/0dnlszujxk5ak ... 9.png?dl=0
6. Now I have 2 local disk in Windows Explorer https://www.dropbox.com/s/tw8vf0c14dcf1 ... 2.png?dl=0
Now it will be interesting
7. Create test folders https://www.dropbox.com/s/fhv3vg2x9z4gn ... 3.png?dl=0
8. Take snapshot https://www.dropbox.com/s/ce1x0r39d34eb ... 5.png?dl=0
9. Test folders deleted using SHIFT+DEL https://www.dropbox.com/s/icjf5t3wyjmz4 ... 8.png?dl=0
10. Shutting down VM and restore Test 1 snapshot https://www.dropbox.com/s/orv5cr5ijt29v ... 1.png?dl=0
I expect to restore test folder on only drive C:\ (Normal type)
11. Why test folder restored on Write-trough disk (E:\)? https://www.dropbox.com/s/edqmh7ojn7ngm ... 3.png?dl=0
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Snapshots restore files on Writetrough Disk

Post by fth0 »

I just tried more or less the same experiment, and for me, it just works. ;)

Please do the following: Repeat the experiment, and after taking the snapshot, shut down the VM from within the guest OS, go to the Virtual Media Manager, Refresh the view, and see if the writethrough disk image got a child. Depending on the result, the difference is before or after this step. BTW, when/how did you take the snapshot?
CyanCetus
Posts: 7
Joined: 6. Aug 2022, 22:23

Re: Snapshots restore files on Writetrough Disk

Post by CyanCetus »

Hello, thanks for reply.
1. I deleted snapshot, here current Virtual Media Manager https://www.dropbox.com/s/nq5wzlzzumip9 ... 4.png?dl=0
2. Created test files https://www.dropbox.com/s/aajnq1t5bxfyf ... 5.png?dl=0
3. Take snapshot Test 2 https://www.dropbox.com/s/qt1w701k3mimj ... 6.png?dl=0
I don't know if this matters or not. After snapshot taking, guest OS notified by default sound about device disconnecting.
4. After snapshot taking test files was deleted by SHIFT+DELETE https://www.dropbox.com/s/idch79qz65nv7 ... 7.png?dl=0
5. Shutting down VM from guest OS and refresh Virtual Media Manager. As you can see only Normal disk have child https://www.dropbox.com/s/tvyvi6zchfzl3 ... 8.png?dl=0
6. Restore snapshot Test 2 https://www.dropbox.com/s/fs1fitbfp4rfl ... 0.png?dl=0
7. Test files was restored on both disks https://www.dropbox.com/s/02fmtg7nv8j1n ... 1.png?dl=0
I don't understand why the file is was restored on Writetrough disk.

After snapshot restore, guest OS notified by default sound about device connecting.
In answer to your question, the snapshot was taken right after the test files creation by Host+T hotkey
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Snapshots restore files on Writetrough Disk

Post by fth0 »

Ok, I have a rough idea what happens:

First of all, the Virtual Media Manager shows that VirtualBox does not create a differencing image for the write-through disk, so that works as expected.

Then you're taking an online snapshot, which consists of the current VM configuration, a snapshot image of the normal disk, and a saved memory state. When you later restore the snapshot, you'll get the saved memory state, which contains for example the guest OS's disk cache and the screen contents. I think there is enough potential to shoot yourself in the foot with that. ;)

If you'd take an offline snapshot instead, it would only contain the current VM configuration and a snapshot image of the normal disk. Try taking a snapshot after the VM has been shut down from within the guest OS, to see if it works as expected.
CyanCetus
Posts: 7
Joined: 6. Aug 2022, 22:23

Re: Snapshots restore files on Writetrough Disk

Post by CyanCetus »

Thanks you so much! I didn't know the difference between online and offline snapshots. Offline works as expected. Files restored only on Normal disk
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Snapshots restore files on Writetrough Disk

Post by fth0 »

You're welcome, and thanks for reporting back! :)
Post Reply