📜 ⬆️ ⬇️

How to mount an image fsa

I did not know where to write it, I think the place will be on the habr. Everywhere they write that fsarchiver is a great utility that can create archives with a file system, compresses them well, etc. And indeed it is! And the most important thing is that these archives can be done on working systems.

But today is the day off, the servers are in another city and one of them lay down, on the system unit a light bulb with an exclamation mark is lit in red, which means a hard trouble with glands. We can’t raise it. With the server, of course, we'll figure it out and fix it, but we should rather raise the service on the backup machine. Images of all servers were of course carefully made by me with the help of the wonderful utility fsarhiver.
And now the task was how to get the configuration files from the fsa-image. Of course, if there is an empty hard drive connected to the machine with backups, this is not a problem, and if it is not there?
Search query type: "how to mount an image of fsa" did not give positive answers. And even in turn, he did not mislead much. On the site, the developers said: “It’s the current file format.” (Unfortunately, this is not possible with this file format).
It became sad. But something inside me said that it was possible! After all, it is Linux!
Still not a lot of searching on the Internet and I found the information you need. Of course, everything is elementary! I have already used this team - losetup, but for some reason it completely flew out of my head.

Now just give an example.
First of all, we need to know what size we need to make a file that will emulate a block device.
')
#fsarchiver archinfo backup.fsa

We get that type:

===================== Filesystem Information ====================
Filesystem id in archive: 0
Filesystem format: ext4
Filesystem label: lboot
Filesystem uuid: f8eebcb0-ba54-47e4-8a86-769880291a3e
Original device: / dev / md0
Original filesystem size: 921.43 MB (966189056 bytes)
Space used in filesystem: 59.61 MB (62504960 bytes)


Here we are interested in the parameter Space Used in filesystem: 59.61 MB (62504960 bytes)
that is, how much minimum space is needed for image deployment. The image file should be slightly larger.
Create an empty vd.img file with a size of 100 megabytes (59.61 MB required).
The parameters speak for themselves count-number of blocks, bs-their size.

#dd if = / dev / zero of = vd.img count = 100 bs = 1M

Then let's see which loopback interfaces we don't use.

#losetup -f

If there are none, then you can add.

#modprobe loop max_loop = 128

And associate the image file with this interface.

#losetup / dev / loop0 vd.img

Then we restore our archive to it.

#fsarchiver restfs backup.fsa id = 0, dest = / dev / loop0

And we mount

#mount -o loop = / dev / loop0 / mnt / vd

After we have removed the necessary files from the image, we need to unmount it, untie and delete it - if we do not plan to use it again. The following commands do this.

#umount / mnt / vd
#losetup -d / dev / loop0
#rm -f vd.img

Good luck to everyone, do not forget to make backups.

Source: https://habr.com/ru/post/261831/


All Articles