Sign in to follow this  
Polanskiman

Tutorial: How to mout raided VHD/VDI VM files

Recommended Posts

If you can't access DSM but you still wish to try and 'fix' some configuration files or perhaps you wish to finally make that backup that you should have done before fiddling with the root user, then you can access the content of the system partition and data partitions through a Live Ubuntu USB or a VM Ubuntu install. I wont go into details how to setup ubuntu on a USB or VM. Search and you shall find.

 

1 - Once in Ubuntu, import all your VHD/VDI files from the RAID array at your preferred location. Now launch Terminal. You will need to first be root so type:

sudo -i

2 - Now install qemu mdadm and lvm2

apt-get install qemu mdadm lvm2

3 - Now load the nbd kernel module by running the following command:

modprobe nbd

4 - Then run qemu-nbd. This is a user space loopback block device server for qemu-supported disk images: (I have 2 raided VHD files, so I need to run the command twice):

qemu-nbd -c /dev/nbd0 /path/to/vhdfile
qemu-nbd -c /dev/nbd1 /path/to/vhdfile2

You need to run the command as many times as you have VHD/VDI files in your RAID array making sure each device has a unique name (/dev/nbd0 /dev/nbd1 ....) and of course providing the path to each individual VHD/VDI file.

 

If you wish to mount the data partition alone then proceed with the following command:

 

5 - To mount the data partition, simply issue this command and you are done:

mdadm -Asf && vgchange -ay

The data partition should now be mounted and accessible.

 

If you also wish to mount the system partition then proceed with the following commands (adapt to your case accordingly):

 

6 - Then you need to check your RAID array and partitioning of your files/drives:

fdisk -l | grep /dev/nbd

In my case I see this. Note I only have 2 drives /dev/nbd0 and /dev/nbd1

[spoiler=]

root@test-VirtualBox:~# fdisk -l | grep /dev/nbd
Disk /dev/nbd0: 8 GiB, 8589901824 bytes, 16777152 sectors
/dev/nbd0p1         2048  4982527 4980480  2.4G fd Linux raid autodetect
/dev/nbd0p2      4982528  9176831 4194304    2G fd Linux raid autodetect
/dev/nbd0p3      9437184 16572415 7135232  3.4G fd Linux raid autodetect
Disk /dev/nbd1: 8 GiB, 8589901824 bytes, 16777152 sectors
/dev/nbd1p1         2048  4982527 4980480  2.4G fd Linux raid autodetect
/dev/nbd1p2      4982528  9176831 4194304    2G fd Linux raid autodetect
/dev/nbd1p3      9437184 16572415 7135232  3.4G fd Linux raid autodetect

System partitions are the ones labeled nbd0p1, nbd1p1. If you have more drives in the array, subsequent system partitions will probably be called nbd2p1, nbd3p1 so on and so forth. This will depend how you named the devices earlier. You get the point.

 

7 - Once you figured out all system partitions, you can examine the foreign endian array members by issuing (this is for my case, with 2 drives):

mdadm -Ee0.swap /dev/nbd0p1 /dev/nbd1p1

If you have 3 drives then you add /dev/nbd2p1. You get the idea.

 

8 - Finally, assemble the array and fix the byte order (this is for my case, with 2 drives):

mdadm -AU byteorder /dev/md0 /dev/nbd0p1 /dev/nbd1p1

Same comment as previous command; add any additional system partitions that you may have. Beware of the /dev/md0. It's normal, not a mistake.

 

Your system partition should now be mounted and you can navigate through the system files. Make the changes you need to do. When finished simply unmount the RAID array. Now this will seem silly but if you are on a Live Ubuntu USB make sure you copy your VHD/VDO files out of the USB drive onto some other device before shutting down Ubuntu. Reason is that the Live Ubuntu USB is not persistent and any changes that were made in Ubuntu or files that where copied into Ubuntu will be deleted. Basically Ubuntu will be reset to defaults. If you are on a Ubuntu VM like a am then obviously this does not apply.

 

---------

Reference:

https://ubuntuforums.org/showthread.php?t=2299701&p=13378414#post13378414

https://bethesignal.org/blog/2011/01/05/how-to-mount-virtualbox-vdi-image/

https://www.synology.com/en-global/knowledgebase/DSM/tutorial/Storage/How_can_I_recover_data_from_my_DiskStation_using_a_PC

http://xpenology.com/forum/viewtopic.php?f=2&t=22100&p=83631&hilit=version#p83631

http://xpenology.com/forum/viewtopic.php?f=2&t=20216&p=74659&hilit=mdadm#p74659 >> Thanks to Jun

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this