How to mount an fsa image
I did not know where to write it, I think the place will be on the hub Everywhere they write that fsarchiver is a wonderful utility that can create archives with the file system, compresses them well, etc. And indeed it is! And most importantly, these archives can be done on working systems.
But today is a day off, the servers are in another city and one of them has gone down, on the system unit the light with an exclamation mark is lit in red, which means a serious trouble with the glands. We can’t lift it by remote. Of course, we will deal with the server and fix it, but we should rather lift the service on the backup machine. Of course, the images of all servers were carefully made by me using the wonderful fsarсhiver utility.
And then the task arose of how to get configuration files from an fsa image. Of course, if there is an empty hard drive connected to the backup machine, this is not a problem, but if it is not?
A search query like: “how to mount an fsa image” did not return positive answers. And even on the turnover is not a lot of misleading. On the website, the developers said: “Unfortunately it won't be possible to do that we the current file format.” (unfortunately this cannot be done with this file format).
It became sad. But something inside me said that it was possible! After all, this is Linux!
There is still not much search on the Internet and I found the necessary information . Of course, everything is elementary! I already used this command - losetup, but for some reason it completely flew out of my head.
Now just give an example.
To begin with, we need to find out what size we need to make a file that will emulate a block device.
#fsarchiver archinfo backup.fsa Get
what type:
Here we are interested in the parameter Space used in filesystem: 59.61 MB (62504960 bytes),
that is, how much minimum space is needed to deploy the image. 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 the 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 do not use
#losetup -f
If there are none, then we can add.
#modprobe loop max_loop = 128
And we associate the image file with this interface
#losetup / dev / loop0 vd.img
Then we restore our archive
#fsarchiver restfs backup.fsa id = 0, dest = / dev / loop0 to it
And mount
#mount -o loop = / dev / loop0 / mnt / vd
After we pulled out the files we need from the image, we need to unmount it, untie it and delete it - if we don't 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 backup.
But today is a day off, the servers are in another city and one of them has gone down, on the system unit the light with an exclamation mark is lit in red, which means a serious trouble with the glands. We can’t lift it by remote. Of course, we will deal with the server and fix it, but we should rather lift the service on the backup machine. Of course, the images of all servers were carefully made by me using the wonderful fsarсhiver utility.
And then the task arose of how to get configuration files from an fsa image. Of course, if there is an empty hard drive connected to the backup machine, this is not a problem, but if it is not?
A search query like: “how to mount an fsa image” did not return positive answers. And even on the turnover is not a lot of misleading. On the website, the developers said: “Unfortunately it won't be possible to do that we the current file format.” (unfortunately this cannot be done with this file format).
It became sad. But something inside me said that it was possible! After all, this is Linux!
There is still not much search on the Internet and I found the necessary information . Of course, everything is elementary! I already used this command - losetup, but for some reason it completely flew out of my head.
Now just give an example.
To begin with, we need to find out what size we need to make a file that will emulate a block device.
#fsarchiver archinfo backup.fsa Get
what 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 to deploy the image. 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 the 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 do not use
#losetup -f
If there are none, then we can add.
#modprobe loop max_loop = 128
And we associate the image file with this interface
#losetup / dev / loop0 vd.img
Then we restore our archive
#fsarchiver restfs backup.fsa id = 0, dest = / dev / loop0 to it
And mount
#mount -o loop = / dev / loop0 / mnt / vd
After we pulled out the files we need from the image, we need to unmount it, untie it and delete it - if we don't 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 backup.