mount partition image and edit it
-
Hello,
Following this topuic which is quite old : Mount saved image and edit it?I’m looking for a way to mount a fog partition image. I tried many things
Uncompress partition image :
[root@fog images]# cd dev/srvtoip_dev/
[root@fog srvtoip_dev]# pwd
/images/dev/srvtoip_dev
[root@fog srvtoip_dev]# file d1p1.img
d1p1.img: gzip compressed data, from Unix, last modified: Wed Feb 10 10:43:58 2016, max compressionmount image :
[root@fog srvtoip_dev]# losetup /dev/loop0 d1p1.img
losetup: d1p1.img: warning: file does not fit into a 512-byte sector the end of the file will be ignored.I’ve tried many combinations with losetup / mount / gunzip…
Can somebody help me with that ?
Regards,
Cédric -
Give this a try: https://forums.fogproject.org/topic/5264/peek-into-img-files/4
@cml said:
It seems like it would be easier to just restore the image to a client, but I had to find a way.
All of this is done on Debian 7 and like Wayne I would not advise you doing this on your production server.
Breakdown:
Install ntfs-3g, partclone, and pigz
Decompress image and restore to a file
Mount imageapt-get install ntfs-3g partclone pigz cd /images/SecurityE420s/ cat d1p2.img | pigz -d -c | partclone.restore -C -s - -O d1p2_extracted.img mount -t ntfs-3g d1p2_extracted.img /mnt ls -lah /mnt total 6.9G drwxrwxrwx 1 root root 4.0K Aug 27 2014 . drwxr-xr-x 28 root root 4.0K Jun 18 17:15 .. lrwxrwxrwx 2 root root 60 Jul 14 2009 Documents and Settings -> /mnt/Users -rwxrwxrwx 1 root root 9.5K Aug 28 2014 fog.log -rwxrwxrwx 1 root root 3.0G Aug 28 2014 hiberfil.sys drwxrwxrwx 1 root root 0 Aug 27 2014 Intel drwxrwxrwx 1 root root 0 Jun 11 2014 MSOCache -rwxrwxrwx 1 root root 4.0G Aug 28 2014 pagefile.sys drwxrwxrwx 1 root root 0 Jul 13 2009 PerfLogs drwxrwxrwx 1 root root 4.0K Aug 28 2014 ProgramData drwxrwxrwx 1 root root 8.0K Aug 27 2014 Program Files drwxrwxrwx 1 root root 8.0K Aug 27 2014 Program Files (x86) -rwxrwxrwx 1 root root 3.1K Aug 28 2014 QcOSD.txt drwxrwxrwx 1 root root 0 Aug 26 2014 $Recycle.Bin drwxrwxrwx 1 root root 4.0K Jun 11 2014 System Volume Information drwxrwxrwx 1 root root 4.0K Nov 20 2010 Users drwxrwxrwx 1 root root 40K Aug 28 2014 Windows
-
@cml Great answer!! Just want to add that you better be careful not to overwrite d1p3.img if this exists in your image directory… Maybe it’s more clear to name the extracted file d1p2_extracted.img
-
Good catch, the post has been modified.
-
Mind you, @cml’s advice is accurate, but if you need to edit the image, you already have to perform a “restore” regardless of how it’s to be done.
If you extract the data and place it in a file, or you’re running a download task, you have to perform the same actions as a download task.
If you know the same things have to be done every time, you can also create a postdownload script to mount the partition and perform any cursory actions as needed before the task completes. This way, I think, is more appropriate as you’re not using disk space on your FOG Server, as the mounted point is directly off the drive of the system that was just restored. You’re also not leaving the entirety of the image in a potential state of disarray. While you could screw up the postdownload script, you can comment it to stop actions from occurring. Editing the image from a file, then re-uploading that file to the main would make that change permanent for ALL hosts that restore that image.
-
@cml said:
Give this a try: https://forums.fogproject.org/topic/5264/peek-into-img-files/4
hello cml
I’ve tried, but it does not seem to work.
here’s the things I’ve done :[root@fog ]# file d1p1.img d1p1.img: gzip compressed data, from Unix, last modified: Wed Feb 17 15:38:56 2016, max compression [root@fog ]# cat d1p1.img | pigz -d -c | partclone.restore -C -s - -O d1p1_extracted.img Partclone v0.2.71 http://partclone.org Démarrage restauration image (-) vers périphérique (d1p1_extracted.img) device (d1p1_extracted.img) is mounted at error exit Partclone fail, please check /var/log/partclone.log !
I have to precise that “d1p1_extracted.img” is not mounted anywhere. I really don’t understand this error.
Another thing I’ve done, I’ve tried to extract the image :
[root@fog ]# cat d1p1.img | gzip -d -c > d1p1_extract.img [root@fog SrvToip_fpbx_2T0]# file d1p1_extract.img d1p1_extract.img: data [root@fog ]# losetup /dev/loop0 d1p1_extract.img losetup: d1p1_extract.img: warning: file does not fit into a 512-byte sector the end of the file will be ignored.
Any tip ?
Regards,
Cédric -
@Rico Maybe this helps: https://bbs.archlinux.org/viewtopic.php?id=179929
Seams like some kind of weird partclone thing… You might need to create an empty output file first.
As well you want to read this: https://sourceforge.net/p/clonezilla/discussion/Clonezilla_live/thread/4db4b2bd/ (partclone.restore seams to be deprecated and you should use partclone.<fstype>)