LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxAnswers Discussion (http://www.linuxquestions.org/questions/linuxanswers-discussion-27/)
-   -   DISCUSSION: How To Do Eveything With DD (http://www.linuxquestions.org/questions/linuxanswers-discussion-27/discussion-how-to-do-eveything-with-dd-376211/)

AwesomeMachine 10-23-2005 09:44 PM

DISCUSSION: How To Do Eveything With DD
 
This thread is to discuss the article titled: How To Do Eveything With DD

sk545 10-28-2005 12:04 PM

wow, excellent.

Rich309 03-12-2006 06:29 PM

Do you mean to say BS= can not be less than 512? I have run it at 2 and it seem to work. Am I being decieved?

w_r_cromwell 03-24-2006 10:55 AM

This is very helpful... thanks for your effort

Bill

anilbh 12-13-2006 06:56 AM

Amazing
 
Wow is right ! But I had a tough time locating this article again .

harryhaller 06-01-2007 11:19 AM

when dd copies a partition, does it also copy the super-block?

In other words, if I copied my windows partition and then restored it, could I then boot from it, assuming, of course, that my boot manager was set up correctly?

Also, could I gezip the file of the partition to make it smaller, or does that cause problems when restoring?

kav 06-01-2007 11:51 AM

Quote:

Also, could I gezip the file of the partition to make it smaller, or does that cause problems when restoring?
I know there's got to be a way to do that manually, maybe even piped into one line. Clonezilla has that kind of functionality except with an easy to follow menu to get it all done. Wonderfull tool.

Heck, it might be as easy as $ dd if=/somefile | tar -czvf /compresed_image

fakie_flip 10-05-2007 12:50 PM

Quote:

Copy a disk partition to a file on a different partition. Do not copy a partition to the same partition.

dd if=/dev/sdb2 of=/home/sam/partition.image bs=4096 conv=notrunc,noerror

This will make a file that is an exact duplicate of the sdb2 partition. You can substitue hdb, sda, hda, or whatever the disk is called.

Restore a disk partition from an image file.

dd if=/home/sam/partition.image of=/dev/sdb2 bs=4096 conv=notrunc,noerror
Could someone please explain why bs=4096 and conv=notrunc,noerror is used?

DrCR 12-21-2007 01:49 PM

bs=446 count=1 is way to backup the MBR, but not the partition table, so yes, it can be less than 512.
bs=4096 - When copying large amounts, say, backing up a partition, bs=4096 tends to be the best choice for faster, more modern machines so I hear.

You can indeed compress on the fly, via piping. For example, here's the command I recently used to backup one of my partitions:
dd if=/dev/sda1 bs=4096 | bzip2 > OSXsda1_ddbackup.bz2

I don't know anything about conv= stuff...I haven't read the review yet, but still wanted to answer so of your questions. :)

DrCR

_______________
A5N8X, 3500+ single-core Manchester, 2x512MB Corsair XMS, MSI 7600GT
S-12 430W, HR-05, Scythe Mime, VF900 modded with Scythe 80x25mm. Dual D12SL-12 Yate Loons
WD1200JB, WD3200JB, HD501LJ
Dual, independant WinXP installs via Grub hiding, VectorLinux 5.1.1SOHO, 5.8SOHO.
- - -
MacBook Pro Santa Rosa, 2.2GHz, 250GB Scorpio, Ceramique compound, Pending Appled-Tux Logo mod
MBRed Hard Drive with: OSX, WinXP, Vista (MSDN, pending), Sidux 2007-03
Pending Fusion "bootcamp" VMs pointing to native OS installs

jasontn 01-18-2010 01:37 AM

I am trying to mirror partitions from one harddisk to another.

At first I tried to mirror the whole harddisk to one of similar size and model.

Code:

dd if=/dev/sda of=/dev/sdb bs=4k conv=noerror 2
It managed to copy every bit correctly except for the var partition. So i cleaned up the partition table of sdb and mirror the rest manually, i.e.

Code:

dd if=/dev/sda7 of=/dev/sdb7 bs=4k conv=noerror 2
Strangely, it refuses to copy anything inside the www directory. I've tried many times with the same result - /var/www is empty in the target harddisk.

I do this all the time without any problem on Debian Etch. On this Debian Lenny box, mirroring other partitions seems fine except for /var.

Is there anything that I can trobleshoot? Logging the output showed no error encountered.

tukidid 01-21-2010 08:45 AM

image remote disk
 
if remote share is connected as
smb://ipnumber/share
could you use just one dd piped to another
and do you need root privilleges on local and
remote machine for that?

DrCR 01-24-2010 06:12 PM

Yep, should work
 
Yeah, if you booted up from a live CD, mounted a samba share to a NAS or some such, you shouldn't have any problem dding over an image of the local hard drive or a partition on the local hard drive to the NAS.

Just bare in mind it may take a good while, even over gig-E. There was one dd-like app, irrc for Linux, but perhaps unix, that has a nice transfer status. But really all you have to do is have a rough idea of how big the backup file should be and just check out the file properties on the shamba share, occasionally refreshing, to see its progress.


jasontn, just to verify, you do have the /dev/sda7 and /dev/sdb7 unmounted, correct? Most of var is temp stuff, but iirc at least some of it sticks between boots e.g. iirc there's an Apache file in www that is used as the default webpage for an Apache install.

HTH

jasontn 02-01-2010 11:43 PM

Quote:

Originally Posted by DrCR (Post 3839109)
jasontn, just to verify, you do have the /dev/sda7 and /dev/sdb7 unmounted, correct? Most of var is temp stuff, but iirc at least some of it sticks between boots e.g. iirc there's an Apache file in www that is used as the default webpage for an Apache install.

HTH

/dev/sdb7 was not mounted when copying was done. The server was idle hence little writing activity when copying. Not a single file, not even the index.html file was copied, from the www directory. I even tried placing other files there, which was also not copied.

I have done this before on live servers, running Debian Etch, flawlessly. It is only now that I'm doing this on Deban Lenny. I don't know if this problem is OS related. Unfortunately, I don't have another machine to reproduce this.

catkin 02-01-2010 11:57 PM

Quote:

Originally Posted by jasontn (Post 3849098)
/dev/sdb7 was not mounted when copying was done. The server was idle hence little writing activity when copying. Not a single file, not even the index.html file was copied, from the www directory. I even tried placing other files there, which was also not copied.

"little writing activity" would still result in an inconsistent image; there must be no writing activity.

jasontn 02-02-2010 10:43 AM

Quote:

Originally Posted by catkin (Post 3849112)
"little writing activity" would still result in an inconsistent image; there must be no writing activity.

Is it safe to unmount the /var partition when the server is running? I normally schedule the copying in the middle of the night when there is no user accessing. It is only accessed by users in the same country.


All times are GMT -5. The time now is 03:44 PM.