2011-01-08, Sat

Write or pipe a disk image directly from tar.gz using tar and dd

The other night I was wanting to dd a fresh copy of the ChromeOS image onto an SD card on my eeePC 701.

Problem was, There was only ~700mb of free space on the eeePC’s puny 4GB SSD drive, so there was no way I could fully extract the 1.6gb image before writing it out.

So here’s how you can dd a image file directly from within a tar.gz archive.

      tar xzOf ChromeOS-Flow.tar.gz | dd of=/dev/sdb bs=1M

Allow me to take you through the parameters for tar one at a time.

  • x extract
  • z pass it through the gzip filter (i.e. decompress it)
  • O send the output through to stdout
  • f parameter for the file we’re working with (as opposed to a stream)

The magic is in the O character which allows you to “|” pipe the output from tar directly to dd which then writes the stream straight to the block device (in this case /dev/sdb).

Isaac Su

tags: bash dd gzip linux stdout tar unix



  1. Thank you, Mr. Su. I was in a very similar situation, and this worked remarkably for my purposes.

    — Alex · Apr 5, 06:52 PM · #

  2. Thank you for this. This is great if you’re using a live CD (ubuntu or something) and don’t have a bunch of space to play around with. :)

    Josh · Sep 19, 04:42 AM · #

  3. just in time, very helpful, thanks a lot.

    — saed · Feb 29, 12:01 AM · #

  4. Thank you. This helps me a lot when I want to flash the image remotely.

    I did a little bit change to improve the time to do it.
    cat ChromeOS-Flow.tar.gz | tar zxO | ssh [email protected][IP ADDR] ‘gzip -d | dd bs=4M iflag=fullblock oflag=dsync of=/dev/sda’

    — Weinan · Sep 11, 07:28 AM · #

Commenting is closed for this article.