LinuxQuestions.org
Help answer threads with 0 replies.
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 11-24-2007, 01:37 AM   #1
bill45
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Rep: Reputation: 0
Making a dd Safety Backup


In reference to the LQorg tutorial on dd;
I intend to do a bootable iso image clone to a larger drive and boot from it prior to upgrading to Ubuntu ff7.10. I'll keep my old smaller drive as a working backup.

Will dd work on drives of unequal size?

Should I use the dd command with the destination drive mounted or unmounted?

Should I wipe any previous data from the destination drive?

Why does the example dd command copy partition 2? How is the swap partition handled?

clone one drive to another
dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=notrunc,noerror

to remove all data from dev/sdb1
dd if=/dev/zero of=/dev/sdb conv=notrunc

Thanks
Bill C
 
Old 11-24-2007, 06:54 AM   #2
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by bill45 View Post
Will dd work on drives of unequal size?
I have seen the wisdom of doing this debated. I will just say that I have successfully duplicated a 40GB drive to an 80GB without a problem. Afterwards I had to expand the size of the extended partition before I could use the additional 40GB, but it worked fine.

Quote:
Should I use the dd command with the destination drive mounted or unmounted?
Your best off with it unmounted so nothing tries to write to it. In fact, it is best if the "from" drive/partition is unmounted as well to guarantee it won't change during the operation. One way to accomplish this is to be running from a live CD instead of from the HD.

Quote:
Should I wipe any previous data from the destination drive?
No need to. Whatever is there will get overwritten.

Quote:
Why does the example dd command copy partition 2? How is the swap partition handled?

clone one drive to another
dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=notrunc,noerror

to remove all data from dev/sdb1
dd if=/dev/zero of=/dev/sdb conv=notrunc
Your fist example copies the second partition on sda to the second partition on sdb. That is because that is what you told it to do with sda2 and sdb2. If you want to copy the entire disk:

dd if=/dev/sda of=/dev/sdb

BTW, I've never used the notrunc option and am not sure I understand it. Under most circumstances I would think you would not want to use the noerr option. If you use it and there is an error, it will just keep going.

In your second example, the way you have the dd command listed, it will write zeroes to the entire disk, not just sdb1.

dd just copies bytes without worrying about what they mean. So you can copy a swap partition just as well as any other partition. Likewise, it makes no difference to dd what filesystem is on a partition.

Last edited by blackhole54; 11-24-2007 at 06:58 AM. Reason: preview != submit :(
 
Old 11-24-2007, 11:48 AM   #3
bill45
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks '54

Wouldn't it be great to have a nice neat GUI on top of dd making it much less likely to commit a fatal error or mix conflicting commands in a string.


Typically the tutorial at LQ.org does not give a background such as what drives specs can be safely cloned, what to do with swap files, using dd mounted or unmounted. I've picked up all this just reading misc posts and feedback from other's success and failures. Scary subject.


There is a big gap in the continuity of making Ubuntu "user friendly" to newbies if the processes of backup, cloning and upgrading storage hardware are not made more accessible, intuitive or (dirty word) easier.


New users are told "try Linux on an old PC" and if you like it, make it part of your computing life, system inventory etc. What happens immediately upon discovery that it is a usable friendly system with real productive potential? The first thing you want is more storage, bigger or additional HDs.


Yes I know, I'm complaining about a free OS. Well it isn't free if it costs weeks of time to figure out simple problems.

Thanks will continue research on this.

Bill
Indy
 
Old 11-25-2007, 01:42 AM   #4
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by bill45 View Post
Wouldn't it be great to have a nice neat GUI on top of dd making it much less likely to commit a fatal error or mix conflicting commands in a string.
dd is a very powerful tool. It gets its power from operating at a very low level. The flip side of this power, however, is there is some danger. I thought I remembered seeing some place where dd was incorporated into a GUI program of larger functionality, but I can't remember it, or find it now. I think it was just a subset of dd's functionality, along with some functionality that was not related to dd.


Quote:
Typically the tutorial at LQ.org does not give a background such as what drives specs can be safely cloned, what to do with swap files, using dd mounted or unmounted. I've picked up all this just reading misc posts and feedback from other's success and failures. Scary subject.
If this is a wiki page you are talking about, as you learn more about this subject, you can modify or add to that page to make it better.


Quote:
There is a big gap in the continuity of making Ubuntu "user friendly" to newbies if the processes of backup, cloning and upgrading storage hardware are not made more accessible, intuitive or (dirty word) easier.

New users are told "try Linux on an old PC" and if you like it, make it part of your computing life, system inventory etc. What happens immediately upon discovery that it is a usable friendly system with real productive potential? The first thing you want is more storage, bigger or additional HDs.
Maybe my persective is screwed up, but I would not consider things that would typically involve dd to be something I would expect a "newbie" to be doing. For simple backup, there are other alternatives, some of which are GUI based. If you want a commercial product that probably is a little easier, Norton Ghost probably fills the bill. Understand that I have not used it; I am basing this on what I have read. These days, for backup I most often use tar or PartImage. The latter is GUI, the former is not.

Quote:
Yes I know, I'm complaining about a free OS. Well it isn't free if it costs weeks of time to figure out simple problems.
You've probably heard it before, but I will repeat it. The value of free(dom) software is in the freedom, not the price. Yes, there is a learning curve. But the learning is an investment, not a throw away expenditure. As you understand more about your system you will find it easier to make it do what you want rather than being forced to limp along with what somebody else says you should be content with. And most of this knowledge won't become obsolete when then next (or the next, or the next ...) version of software comes out.

Good luck as you explore this new (for you) operating system. Have fun (and don't be afraid of the command line)!
 
Old 11-25-2007, 07:33 AM   #5
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 270Reputation: 270Reputation: 270
The problem with dd is that it doesn't do any type of integrity check. It's exactly like the name describes it, disk dump. It doesn't care if the data is corrupt or missing, etc.

If you do decided to use dd as a backup method, the best way to ensure that the dd image you created is valid is to test it before you wipe anything you've backed up or you might find yourself in a really big jam when something went wrong during the dump.

I use dd for iso images, creating small images of the like not intended to be a backup but never as a primary backup solution, it really is too risky and it's too much of a maintenance as a sysadmin to ensure the dd is good, it's almost like double work.
 
Old 11-25-2007, 10:05 PM   #6
bill45
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks 54, your input is well appreciated. When I say free software it's a given that I include both meanings (freedom and free beer) but also feel I'm importuning volunteers who have already worked miracles with Ubuntu and other distros. I'll get over it.


I finally figured out how to invoke g4l on the bootable SystemRescueCD and it did sorta work. I checked the cloned drive and all the files are there. However it will not boot. Perhaps I need to do that trick expanding the swap file or partition to match the drive (gulp!). I'm keeping the original small 20GB drive w/Ubu7.04 intact as a backup for now. I'll install Ubu7.10 over the larger cloned drive when I get it to boot.


Thanks trickykid, I am only using dd or g4l as a one time clone project, and will probably use a simpler GUI front end like Sbackup for subsequent backups. That G4L boot CD does have Gparted on it so I do have that available as well.


What am I looking for to repair that larger 40GB drive I just cloned from the 20GB image? Do I need to put grub on it?

Bill
Indy

Last edited by bill45; 11-25-2007 at 10:06 PM. Reason: spelling
 
Old 11-26-2007, 01:00 AM   #7
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by bill45 View Post
I finally figured out how to invoke g4l on the bootable SystemRescueCD and it did sorta work. I checked the cloned drive and all the files are there. However it will not boot.
If your original disk booted with GRUB and if all the files are still there, you should only need to reinstall the MBR. If your partition with the GRUB info is /dev/sda2, and if you boot into a live CD (or rescue mode) which has GRUB, you can

Code:
# grub
grub>  root (hd0,1)
grub> setup (hd0)
grub> quit
#
If the partition is other than /dev/sda2, change the partition number in red accordingly.



Quote:
Perhaps I need to do that trick expanding the swap file or partition to match the drive (gulp!).
Not the swap partition!

If you want to be able to use the full disk, you need to expand the extended partition if there is one and it is the last of the used primary partitions. And this is true only if you copied the whole disk, partition tables and all (rather than individual partitions). If your satisfied with the smaller size, you don't need to do anything.

Quote:
I'm keeping the original small 20GB drive w/Ubu7.04 intact as a backup for now.
Very wise!

Last edited by blackhole54; 11-26-2007 at 01:03 AM. Reason: typos
 
Old 11-27-2007, 02:18 PM   #8
bill45
LQ Newbie
 
Registered: Nov 2007
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks 54, this is almost like fun.

OK, boot to live CD and do the grub command, copy the MBR. then figure out how to expand the extended partition. Does this mean I have two data partitions regardless, or can I add the extended to the ext3 boot partition which is the preferred outcome?

I take it I have root privileges with any distro using live rescue CD?

The Gnome Partition Editor shows the cloned 40GB drive as follows:

dev/sdb1 ext3 18.25GB ext3 /home/40GB/ used3.54GB unused14.71Gb boot
dev/sdb2 extended 8.55.02MB
dev/sdb5 swap 8.54.99MB
unallocated 18.19GB
 
Old 11-28-2007, 12:52 AM   #9
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by bill45 View Post
Thanks 54, this is almost like fun.
Glad you're enjoying it!

Quote:
OK, boot to live CD and do the grub command, copy the MBR. ...
I don't want to get picky about wording, but I do want to make sure we are communicating. The commands I gave you will create a new MBR (except for the partition table) based on the info in menu.lst and the location of things on the disk.


Quote:
then figure out how to expand the extended partition. Does this mean I have two data partitions regardless, or can I add the extended to the ext3 boot partition which is the preferred outcome?
The extended partition is simply a container for the logical partitions (sda5 and above). So no, it has to remain separate. More on this below.

Quote:
I take it I have root privileges with any distro using live rescue CD?
Yes. All the stuff you are doing here requires running as root. If you've booted a CD in rescue mode, you are probably root already. On a live CD, if you boot up as a normal user, it is likely that

Code:
sudo su
will make you root, w/o being asked for a password.

Quote:
The Gnome Partition Editor shows the cloned 40GB drive as follows:

dev/sdb1 ext3 18.25GB ext3 /home/40GB/ used3.54GB unused14.71Gb boot
dev/sdb2 extended 8.55.02MB
dev/sdb5 swap 8.54.99MB
unallocated 18.19GB
If your extended partition contained any partitions with real data I would probably suggest you resize the extended partition, which might be a bit hair-raising. (For reasons I forget, I once had to do that by deleting, then recreating the extended partition using fdisk while leaving the contained partitions in place.) But since the swap partition can be easily recreated. I would suggest you simply delete both the swap and the extended partitions. Then you will have just one partition left which is your first primary partition. The you can easily partition the rest of the disk as you like.

Remember the limit of 4 primary partitions. And if you are going to have any logical partitions, one of the primary partitions will have to be the extended partition. Plan now for what you may wish to do in the future so you don't run out of primary partitions.

Remember to recreate your swap partition. After creating it, you must format it with

Code:
mkswap <partition>
That can probably by done from your rescue/live CD. If your swap partition has changed partition number, you will also need to edit /etc/fstab to reflect the change. I suggest you edit that file from your rescue/live CD.

Yeah, this is just like a game!

Last edited by blackhole54; 11-28-2007 at 01:39 AM. Reason: finishing post after interruption
 
  


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
making a backup script keef12345 Linux - Newbie 1 11-03-2007 05:23 PM
Making a Backup Harddrive mepenn Fedora 4 01-27-2007 11:45 AM
Making backup through ssh connection Supernoobs Linux - General 1 11-17-2005 12:09 PM
Making a simpel backup CloudBuilder Linux - Newbie 4 10-30-2003 12:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:05 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