LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-11-2010, 12:25 PM   #1
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Rep: Reputation: 31
Compress after copy with dd?


I copy my partition with this command

Code:
 dd if=/dev/sdb2 of=/home/sam/partition.image bs=4096 conv=notrunc,noerror
But I would like to compress at the same time.
So, the output file to be some rar or zip ot tar.gz file.
Is that possible?
 
Old 02-11-2010, 12:27 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Instead of specifying an outfile pipe it to bzip2 and redirect it.

eg:
Code:
dd if=/dev/sdb2 bs=4096 conv=notrunc,noerror | bzip2 > /home/sam/partition.image.bz2
 
Old 02-11-2010, 01:08 PM   #3
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
I tried it bit it doesnot work.

I recive this

Code:
0+0 records out
0 bytes (0 B) copied, 29,6211 s, 0,0 kB/s
dd: leyendo «/home/miros/facturación»: Es un directorio
0+0 records in
0+0 records out
0 bytes (0 B) copied, 29,6212 s, 0,0 kB/s
dd: leyendo «/home/miros/facturación»: Es un directorio
0+0 records in
0+0 records out
0 bytes (0 B) copied, 29,6212 s, 0,0 kB/s
dd: leyendo «/home/miros/facturación»: Es un directorio
^C records out
0 bytes (0 B) copied, 29,6333 s, 0,0 kB/s
0+0 records in
0+0 records out
0 bytes (0 B) copied, 29,6483 s, 0,0 kB/s
Other ideas?
 
Old 02-11-2010, 01:48 PM   #4
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by miros84 View Post
Other ideas?
Try
Code:
sudo dd if=/dev/sdb2 bs=4096 conv=notrunc,noerror | bzip2 > /home/sam/partition.image.bz2
If that does not work, what is the output of "fdisk -l"?
 
Old 02-11-2010, 02:36 PM   #5
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
I think I confused you.

I wanted to do that:

Code:
dd if=/home/miros/facturación/ of=/home/miros/opiti/partition.image bs=4096 conv=notrunc,noerror
I didnot want to copy a partition, I want to copy a directory.
I do it as root.

Trying to copy a partition, it works, but trying to copy a directory is when it doesnot work.
 
Old 02-11-2010, 02:46 PM   #6
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Why would you dd a directory instead of using a tool more suited to that operation? dd really shouldn't be used as a multipurpose copying tool even though it can be shoe horned into that role.

Code:
tar cfvj /home/miros/opiti/backup.tbz2 /home/miros/facturación/*

Last edited by rweaver; 02-11-2010 at 02:47 PM.
 
Old 02-11-2010, 03:09 PM   #7
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by miros84 View Post
I think I confused you.
I think you confused yourself. Here is the first line of your original post:
Quote:
Originally Posted by miros84 View Post
I copy my partition with this command
 
Old 02-13-2010, 01:04 PM   #8
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
Yeah, you are right.
I confused myself and you.
So, it is impossible to copy folder with dd?
 
Old 02-13-2010, 01:22 PM   #9
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
If all you are looking to do is copy a folders contents and compress it then why don't you use the cp or tar commands or both.
Code:
cp /path/to/folder/ /path/to/new/folder/newname
You end with a slash and it'll get just the contents and not the folder. Then you can update the new folder as the old folder changes with something like
Code:
cp -nR /path/to/folder/ /path/to/new/folder
Put quotes around the entire path if the file or folder contains non standard characters like spaces or ?
Code:
cp -nR "/path/to/folder/" /path/to/new/folder
dd is a bitstream duplicator. It will duplicate anything you point it to.
It copies 1 and 0 in the exact order and place where they were. That's why it is good for an exact .iso of something.

Last edited by teckk; 02-13-2010 at 01:23 PM.
 
1 members found this post helpful.
Old 02-13-2010, 04:08 PM   #10
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,976

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
See also cat and tar.
 
Old 02-15-2010, 12:56 PM   #11
miros84
Member
 
Registered: Aug 2009
Location: Spain
Distribution: Debian stable, squeeze
Posts: 501

Original Poster
Rep: Reputation: 31
Quote:
sudo dd if=/dev/sdb2 bs=4096 conv=notrunc,noerror | bzip2 > /home/sam/partition.image.bz2
I use this command to copy and compress some partition.
And which will be the command to restore the partition after that?

Something like that?
Code:
sudo dd if=/home/sam/partition.image.bz2 | I miss this part
 
  


Reply



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
compress rehan999 Linux - Software 1 06-16-2009 07:51 AM
Copy/Compress DVD to DVD fleshwound Linux - Software 2 11-23-2005 06:10 PM
Compress Gins Linux - General 5 11-19-2004 01:05 PM
compress fs alaios Linux - General 5 09-07-2004 08:29 PM
compress Ownasaurus Linux - Software 4 09-12-2003 07:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:21 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
Open Source Consulting | Domain Registration