Mount CloneZilla image: Difference between revisions

From WickyWiki
m 15 revisions
 
(12 intermediate revisions by the same user not shown)
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" ...
CloneZilla is not always able to restore an image, in that case you could try do do this manually. On the other hand you just might want to look inside the image without having to restore it to a physical partition.
 
=Windows NTFS partition=
 
Note: I didn't test this yet (201309).
 
Guide:
 
* http://www.michielovertoom.com/windows/shrinking-ntfs/
 
==Extract==
 
Install partclone:
 
<syntaxhighlight lang=bash>
add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
apt-get update
apt-get install partclone
</syntaxhighlight>
 
Install ntfsclone:
 
<syntaxhighlight lang=bash>
sudo apt-get install ntfsprogs
</syntaxhighlight>
 
Locate the CloneZilla 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?
Find what compression has been used, gzip, bzip or lzop?
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
file *.ntfs-img.aa
file *.ntfs-img.aa
</syntaxhighlight>
</syntaxhighlight>
Extract partition image (sdb1) from CloneZilla, we assume gzip has been used.


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 ==
Options:
* -C ignore size errors
* -F force
* -O overwrite
* -s <> source, specify - to use standard input (pipe)
* -o <outputfile>


You will need ntfsclone, install
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo apt-get install ntfsprogs
cat sdb1.ntfs-ptcl-img.gz.* | gzip -d -c | partclone.restore --restore_row_file -F -O -C -s - -o sdb1.img
</syntaxhighlight>
 
Define device md0 and mount it:
 
<syntaxhighlight lang=bash>
mdconfig -a -t vnode -f sdb1.img md0
mkdir /media/mnt
mount -t ntfs /dev/md0 /mnt
</syntaxhighlight>
 
==Resize==
 
Check for errors:
 
<syntaxhighlight lang=bash>
dmesg | tail
</syntaxhighlight>
 
Check for the minimum size:
 
<syntaxhighlight lang=bash>
ntfsresize -m /dev/md0
</syntaxhighlight>
 
Apply the resize (in this example 36Mb)
 
After the resize, the imagefile stays at its original size, it's not automatically truncated. We use ntfsclone to extract the relevant data in the next step.
 
Note that this can take considerable time:
 
<syntaxhighlight lang=bash>
ntfsresize --size 36M /dev/md0
</syntaxhighlight>
 
Clone to get the minimum size. The --force is necessary because the resize action flags the volume for a chkdsk check.
 
<syntaxhighlight lang=bash>
ntfsclone --force -o sdb1_shrunk.img /dev/md0
mdconfig -d -u /dev/md0
</syntaxhighlight>
 
==Restore==
 
Restore to partition, in this example /dev/sda1.
 
THIS WILL OVERWRITE THE TARGET PARTITION!!
ALL DATA ON THAT PARTITION WILL BE LOST!!
 
Note: after this only the earlier 'minimum size' of the partition is used
 
<syntaxhighlight lang=bash>
partclone.restore -d -s sdb1_shrunk.img -o /dev/sda1
</syntaxhighlight>
 
Resize to fit partition:
 
<syntaxhighlight lang=bash>
ntfsresize -x /dev/sda1
</syntaxhighlight>
 
=Linux ext4 partition=
 
==Extract==
 
Install partclone:
 
<syntaxhighlight lang=bash>
add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse"
apt-get update
apt-get install partclone
</syntaxhighlight>
 
Lets say compression is gzip (as it probably is), then we need to extract the image using gzip.
 
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.
 
<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>
</syntaxhighlight>


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


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo cat *.ntfs-img.* | gzip -d -c | ntfsclone --restore-image -o ntfs.img -
mkdir /media/ubuntutje
mount -o loop -t ext4 sda5.img /media/sda5img
umount /media/sda5img
</syntaxhighlight>
</syntaxhighlight>


Mount with:
==Resize==
 
Check for (mount) errors:
 
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo mkdir /media/ntfs-img
dmesg | tail
sudo mount -o loop -t ntfs ntfs.img /media/ntfs-img
</syntaxhighlight>
</syntaxhighlight>


== Linux ext4 partition ==
Fix errors (if any)


You will need partclone, download the deb package from:
<syntaxhighlight lang=bash>
* https://launchpad.net/ubuntu/precise/amd64/partclone/0.2.22-2 (amd64)
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


Install with:
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
sudo dpkg -i partclone_0.2.22-2_amd64.deb
resize2fs -M sda5.img
</syntaxhighlight>
</syntaxhighlight>


Lets say compression is gzip (as it probably is), then we need to extract the image using gzip:
==Restore==
 
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>

Latest revision as of 08:30, 15 September 2013


CloneZilla is not always able to restore an image, in that case you could try do do this manually. On the other hand you just might want to look inside the image without having to restore it to a physical partition.

Windows NTFS partition

Note: I didn't test this yet (201309).

Guide:

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

Install ntfsclone:

sudo apt-get install ntfsprogs

Locate the CloneZilla 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

Extract partition image (sdb1) from CloneZilla, we assume gzip has been used.

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.

Options:

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

Define device md0 and mount it:

mdconfig -a -t vnode -f sdb1.img md0
mkdir /media/mnt
mount -t ntfs /dev/md0 /mnt

Resize

Check for errors:

dmesg | tail

Check for the minimum size:

ntfsresize -m /dev/md0

Apply the resize (in this example 36Mb)

After the resize, the imagefile stays at its original size, it's not automatically truncated. We use ntfsclone to extract the relevant data in the next step.

Note that this can take considerable time:

ntfsresize --size 36M /dev/md0

Clone to get the minimum size. The --force is necessary because the resize action flags the volume for a chkdsk check.

ntfsclone --force -o sdb1_shrunk.img /dev/md0
mdconfig -d -u /dev/md0

Restore

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

THIS WILL OVERWRITE THE TARGET PARTITION!! 
ALL DATA ON THAT PARTITION WILL BE LOST!!

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

partclone.restore -d -s sdb1_shrunk.img -o /dev/sda1

Resize to fit partition:

ntfsresize -x /dev/sda1

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.

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.

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

Resize

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

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