Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 06-24-2011, 08:53 AM   #1
LQ Newbie
Registered: May 2011
Location: London UK
Distribution: Debian
Posts: 12

Rep: Reputation: Disabled
Mirroring a disk - Debian dd command hangs system

This is a somewhat hybrid system - Tweaked Debian Based (4.0 I think) Studio64 and I have installed and got running LLAMP and Webmin on top. I have 2 identical (250GB) disks one or which is the system and I'd like to mirror to the other it in such a way that if the original breaks (or , more likely, I break it!), I can boot off the other and restore myself to the last backup. I tried:

dd if=sdb of=sda

a number (4+) of times. Mostly it runs for ages (6+ hrs) then hangs the system. Once it completed and the system booted off sda but no 'products'- (LLAMP, KDE) would start. (various errors indicating wrong device).

The question(s):

Is this the right approach for what I am trying to do - make the system safe by providing an alternate system? Ideally, Id like this to just run automatically every 3-5 days.
Why does this hang most of the time (and indeed, why are the results different when, as near as I can tell, the starting conditions are the same? Maybe this is a clue:

/dev/sdb1 237755108 55739120 169938728 25% /
tmpfs 773012 0 773012 0% /lib/init/rw
udev 10240 92 10148 1% /dev
tmpfs 773012 0 773012 0% /dev/shm
/dev/sda1 237755108 111118020 114559828 50% /dsk2

Final note: I'm long familiar with computers, networks etc. but really new to Linux. Be gentle!

Old 06-24-2011, 11:37 AM   #2
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,398
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Using dd to make a copy of a mounted filesystem isn't a great idea. In any case, if you like to use dd, you should see AwesomeMachine's 'Learn The DD Command Revised' here on LQ. Have you considered the use of rsync to do your backup? You would have to copy the MBR independently, but that rarely, if ever changes.
--- rod.
Old 06-24-2011, 12:03 PM   #3
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
If Human Error is not something you are too concerned about I'd advise using RAID. There are a few ways to RAID and it is possible to convert partitions to RAID, this gives an active back-up. It does have the issue that RAIDs do back-up human error so from that side of things it is not a back-up and also it is possible to cause other issues during the process of making a RAID but I am just tossing it out as an alternative option to look at. Else wise I'd do as theNbomr has said and consider rsync as it will only back-up files that have changed since the last rsync.

Last edited by r3sistance; 06-24-2011 at 12:05 PM.
Old 06-25-2011, 03:16 AM   #4
LQ Newbie
Registered: May 2011
Location: London UK
Distribution: Debian
Posts: 12

Original Poster
Rep: Reputation: Disabled
Many thanks for the replies. Re the dd command - is the problem in using this on mounted file systems around open files? I've looked into rsync but as I said - I am very new at Linux (and unix)and rsync looked a bit complicated to start with. I come from a VMS world and while much here looks familiar, the language is alien (!) and underlying ideas are quite different. I'll look into rsync again ... I'll need to figure out the simple command to copy the entire disk... the fact that it copies only changes after that is a big boost. Any chance of pointing me at some instruction for copying the MBR?

Good forum! I might just get a handle on this yet!

Many thanks

Old 06-25-2011, 07:41 AM   #5
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,169

Rep: Reputation: 2628Reputation: 2628Reputation: 2628Reputation: 2628Reputation: 2628Reputation: 2628Reputation: 2628Reputation: 2628Reputation: 2628Reputation: 2628Reputation: 2628
VMS as in VAX ?. Whoa - I thought I was old school ...
Misty memories of a PDP 11/45 connected to a CDC 6400 swirl past ...

Sorry, back to the current century/universe.

dd is a block level tool - it has no knowledge (or interest) in filesystems. Read that as "your data". Madness to use it on a running system.
And by default it works at the sector level (512 bytes) - hence it takes forever, and updates get lost. Similar comments apply to any generic tool on running system(s) BTW - rsync included.
Do full system backups from a quiesced system - liveCDs work well.

As for backing up the MBR, I have never seen a benefit, and lots of potential cock-ups. Easier to re-install. That liveCD comes to the rescue again.
Old 06-25-2011, 08:04 AM   #6
LQ Newbie
Registered: Jun 2011
Posts: 2

Rep: Reputation: Disabled
You can use tar command to take full system backup. Refer After full system backup, to restore just install basic linux. Copy the backup to the local file system and restore.

Command that i used and found usefull.
1. cd /

2. tar cvpzf backup.tgz --exclude=/proc --exclude=/etc/fstab --exclude=/boot --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /
3. tar cvpjf backup.tar.bz2 --exclude=/proc --exclude=/lost+found --exclude=/backup.tar.bz2 --exclude=/mnt --exclude=/sys /

Last edited by Tinkster; 06-25-2011 at 08:04 PM. Reason: Pleased stop spamming links to what I presume is your own site.
Old 06-25-2011, 08:38 AM   #7
Senior Member
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
@satya_s2k: this is the third post of you with a link to this "learn-linux" site.

Maybe the site is useful in your opinion, as far as I see there is nothing on this site with has to do anything with the theme of this thread, the same thing is true for the other two posts of you. Moreover the site seems quite new and there is nothing useful at all.

We don't want spammers here, if you insert a link, please take a useful link which points us to a site which has something to do with the theme of the thread.

Old 06-25-2011, 08:05 PM   #8
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911Reputation: 911
satya: please stop spamming your links.
Old 06-26-2011, 04:57 PM   #9
Registered: Mar 2008
Posts: 18,565

Rep: Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780Reputation: 2780
I'd use a different block size for the dd command.

I'd also dd to a file instead. Dunno why but I would.

I clone a lot of old systems with dd to some ftp file. I compress the image. There is some about that may be best for your systems. Some may support max compression but the middle 5 is a good place to start.
Old 06-26-2011, 06:42 PM   #10
Senior Member
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 404Reputation: 404Reputation: 404Reputation: 404Reputation: 404
dd SHOULD work, provided the drives are the same size, but running it on the drive that contains the active OS is troublesome at best because the contents are always changing, it's like trying to shoot a moving target.

the best way to clone a drive with your OS like this, i'm surprised nobody else seems to have mentioned such, is to boot the drive off a live cd or thumb drive, THEN perform the dd operation.
Old 06-29-2011, 05:14 AM   #11
LQ Newbie
Registered: May 2011
Location: London UK
Distribution: Debian
Posts: 12

Original Poster
Rep: Reputation: Disabled
Ok. I think for the immediate issue, there are a number of cloning options. Live CD and dd sounds good. I guess I'd get the same effect with clonezilla. I can then attempt an upgrade which, it it all goes horribly wrong, I can get out of! After that an regular, automatic and reliable backup mechanism is what is needed. Sounds like rsync and a bit of study is in order. Thanks to all for the pointers. I really wanted to be a dumb user in all of this but it just doesn't work that way does it? I suppose that is what windoze is for.
Old 06-29-2011, 06:43 AM   #12
Karl Godt
Registered: Mar 2010
Location: Kiel , Germany
Distribution: once:SuSE6.2,Debian3.1, aurox9.2+3,Mandrake?,DSL? then:W7st,WVHB, #!8.10.02,PUPPY4.3.1 now:Macpup
Posts: 314

Rep: Reputation: 45
I mostly use
rsync -url --devices /Directory /mnt/sdaXY/Backup/
I've also put in a function into .bashrc
if [ -d /proc/ide ] ; then

if [ -z "`mount | grep "^/dev/${DEVNAME}12"`" ] ; then

if [ ! -d /mnt/${DEVNAME}12 ] ; then
mkdir /mnt/${DEVNAME}12

mount /dev/${DEVNAME}12 /mnt/${DEVNAME}12

rox /mnt/${DEVNAME}12/MacPup_F3/ &
rsync -url --devices "$1" /mnt/${DEVNAME}12/MacPup_F3"`dirname $1`"
sleep 4s

rox /mnt/${DEVNAME}12/MacPup_F3/"`dirname $1`"
umount /dev/${DEVNAME}12


if [ -n "`ls /mnt/${DEVNAME}12/*/* 2>/dev/null`" ] ; then

rox /mnt/${DEVNAME}12/MacPup_F3/ &
rsync -url --devices "$1" /mnt/${DEVNAME}12/MacPup_F3"`dirname $1`"


echo "ERROR"


where rox is my filemanager . I'll have to put a
[ -z "$1" ] && exit
into it at top , though .


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
wall hangs on tty_write system call for about 15 minutes on debian 2.6 kernel kspradhan Linux - Server 1 08-30-2008 07:02 AM
lftp mirroring hangs cannot open file for reading archangel_617b Linux - Software 3 05-22-2008 12:03 PM
SATA exception, disk errors, system hangs Barrett Linux - Hardware 2 01-02-2008 09:28 AM
Bootable disk that hangs system Akhran Linux - Newbie 2 09-03-2005 05:54 AM
Hard Disk hangs if system left on for 2-3 hours jdsahota Linux - General 1 07-13-2003 08:29 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:59 PM.

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