Mount CloneZilla image: Difference between revisions

From WickyWiki
m 15 revisions
No edit summary
Line 3: Line 3:
[[Category:Ubuntu System]]
[[Category:Ubuntu System]]
[[Category:2009]]
[[Category:2009]]
Note: 201201 extracted an ext4 image but couldn't mount it.


Locate image and go there, you will find files like: "sda1.ntfs-img.aa" and "sda1.ntfs-img.ab" ...
Locate image and go there, you will find files like: "sda1.ntfs-img.aa" and "sda1.ntfs-img.ab" ...
Line 14: Line 13:
Note: the image you are about to extract will be sized to the original partition-size, unused space included. This can take quite some time and disk space.
Note: the image you are about to extract will be sized to the original partition-size, unused space included. This can take quite some time and disk space.


== Windows NTFS partition ==
=Windows NTFS partition=


You will need ntfsclone, install
You will need ntfsclone, install
Line 33: Line 32:
</syntaxhighlight>
</syntaxhighlight>


== Linux ext4 partition ==
=Linux ext4 partition=


You will need partclone, download the deb package from:
==Extract==
* https://launchpad.net/ubuntu/precise/amd64/partclone/0.2.22-2 (amd64)
 
Install partclone:


Install with:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo dpkg -i partclone_0.2.22-2_amd64.deb
add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
apt-get update
apt-get install partclone
</syntaxhighlight>
</syntaxhighlight>


Lets say compression is gzip (as it probably is), then we need to extract the image using gzip:
Lets say compression is gzip (as it probably is), then we need to extract the image using gzip:
Options:
* -C ignore size errors
* -F force
* -O overwrite
* -s <> source, specify - to use standard input (pipe)
* -o <outputfile>
<syntaxhighlight lang=bash>
cat sda5.ext4-ptcl-img.gz.* | gzip -d -c | partclone.restore --restore_row_file -F -O -C -s - -o sda5.img
</syntaxhighlight>
Mount/unmount with:
<syntaxhighlight lang=bash>
mkdir /media/ubuntutje
mount -o loop -t ext4 sda5.img /media/sda5img
umount /media/sda5img
</syntaxhighlight>
==Restore==
You can do this instead of using CloneZilla if you have 'geometry' errors or other problems.
Check for (mount) errors:
<syntaxhighlight lang=bash>
dmesg | tail
</syntaxhighlight>
Fix errors (if any)
<syntaxhighlight lang=bash>
fsck.ext4 -f sda5.img
e2fsck -f sda5.img
</syntaxhighlight>
Resizing the filesystem on sda5.img to minimum size. Note: this can take a lot of time
<syntaxhighlight lang=bash>
resize2fs -M sda5.img
</syntaxhighlight>
Restore to partition, in this example /dev/sda3.
THIS WILL OVERWRITE THE TARGET PARTITION!!
ALL DATA ON THAT PARTITION (/dev/sda3) WILL BE LOST!!
Note: after this only the earlier 'minimum size' of the partition is used


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
cat *.ext4-ptcl-img.* | gzip -d -c | sudo partclone.restore -C -s - -O ext4.img
partclone.restore -d -s sda5.img -o /dev/sda3
</syntaxhighlight>
</syntaxhighlight>


Mount with:
Resize partition to fit the whole available space:
 
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo mkdir /media/ext4-img
e2fsck -f /dev/sda3
sudo mount -o loop -t ext4 ext4.img /media/ext4-img
resize2fs /dev/sda3
</syntaxhighlight>
</syntaxhighlight>

Revision as of 07:43, 15 September 2013


Locate image and go there, you will find files like: "sda1.ntfs-img.aa" and "sda1.ntfs-img.ab" ...

Find what compression has been used, gzip, bzip or lzop?

file *.ntfs-img.aa

Note: the image you are about to extract will be sized to the original partition-size, unused space included. This can take quite some time and disk space.

Windows NTFS partition

You will need ntfsclone, install

sudo apt-get install ntfsprogs

Lets say the compression is gzip (as it probably is), then we need to extract the image using gzip.

sudo cat *.ntfs-img.* | gzip -d -c | ntfsclone --restore-image -o ntfs.img -

Mount with:

sudo mkdir /media/ntfs-img
sudo mount -o loop -t ntfs ntfs.img /media/ntfs-img

Linux ext4 partition

Extract

Install partclone:

add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
apt-get update
apt-get install partclone

Lets say compression is gzip (as it probably is), then we need to extract the image using gzip:

Options:

  • -C ignore size errors
  • -F force
  • -O overwrite
  • -s <> source, specify - to use standard input (pipe)
  • -o <outputfile>
cat sda5.ext4-ptcl-img.gz.* | gzip -d -c | partclone.restore --restore_row_file -F -O -C -s - -o sda5.img

Mount/unmount with:

mkdir /media/ubuntutje
mount -o loop -t ext4 sda5.img /media/sda5img
umount /media/sda5img

Restore

You can do this instead of using CloneZilla if you have 'geometry' errors or other problems.

Check for (mount) errors:

dmesg | tail

Fix errors (if any)

fsck.ext4 -f sda5.img
e2fsck -f sda5.img

Resizing the filesystem on sda5.img to minimum size. Note: this can take a lot of time

resize2fs -M sda5.img

Restore to partition, in this example /dev/sda3.

THIS WILL OVERWRITE THE TARGET PARTITION!! 
ALL DATA ON THAT PARTITION (/dev/sda3) WILL BE LOST!!

Note: after this only the earlier 'minimum size' of the partition is used

partclone.restore -d -s sda5.img -o /dev/sda3

Resize partition to fit the whole available space:

e2fsck -f /dev/sda3
resize2fs /dev/sda3