Labels

Android (1) bash (2) boost (2) C (34) C++ (2) cheatsheet (2) CLion (6) css (3) Debian (33) DL (17) Docker (1) Dreamweaver (2) Eclipse (3) fail2ban (4) git (5) GitHub (4) Hacking (3) html (8) http (1) iOS (1) iPad (1) IRC (1) Java (30) javascript (3) Linux (164) Mac (19) Machine Learning (1) mySQL (47) Netbeans (4) Networking (1) Nexus (1) OpenVMS (6) Oracle (1) Pandas (3) php (16) Postgresql (8) Python (9) raid (1) RedHat (14) Samba (2) Slackware (45) SQL (14) svn (1) tar (1) ThinkPad (1) Virtualbox (3) Visual Basic (1) Visual Studio (1) Windows (2)

Wednesday 15 September 2021

Restoring a fsarchiver file to a temporary block device.

 Restoring a fsarchiver file to a temporary block device.


1 - Check the size of the fsa file with;


sudo fsarchiver archinfo file.fsa

An example of which is as below;

====================== archive information ======================
Archive type:                   filesystems
Filesystems count:              1
Archive id:                     5fe095a4
Archive file format:            FsArCh_002
Archive created with:           0.6.15
Archive creation date:          2020-12-22_11-39-27
Archive label:                  <none>
Minimum fsarchiver version:     0.6.4.0
Compression level:              3 (gzip level 6)
Encryption algorithm:           none

===================== filesystem information ====================
Filesystem id in archive:       0
Filesystem format:              ext4
Filesystem label:
Filesystem uuid:                4443705c-4a14-4475-b202-cab3132977e5
Original device:                /dev/sda6
Original filesystem size:       91.67 GB (98428792832 bytes)
Space used in filesystem:       1.88 GB (2019938304 bytes)


We are interested in the "Space used in filesystem"

2 - We want to create an image file that is just slightly larger than the "Space used in filesystem" from above, in our case 2Gb


So we create an image file as below;

dd if=/dev/zero of=device.img count=2 bs=1G

3 - We need to fine an unused loopback device with;


sudo losetup -f


If there isn't one, we can add one as below;

modprobe loop max_loop = 128 [ source ]

4 - We now need to associate the image file image.img with the loopback device;


sudo losetup /dev/loop0 device.img

5 - We now need to restore the image as below;


sudo fsarchiver restfs file.fsa id=0,dest=/dev/loop0

6 - We now need to mount the device (make a suitable mount point first with mkdir if needed);


sudo mount /dev/loop0 /media/temp_mount

7 - Do what you need to do, get what you need to get and then get out of here...


When we're done, we need to unmount;

sudo umount /media/temp_mount

we need to remove the association between our loopback device and our image file;

sudo losetup -d /dev/loop0

Finally, we need to remove the image file;

rm device.img

No comments:

Post a Comment

Note: only a member of this blog may post a comment.