# dd corrupt /dev/hda to external USB drive: file size error?

## sog

as covered in another thread (https://forums.gentoo.org/viewtopic-t-470291-highlight-.html), i've somehow corrupted my main partition (reiserfs) and am currently unable to access the information. 

one recommendation has been to dd the entire drive to another storage source straight up or as a .iso file. unfortunately, i'm unable to do so as i receive a "file size limit exceeded error" - but when i do a ulimit -a from within the target partition, i get a "file size: unlimited."

anybody have any ideas whatsoever? i'd hate to lose everything that's on this drive. i don't mind replacing it, but i'd like to get at least some of the materials on it transferred.

----------

## I.C.Wiener

I just assume you are trying something like this 

"ddrescue if=/dev/hda > /mnt/usb/broken_disk.img"

Where /mnt/usb is formated with fat32 (to let those windows-n00bs have access to it).

Fat32 doesn't support files larger than 4GB so this will fail if /dev/hda is larger than that.

Possible solutions:

1. You could try to pipe through bzip which will compress the data on the fly (perhaps it can even splitt files?)

2. copy a single partition only instead of the full disk (might fit into a 4GB file?)

3. use a decent fs like ext3 for the usb-drive

----------

## sog

ah, i thought it might be something like that, in spite of what the ulimit returned. will have to find a way around this. 

will the dd command work with network drives, because that'll be easier than finding another external drive with a real FS  :Wink: 

----------

## troymc

 *sog wrote:*   

> 
> 
> will the dd command work with network drives, because that'll be easier than finding another external drive with a real FS 

 

Yes it will. You can use a NFS or SAMBA share, or if you don't have anything like that, simply pipe your dd thru ssh like this:

```

# dd if=/dev/hda4 | ssh $fileserver "cd /big/filesystem; dd of=hda4.bin"

```

troymc

----------

## sog

crap. i thought i was golden with troymc's instructions, but no joy.

his help was just what i needed (thanks troymc) - i was able to easily pipe the dd output to the other machine via ssh - but during the dd i got bad block reads. 

might have to go w/ Nucleus' Kernel for Reiser now. 

does anyone happen to know if ddrescue is on the full install disk? 

i'm currently booting off a minimal install, which doesn't have ddrescue on it and i can't chroot and therefore can't emerge.

if the full install disk has ddrescue on it i guess i'll try that, as it supposedly tries to read over/around bad blocks, but if not i'll have to go the commercial route.

----------

## I.C.Wiener

knoppix should have ddrescue installed. I think at least an rather old version (3.x) had.

I tried dd with an nfs share a few month ago:

dd if=/dev/hda of=/mnt/nfs-share/hda.img  <= this did not work!

dd if=/dev/hda > /mnt/nfs-share/hda.img <= this works fine

----------

## sog

first download of knoppix just hung, not 40 MB's from completion. trying again.

----------

## sog

ok, got the knoppix CD down via bittorrent, but it seems as if dd_rescue is considerably less tolerant of piping things through ssh than plain old dd is. 

it keeps telling me that i need to specify input and output files, although it does appear to complete the ssh connection because i'm prompted for a password. 

so now i'm attempting to mount the drive in question as a samba share, but that too is giving me problems.  i do a:

```
sudo mount -t smbfs //192.168.2.4/home/sog/sogjr_recovery /mnt/apone -o username=sog,uid=hs_int1023,gid=samba
```

(have also tried it with ...192.168.2.4//home... - same error)

in Knoppix and it gives me a:

```
4359: tree connect failed: ERRDOS - ERRnosuchshare (You specified an invalid share name)

SMB connection failed

```

i guess i could have screwed up the share in samba, but it doesn't seem that complicated. in /etc/samba/smb.conf, i have the following:

```
[sogjr_recovery share]

       comment  = backup share

       browseable = yes

       guest ok = yes

       writable = yes

       path = /home/sog/sogjr_recovery
```

can anybody see anything obvious i'm doing wrong?

p.s. i should also mention that i've done the smbpasswd -a bit, and have both restarted the samba services and box itself - to no avail.

----------

## zhs

I think your problem is in the command that youre using.  After the IP address you need to put the name of the share instead of the path.  sudo mount -t smbfs //192.168.2.4/sogjr_recovery_share /mnt/apone -o username=sog,uid=hs_int1023,gid=samba  

The other thing that i noticed is that you dont have an underscore between "recovery and "share"  I'm not sure if it will accept that as a valid share name....

Oh and also, i dont think samba will let you share home directories either.

----------

## sog

that was it, zbs - thx so much for the tip. 

by correcting the name of the share, i was successfully able to mount the remote samba dir via the command:

```
sudo mount -t smbfs //192.168.2.4/sogjr_recovery /mnt/apone -o username=sog,uid=hs_int1023,gid=samba 
```

that's the good news. the bad news is that i still can't dd_rescue the thing. i *think* what's happening is that we have some sort of permissions problem. 

first, i try:

```
dd_rescue if=/dev/hda4 of=/mnt/apone/hda4.iso

dd_rescue: (fatal): open "if=/dev/hda4" failed: No such file or directory

```

and get the error as above. that's weird, i'm thinking, it seems like i can't read the actual partition. so i try :

```
fdisk -l /dev/hda

Cannot open /dev/hda

```

uh-oh, i'm thinking. if, however, i sudo before that, it works fine. 

```

sudo fdisk -l /dev/hda

Disk /dev/hda: 40.0 GB, 40007761920 bytes

240 heads, 63 sectors/track, 5168 cylinders

Units = cylinders of 15120 * 512 = 7741440 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/hda1   *           1        1258     9510448+   7  HPFS/NTFS

/dev/hda2            1259        1263       37800   83  Linux

/dev/hda3            1264        1330      506520   82  Linux swap / Solaris

/dev/hda4            1331        5168    29015280   83  Linux
```

so now i'm thinking no problem, i'll just sudo dd_rescue and be good to go. same error as the first time. then i remember that I.C. Wiener had problems with that format, so i try:

```
dd_rescue if=/dev/hda4 > /mnt/apone/hda4.iso

bash: /mnt/apone/hda4.iso: Permission denied
```

this time, it seems to be able to find the input file fine, and is gagging on the output.  it can't write, in other words, to the share.  how about if i sudo? same deal.

```
sudo dd_rescue if=/dev/hda4 > /mnt/apone/hda4.iso

bash: /mnt/apone/hda4.iso: Permission denied
```

i thought maybe it was a problem of usernames on the actual share itself - so i've added both the 'root' and 'knoppix' usernames to the samba database on the target machine and restarted samba, but that hasn't worked. 

any ideas? i feel like i've made progress - now i just need to close the deal.

----------

## phorn

Hi,

First of all, about the first error (which you would still get in the second case as well):

The dd_rescue syntax is different:

From dd_rescue -h:

 *Quote:*   

> USAGE: dd_rescue [options] infile outfile

 

To use dd_rescue in your case, run:

```
dd_rescue /dev/hda4 /mnt/apone/hda4.iso
```

i.e. without "if=" or "of="

You will also notice that the dd_rescue error gives you a subtle indicator that the command line format is different:

 *Quote:*   

> dd_rescue: (fatal): open "if=/dev/hda4" failed: No such file or directory

 

You see that it is trying to open a file called "if=/dev/hda4", and dies out since there is no directory called "if=".

Now, with regard to the Permission denied problem, this error has to do with the way bash parses the command line.

Bash sees the command "sudo dd_rescue /dev/hda4", and then bash later recognizes the ">" symbol as a pipe character, so interprets the ">" itself.

While dd_rescue is run as root, bash, which creates the pipe output, is running as a non-root user, which does not have permissions to that directory. (You may notice that the error is "bash: /mnt/apone/hda4.iso: Permission denied").

Since bash encounters an error, it does not attempt to run the command, or else you would get the syntax error with dd_rescue.

To resolve this, you have two options.

One is to use a nested bash shell, like:

```
sudo bash -c 'dd_rescue if=/dev/hda4 > /mnt/apone/hda4.iso'
```

This will create another bash shell, this time running as root, which will pipe to the output file.

This is annoying to write, so a better way is to use dd and dd_rescue's internal output file argument (see above).

----------

## sog

you rock phorn. i'm an idiot for assuming the dd_rescue syntax was the same, but i appreciate you not saying so  :Wink: 

anyhow, this command failed:

```
dd_rescue /dev/hda4 /mnt/apone/hda4.iso
```

with a but with a simple sudo:

```
sudo dd_rescue /dev/hda4 /mnt/apone/hda4.iso
```

the transfer began just fine. that's the good news. 

the bad news is that it errored out after 2GB's transferred with a "File size limit exceeded." i've hit that before on a FAT32 filesystem, but the /mnt/apone filesystem is an Ubuntu box - ext3 filesystem. the same filesystem, moreover, that handled an over 20GB file with dd before that errored out due to the bad block problem. 

does anyone know if there's some sort of cap on the size file or partition that dd_rescue can recover? because i don't see any problem with the filesystems.

----------

## sog

if it helps at all, it's erroring out consistently (2 times so far) at the same point:

```
xferd:   2096128.0k
```

also, no errors had been hit so far - they typically come after 20 GBs, at least when i've used dd. 

```
errs:     0
```

----------

