WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Creating a partition image with dd / ddrescue  (Read 8370 times)

Offline Fakir

  • Newbie
  • *
  • Posts: 12
Creating a partition image with dd / ddrescue
« on: January 22, 2017, 05:32:32 AM »
Hey folks!

I'd like to create a partiton image of my win partition via TC 7.2 in order to mount in a VM. Although it's written on many websites that this should work with dd / ddrescue, I cannot finish the execution:

1. First problem seems to be that the partitions are not handled by TC in the /dev folder but in the /mnt folder whereas dd / ddrescue expect a /dev folder

2. dd doesn't know the "conv=sparse" operator (and without this, the img file would be as big as the whole partition to clone)

3. By using ddrescue (syntax: ddrescue -S /dev/sda1 /dev/scc1/partition.img) the program tells me that this is not a directory. Indeed, this is a file but as mentioned: there are lots of pages telling that this operation can be done.

Can you see what seems to be the trouble?

Two additional questions:

a) Would partimage be the better alternative? - It's not listed in the repo, though.
b) Is Virtualbox able to read gz-data? If yes, I could do the operation without sparse operator by just simply compressing the img file..

Julian

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Creating a partition image with dd / ddrescue
« Reply #1 on: January 22, 2017, 11:24:05 AM »
Every mounted partition you see in  /mnt  has its counter part in  /dev .
I.e.  /mnt/sda1  and  /dev/sda1 .
If you want to  dd  the contents of a device into a file on a filesystem, you'd do something like
Code: [Select]
dd if=/dev/sda1 of=/mnt/sdc1/partition.img
Download a copy and keep it handy: Core book ;)

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 705
Re: Creating a partition image with dd / ddrescue
« Reply #2 on: January 22, 2017, 12:08:40 PM »
The dd within busybox is very light.

You could just add coreutils if you need the dd version with more options.

You could easy check what dd you running like this:

Before install of coreutils.
Code: (bash) [Select]
tc@box:~$ la $(which dd)
lrwxrwxrwx    1 root     root             7 Jan  1  1970 /bin/dd -> busybox

After install coreutils.
Code: (bash) [Select]
tc@box:~$ la $(which dd)
lrwxrwxrwx    1 root     root            38 Jan 22 17:03 /usr/local/bin/dd -> /tmp/tcloop/coreutils/usr/local/bin/dd


« Last Edit: January 22, 2017, 12:15:02 PM by patrikg »

Offline Fakir

  • Newbie
  • *
  • Posts: 12
Re: Creating a partition image with dd / ddrescue
« Reply #3 on: January 22, 2017, 12:26:20 PM »
Ok, hint 1 (misalf) already helped (at least a little bit ;) ): the program started but canceled execution after 4.3 GB.

Perhaps this is due to the fact that it's a Fat partition to where I write the img file..? - At least this would explain why partimage did the same and aborted after that amount of size, too.

I'll try it with dd (coreutils) but I have to be sure that the file does not contain zero bits (sparse file). For testing partimage I took my usb stick and the result exactly had the size of the files written on it. When I tested the same with ddrescue, the file size corresponded to the whole size of the stick. Luckily it was an old stick with only 512 MB.. ;)

How can I be sure that the img file will only contain 'real' data and no zero bits? And: how can I 'unblock' that 4.3 GB limit?

Offline Fakir

  • Newbie
  • *
  • Posts: 12
Re: Creating a partition image with dd / ddrescue
« Reply #4 on: January 22, 2017, 12:38:58 PM »
I just tested the procedure by using dd (coreutils). Although using the conv=sparse operator the resulting img file was at the same size as the whole partition (approx. only half of the partition is used by data).

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11556
Re: Creating a partition image with dd / ddrescue
« Reply #5 on: January 22, 2017, 12:47:29 PM »
Hi Fakir
Enter:
Code: [Select]
dd --helpThis will tell you whether  sparse  is a supported option.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 705
Re: Creating a partition image with dd / ddrescue
« Reply #6 on: January 22, 2017, 01:26:05 PM »
When using dd... it's not mounting the disc with correct filesystem and take file by file.
Just take the hole thing.
Why not just compact the image...
And remember always to use conv=notrunc,noerror to records the image correctly.

Offline Fakir

  • Newbie
  • *
  • Posts: 12
Re: Creating a partition image with dd / ddrescue
« Reply #7 on: January 22, 2017, 02:20:32 PM »
@ Rich
With dd (coreutils) the sparse operator works.

@ Patrikg
The background of that procedure is to have an image that can be used in virtualbox. I'm not sure if virtualbox is able to handle a gz file..?

How do you mean this: dd isn't mounting the correct filesystem? The problem isn't limited to dd, the othr programs I tried ended up in the same.

As far as I could see in the meanwhile, it's actually due to the file size restriction in fat 32 that I cannot get the whole partition content into one big file. So obviously I now have the two possibilities:
1. I tell dd / ddrescue / partimage to split the image into several smaller files (but then I would get the problem how to merge them on that fat 32 hdd into a fil that is bigger than 4.3 GB, so this isn't a real possibility ;) )
2. I get it handled that virtualbox can process a compressed gz img file.

I wonder how others have accomplished the same issue: creating a partition image and loading into a VM - I can't imagine that this issue is a rare case. Perhaps it's just because they're not using a fat 32 formatted hdd.. ;)

Offline Misalf

  • Hero Member
  • *****
  • Posts: 1702
Re: Creating a partition image with dd / ddrescue
« Reply #8 on: January 22, 2017, 11:53:33 PM »
It's true that the old FAT filesystem does not support files greater than 4 GB.
In order to store a files bigger than 4GB, you need to use anther filesystem. NTFS or EXT2/3/4 will do.
Download a copy and keep it handy: Core book ;)

Offline Fakir

  • Newbie
  • *
  • Posts: 12
Re: Creating a partition image with dd / ddrescue
« Reply #9 on: January 23, 2017, 01:09:11 PM »
Ok, I'll try to get the partition's size smaller than 4.3 GB…
 
But: how would you explain the fact that dd and ddrescue created a sparse img file that had the size of the whole original partition instead of only the files contained on it.

In case I accomplish to shrink the partition down: How can I reliably avoid that dd / ddrescue want to create a file having the size of the whole partition?

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 705
Re: Creating a partition image with dd / ddrescue
« Reply #10 on: January 23, 2017, 03:34:43 PM »
You should read my favorite site explaining some of the features of dd...

Dd - Destroyer of Disks
http://www.noah.org/wiki/Dd_-_Destroyer_of_Disks

Offline Fakir

  • Newbie
  • *
  • Posts: 12
Re: Creating a partition image with dd / ddrescue
« Reply #11 on: January 24, 2017, 03:57:25 PM »
Ok, I've got a plan (once more ;) ): I'll format an usb stick with exfat using partimage. This seems to me the best way to get my wished result.

Concerning this, I have some more questions (I know: both would be better asked in separate threads):

- In case I use TC: will the fuse.tcz extension allow me to have access to exfat? Background of the question: the partimage.tcz isn't included in the repo for TC 7.x so I have to take my older version (4.x I guess) where part image can be found in the repo but only that one fuse.tcz file (its description doesn't say anything about its abilities).

- General question: is exfat only meant to be a flash fs or can it also be used as a hdd fs (for external drives, e.g.)?