LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Mirroring a disk - Debian dd command hangs system (https://www.linuxquestions.org/questions/linux-newbie-8/mirroring-a-disk-debian-dd-command-hangs-system-888104/)

pbeau 06-24-2011 07:53 AM

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!

Thanks
Paul

theNbomr 06-24-2011 10:37 AM

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.

r3sistance 06-24-2011 11:03 AM

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.

pbeau 06-25-2011 02:16 AM

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

Paul

syg00 06-25-2011 06:41 AM

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.

satya_s2k 06-25-2011 07:04 AM

You can use tar command to take full system backup. Refer http://ubuntuforums.org/showthread.php?t=35087. 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 /

markush 06-25-2011 07:38 AM

@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.

Markus

Tinkster 06-25-2011 07:05 PM

satya: please stop spamming your links.

jefro 06-26-2011 03:57 PM

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.

frieza 06-26-2011 05:42 PM

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.

pbeau 06-29-2011 04:14 AM

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.

Karl Godt 06-29-2011 05:43 AM

I mostly use
Code:

rsync -url --devices /Directory /mnt/sdaXY/Backup/
I've also put in a function into .bashrc
Code:

Rs(){
if [ -d /proc/ide ] ; then
DEVNAME='hdb'
else
DEVNAME='sda'
fi

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

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

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

else

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`"

else

echo "ERROR"

fi

fi
}

where rox is my filemanager . I'll have to put a
Code:

[ -z "$1" ] && exit
into it at top , though .


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