Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: tar from stdin: piping to tar.

  1. #1
    Join Date
    Apr 2008
    Beans
    86

    tar from stdin: piping to tar.

    I want to do something like this
    Code:
    # dd if=/dev/sdX | tar -cvz /location/of/harddiskimage.tar.gz
    I am currently using the following
    Code:
    # dd if=/dev/sdX | gzip > /location/of/harddiskimage.img.gz
    However I would like to be able to add other things into the archive, not just compress the image.
    Any help is appreciated

  2. #2
    Join Date
    Jun 2007
    Location
    Greater Boston
    Beans
    1,586
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: tar from stdin: piping to tar.

    What about:

    dd if=/dev/sdX | tar -cvzf /location/of/harddiskimage.tar.gz

    z is supposed to compress on create and decompress on extract.
    cmn

  3. #3
    Join Date
    Apr 2008
    Beans
    86

    Re: tar from stdin: piping to tar.

    Quote Originally Posted by cmnorton View Post
    What about:

    dd if=/dev/sdX | tar -cvzf /location/of/harddiskimage.tar.gz

    z is supposed to compress on create and decompress on extract.
    Code:
    # dd if=/dev/zero | tar -cvzf /home/user/Desktop/imag.tgz
    tar: Cowardly refusing to create an empty archive
    Try `tar --help' or `tar --usage' for more information.

  4. #4
    Join Date
    Feb 2006
    Beans
    1,086
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: tar from stdin: piping to tar.

    Why not first do
    Code:
    dd if=/dev/sdX > filename
    Then
    Code:
    tar czvf harddiskimage.tar.gz filename
    ??

  5. #5
    Join Date
    Dec 2006
    Beans
    1,807
    Distro
    Ubuntu 7.10 Gutsy Gibbon

  6. #6
    Join Date
    Apr 2008
    Beans
    86

    Re: tar from stdin: piping to tar.

    Quote Originally Posted by glennric View Post
    Why not first do
    Code:
    dd if=/dev/sdX > filename
    Then
    Code:
    tar czvf harddiskimage.tar.gz filename
    ??
    Isn't that two operations? dd is very slow as is and if you add to that time the time needed to tar it, that makes for two long operations when I'd rather it just be 1 long operation.

  7. #7
    Join Date
    Feb 2006
    Beans
    1,086
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: tar from stdin: piping to tar.

    I don't think that tar accepts data from standard input the way you are trying to do. It needs a list of files to work on, not data like that output by dd. So you may be stuck with two commands.

  8. #8
    Join Date
    Feb 2006
    Beans
    1,086
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: tar from stdin: piping to tar.

    Why are you trying to do this?

  9. #9
    Join Date
    Jun 2007
    Location
    Greater Boston
    Beans
    1,586
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: tar from stdin: piping to tar.

    Quote Originally Posted by JohnGalt131 View Post
    Code:
    # dd if=/dev/zero | tar -cvzf /home/user/Desktop/imag.tgz
    tar: Cowardly refusing to create an empty archive
    Try `tar --help' or `tar --usage' for more information.
    Mea culpa. Sorry about the mis-information.

    You can certainly dd from the device and pipe it into gzip. I just tried it.

    sudo dd if=/dev/sdb1 | gzip -9 > temp.gz

    This works, where /dev/sdb1 is my unmounted external USB drive.

    Else, I believe you would have to dd out to a file, and then run that through tar.

    Edit:
    -----------

    Are you trying to image a disk?
    Last edited by cmnorton; December 11th, 2008 at 05:41 PM. Reason: Ask question
    cmn

  10. #10
    Join Date
    Apr 2008
    Beans
    86

    Re: tar from stdin: piping to tar.

    Quote Originally Posted by cmnorton View Post
    Mea culpa. Sorry about the mis-information.

    You can certainly dd from the device and pipe it into gzip. I just tried it.

    sudo dd if=/dev/sdb1 | gzip -9 > temp.gz

    This works, where /dev/sdb1 is my unmounted external USB drive.

    Else, I believe you would have to dd out to a file, and then run that through tar.

    Edit:
    -----------

    Are you trying to image a disk?
    Yes I periodically create compressed images. But I would like to be able to append files to the archive (usually text files) such as a list of instructions for a restore, the contents of the image, etc. gzip only compresses, it does not (I don't think) archive.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •