LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-16-2014, 11:24 AM   #1
luverboy4u
LQ Newbie
 
Registered: Oct 2014
Posts: 5

Rep: Reputation: Disabled
Backup of HDD partitions using DD


Hi,

I'm a newbie in Linux.
The background of the system I have is listed below.
CentoOS 7 with 4 processors and 8GB of RAM.
This is my test server to test out the "dd" command so that I can make an image of another physical Red Hat Linux machine.
The test server CentOS 7 has two partitions on it /dev/sda1 and /dev/sda2. Boot; /dev/sda1 and Linux LVM:/dev/sda2.

My question is how do I back up both partitions using the dd command to a USB drive or NAS/SAN server as a single .img file?
 
Old 10-16-2014, 11:26 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,260

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Code:
dd if=/dev/sda of=/path/to/backup/location.img
Just make sure your backup system has enough space available to hold the entire capacity of /dev/sda. Not just the used space, the entire space. You should also shut down the system while this is running. You can do the backup in a live session to make sure none of the files change during the copy, rendering the backup inconsistent.

Last edited by suicidaleggroll; 10-16-2014 at 11:27 AM.
 
Old 10-16-2014, 11:31 AM   #3
luverboy4u
LQ Newbie
 
Registered: Oct 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
so the dd if=/dev/sda command would get the whole drive and not just one partition as in sda1 or sda2 right?
 
Old 10-16-2014, 11:57 AM   #4
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 571

Rep: Reputation: 183Reputation: 183
dd will copy the entire drive including both partitions and all unused space, as well, to one file.
On the other hand, you can copy the first partition to one file, and copy the second partition to another file. So you would have 2 files instead of one.
Alternatively, you can run the gparted program in a live DVD or USB and use it almost like a file manager to Copy and Paste the partitions elsewhere. That is MUCH faster than dd.
 
Old 10-16-2014, 12:10 PM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
^ rite. this is what i do:
http://www.linuxquestions.org/questi...6/#post4904425
 
Old 10-16-2014, 12:29 PM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,117

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Since you're copying a large amount of contiguous data (the entire hard disk), it makes sense to increase the blocksize used by dd for the copy. That will make the dd operation run much faster.

Code:
dd if=/dev/sda of=/path/to/backup/location.img bs=16384
Since you are new to dd, it is important to state "Don't ever mix up the if= and of= parameters!"

Also, to a little learning on image-based vs. file-based backups. dd is image-based. There are different factors to consider that might make you want to choose one backup strategy over the other.
 
Old 10-16-2014, 01:37 PM   #7
luverboy4u
LQ Newbie
 
Registered: Oct 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks to haertig, suicidaleggroll, haertig, and TxLonghorn for the responses.
 
Old 10-16-2014, 02:23 PM   #8
OpensourceRulzs
LQ Newbie
 
Registered: Oct 2014
Posts: 14

Rep: Reputation: Disabled
Since you will use a liveCD to do this, why not use clonezilla.

This is what clonezilla is specifically designed to do. If you never heard of clonezilla, go to youtube.com and you will find many videos on its usage.
 
Old 10-16-2014, 02:32 PM   #9
luverboy4u
LQ Newbie
 
Registered: Oct 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Ok that is my second option but how do I convert all of the files that Clonezilla uses to an .img file?
 
Old 10-16-2014, 02:41 PM   #10
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 2,330
Blog Entries: 1

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
It's better to back up the individual partitions IMO. As you can mount those backups and rsync the files as the restore option, or grab individual files as needed. Pros and cons and lots of options in terms of backups. A dd of the full drive might be less useful if the replacement drive is not that same size, or if you want to try "other" filesystems for a while.
 
Old 10-16-2014, 02:42 PM   #11
OpensourceRulzs
LQ Newbie
 
Registered: Oct 2014
Posts: 14

Rep: Reputation: Disabled
Quote:
Originally Posted by luverboy4u View Post
Ok that is my second option but how do I convert all of the files that Clonezilla uses to an .img file?
Clonezilla handles all this for you, from copying a partition(s) and selecting the img file(s) you want to restore.

Watch some videos on youtube on clonezilla as it would be explained more clearly. In fact, watch several videos if you can, because some videos are not complete or clear. Make sure the video explains backing up and restoring the clone images.

PS: if clonezilla is still not clear to you, then use the dd methods above.

Last edited by OpensourceRulzs; 10-16-2014 at 03:04 PM.
 
Old 10-16-2014, 02:43 PM   #12
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,029

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
^ kpartx supposedly can navigate individual partitions from within a disk image file.
 
Old 10-16-2014, 03:32 PM   #13
luverboy4u
LQ Newbie
 
Registered: Oct 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks for the help everyone.
 
  


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
HDD backup: taking a snapshot of the whole drive instead of partitions jsmith6 Linux - Laptop and Netbook 2 03-23-2010 12:02 PM
[SOLVED] Linux HDD backup under windows - looking for backup utility SigTerm General 1 01-27-2010 12:54 PM
HDD partition recovery - HDD works but no partitions are accessible? stevod333 Linux - Software 6 10-01-2009 06:24 AM
corrupted HDD: need to place backup onto different HDD Cyberman Linux - Desktop 6 09-26-2009 11:51 PM
Formatting external hdd as backup to 2 hdd's balch4 Linux - Desktop 2 12-05-2006 12:49 AM


All times are GMT -5. The time now is 01:08 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration