0

I am trying to image a disk for one of our network appliances and am running into an issue with saving the output file.

This is the command:

ssh [email protected] shell "dd if=/dev/md0 |gzip -1 -" dd of=md0_monSecondary.gz"

The screen outputs a bunch of garbled text and at the end says the following:

Lgzip: can't stat: dd: No such file or directory
gzip: can't stat: of=md0_blah.gz: No such file or directory

The other command we were given is this:

ssh [email protected] shell "dd if=/dev/md0 bs=10M | tail -c +7 | head -c -6 > md0.img"

If I run that I get a Error:

No such command

If I run it without quotes

ssh [email protected] shell dd if=/dev/md0 bs=10M | tail -c +7 | head -c -6 > md0.img

I get a message that says:

'tail' is not recognized as an internal or external command, operable program or batch file. 

What am I doing wrong with these commands?

1
  • If I run the ssh [email protected] shell dd if=/dev/md0 bs=10M | tail -c +7 | head -c -6 > md0.img from another networking appliance, I get the following: stdout:: command not found Commented Oct 19, 2023 at 17:05

1 Answer 1

1

If you use dd with a compressed stream but without iblock=fullblock you are likely to end up with a corrupted image. It's much easier just to use cat (or in this case, gzip) and dispense with the complexities of dd entirely:

ssh -n [email protected] shell 'gzip </dev/md0' >md0_monSecondary.gz

If the server on 192.0.0.0 really cannot handle gzip directly from a device, for example if it's based on BSD rather than Linux, then use this. But only use this variant as a last resort:

ssh -n [email protected] shell 'dd bs=128M if=/dev/md0 | gzip' >md0_monSecondary.gz

The shell component of the command line is very unusual. I assume it's something related to the type of server you're using. For a normal server you wouldn't need it at all.

Bear in mind that if /dev/md0 is still mounted as a filesystem on the remote server while you're copying it the resulting image is highly likely to be corrupted. If you're lucky you'll notice straightaway. If you're not, then the potential corruption will sit there until you need the image restored.

4
  • TY! The device's OS is based on freebsd. That is why the need for the shell. I got this working on a coworker's linux box. ssh [email protected] shell dd if=/dev/md0 bs=10M | tail -c +7 | head -c -6 > 192.0.0.0_md0.img Does this prevent corruption? Are disks like this prone to corruption? /dev/raid/r0s1a /dev/raid/r0s1e Commented Oct 20, 2023 at 0:56
  • If I run this from my windows VM:ssh [email protected] shell dd if=/dev/md0 bs=10M | tail -c +7 | head -c -6 > 192.0.0.0_md0.img, I get a "'tail' is not recognized as an internal or external command, operable program or batch file." error. Is that just not supported? How do we specify the path to the img file in Windows? ssh [email protected] shell dd if=/dev/md0 bs=10M | tail -c +7 | head -c -6 > C:\temp\192.0.0.0_md0.img Commented Oct 20, 2023 at 1:02
  • 1
    Why are you running tail at all? Commented Oct 20, 2023 at 6:01
  • @JohnBalan note that without any quoting, anything after | is executed on the client host. (I suppose it really depends on your client shell but practically it's probably the case anyway.) Commented Oct 20, 2023 at 9:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.