LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-03-2010, 10:05 PM   #1
RichTJ99
LQ Newbie
 
Registered: Jul 2010
Posts: 5

Rep: Reputation: 0
Using DD command with Bzip2? CLI question


Hi,

I am looking to use DD to compress an entire disk (sda) to an image file on sdb.

A friend told me to mount sdb / partition 1, then as root, type the following command:

Code:
dd if=/dev/sda | bzip2 -9 >/media/sdb1/disk_image.img.bz2
This did not work. I just get an error message:

Code:
Invalid command line: Not enough files given. Aborting...

I was also told to restore (assuming sda has the image & sdb is the destination), I could do the following:

Code:
Code:
bzip2 -cd /media/sda1/disk_image.img.bz2 | dd of=/dev/sdb
Of course, since the first part didnt work, I couldnt test the second.

Any ideas how to use DD to byte for byte image the entire drive & compress it (its mostly empty space).

Thanks,
Rich
 
Old 07-04-2010, 12:24 AM   #2
ongte
Member
 
Registered: Jun 2009
Location: Penang, Malaysia
Distribution: Mageia, CentOS, Ubuntu
Posts: 468

Rep: Reputation: 72
Is there a particular reason why you wanna use dd? Why not use a disk cloning tool like Clonezilla or G4L?

dd even with bzip2 will be stupidly slow since dd reads everything regardless if it's empty or not. You also have to remember that the device you are backing up cannot be mounted while you are doing this backup. It's a much better idea to use tools designed for this purpose.
 
Old 07-04-2010, 07:36 AM   #3
RichTJ99
LQ Newbie
 
Registered: Jul 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Hi,

I need to use DD because I want all the information on the drive (including blank space). I dont mind if DD is slow, I just want to make sure it grabs all the data. Clonezilla doesnt recognize the partition (its a Tivo one).

Thanks,
Rich
 
Old 07-04-2010, 08:25 AM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
mount sdb / partition 1
I don't know what this means---what did you actually mount--and to what mountpoint?

There's nothing wrong with using DD for something like this but I'm uncertain about piping it thru bzip2. I do think it's best not to have the disks (partitions) mounted---although I'm not sure you can have bzip2 redirect to a file unless the destination partition is mounted.

What is the end goal? e.g. why not just use gz or bz2 + tar to create a backup.
 
Old 07-04-2010, 08:37 AM   #5
johnshen64
LQ Newbie
 
Registered: Jun 2010
Posts: 29

Rep: Reputation: 5
use df to make sure /media/sdb1 is mounted and has enough disk space. your friend probably means mount /dev/sdb1 /media/sdb1.

otherwise the command is correct.
 
Old 07-04-2010, 09:21 AM   #6
RichTJ99
LQ Newbie
 
Registered: Jul 2010
Posts: 5

Original Poster
Rep: Reputation: 0
I am backing up a 2TB blank tivo drive. I need it to be byte for byte however a similar 320GB blank Tivo drive I backed up came out to 1.5GB in space. I am assuming this blank 2TB tivo drive will also get compressed to a similar size.

I would be open to another type of compression option as long as it does the same byte for byte backup.

My goal is that when my unreliable 2TB drive dies, I have a restore method that is 100% without having to dedicate an entire 2TB drive to sit as a backup.

If you have another suggested command to try, I would be happy to try it out.

I started to use partedmagic.com's live CD since it has all the needed utilites on it. I just clicked on the Mount devices to mount sdb1.

Thanks,
Rich
 
Old 07-05-2010, 06:16 AM   #7
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 4,023

Rep: Reputation: Disabled
You wrote "dd if=/dev/sda | bzip2 -9 >/media/sdb1/disk_image.img.bz2". That would mean the whole disk /dev/sda else it must read dd if=/dev/sda[n] | bzip2 -9 >/media/sdb1/disk_image.img.bz2" where [n] is the partition number.

To learn about dd: http://www.linuxquestions.org/questi...ommand-362506/
This is the one and only true dd thread on LQ .
 
Old 07-05-2010, 08:45 AM   #8
RichTJ99
LQ Newbie
 
Registered: Jul 2010
Posts: 5

Original Poster
Rep: Reputation: 0
All i am looking to do is use DD to make a full byte by byte backup of sda into a zip file on Sdb1. I just cant seem to find the right command.
 
Old 07-05-2010, 08:47 AM   #9
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 42.1_64+Tumbleweed-KDE, Mint 17.3
Posts: 4,023

Rep: Reputation: Disabled
Post your question in the above mentioned thread. The OP will help you out.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
chapter 6, want to use bzip2 but it fails with bash: bzip2: No such file or directory nomad5000 Linux From Scratch 2 10-12-2009 08:58 PM
CLI command line recall hearnold Programming 0 09-07-2006 03:24 PM
bzip2 question sanmadjack Linux - Software 2 06-29-2006 10:01 PM
cli: command & domtar Linux - General 1 02-27-2005 07:43 AM
Command and Conquer - CLI Nimoy Programming 6 11-05-2003 03:50 PM


All times are GMT -5. The time now is 12:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration