Score:2

Access existing contents of a mounted partition

br flag

I am currently trying out a new server setup on a VirtualBox VM. In my scenario I have attached two (virtual) hard drives; I use one as the main system disk and the other one as a local backup drive. The backups are performed with borg/borgmatic to the backup drive. I plan to use the same setup later on the real server (with real disks).

In order to test a scenario where I lose the system disk and try to get the data on the backup system, I created a new virtual machine with a new system disk and attached the existing disk to the VM. fdisk -l will display the existing drive as /dev/sdb1.

When I mount this drive with mount /dev/sdb1 /backup, I don't see the contents previously on the drive and so far I have not figured out a way to access them.

When mounted, the result of file -s /dev/sdb1 is:

Linux rev 1.0 ext4 filesystem data, UUID=[...], volume name "disk2" (needs journal recovery) (extents) (64bit) (large files) (huge files)

So I do:

$ umount /backup
$ e2fsck -p /dev/sdb1
disk2: clean 11/1310720 files, 126322/5242624 blocks

(I need to unmount first to be able to run e2fsck)

After that I get

Linux rev 1.0 ext4 filesystem data, UUID=[...], volume name "disk2" (extents) (64bit) (large files) (huge files)

However, when I mount the drive again, I still get the (needs journal recovery) remark with file -s.

If I want to restore the data from the backup drive, I naturally need to access its contents. Is there a way to do this?

djdomi avatar
za flag
what fs was used? what tells lsblk?
br flag
@djdomi: fs is ext4, what specific output of lsblk do you care for? NAME,SIZE,LABEL,OWNER,GROUP,MODE,TYPE are sdb1, 20G, disk2, root, disk, brw-rw----. part
djdomi avatar
za flag
please post this infos in your question by editing, not as comment
Chris Heath avatar
cn flag
what results do you get when you run `fsck -y /dev/sdb1` ?
in flag
Are you doing all this while the first VM is running?
br flag
@GeraldSchneider: No, the other VM is not running, but the drive has also not been properly unmounted either.
Score:0
it flag

as suggested by the comments you cannot access one virtual hard drive simultaneously by more than one virtual machine.

Oracle VirtualBox has expanded a functionality that allows you to do so https://www.oracledistilled.com/virtualbox/creating-shared-drives-in-oracle-vm-virtualbox/

but this is for specific use cases such as testing Oracle RAC or some other cluster solutions that allow using shared block devices.

Long story short - properly unmount your disk and power off your VM. Detach the virtual disk from the VM and afterwards attach it to another properly shut down VM. No VM can be in a paused state or have any snapshots in place for the virtual drive in question. If these conditions are met you should see your data on another VM after bootup.

BTW proper backup solutions do not deal with local drives but store backups on a NAS which is then used to recover such data - be it application data or OS itself.. To prevent ransomware encryption more sophisticated data storage and/or access control is used.

br flag
The local backup is not my only one. I have an encrypted remote backup, too.
Roman Spiak avatar
it flag
Please try the suggestions in my answer and comment if it works as expected. For the off-topic discussion - encrypted remote backup does not provide any protection to ransomware that encrypts your data - you'll just end up with data encrypted twice without the means of doing the 1st decryption :)
br flag
I will try in due time once get to it.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.