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-09-2015, 02:33 AM   #1
a22an
LQ Newbie
 
Registered: Oct 2015
Location: front of laptop
Distribution: opensuse
Posts: 18

Rep: Reputation: Disabled
dd or tar? why?


i want to backup a:
1- boot sda1
2- / sda6
3- /home sda7
i did:
Code:
boot from mint live usb
df -k
dd if=/dev/sda1 of=/media/tu/mon/aa/bootimg5-10-2015.iso bs=4096 conv=notrunc,noerror
dd if=/dev/sda6 of=/media/tu/mon/aa/backimg5-10-2015.iso bs=4096 conv=notrunc,noerror
dd if=/dev/sda7 of=/media/tu/mon/aa/homeimg5-10-2015.iso bs=4096 conv=notrunc,noerror

but i want to do this with tar:
i did:
Code:
boot from mint live usb
tar cvzf bootimg5-10-2015.tar.gz /media/tu/mon/aa/
tar cvzf backimg5-10-2015.tar.gz /media/tu/mon/aa/
tar cvzf homeimg5-10-2015.tar.gz /media/tu/mon/aa/

please advice me?
 
Old 10-09-2015, 02:39 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,433

Rep: Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769
dd works on the raw device (or with a single file, which is an image of a divice), it will not really take care about filesystem, files and dirs on that device, tar can only work with files.
What kind of advice do you need?
 
1 members found this post helpful.
Old 10-09-2015, 03:09 AM   #3
a22an
LQ Newbie
 
Registered: Oct 2015
Location: front of laptop
Distribution: opensuse
Posts: 18

Original Poster
Rep: Reputation: Disabled
thanks pan64,
so i understand you say tar is better for backup a (boot partition, root partition and home partition)?
 
Old 10-09-2015, 03:32 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,433

Rep: Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769
What is your real goal? What do you need?
tar can only handle files and not full partitions.
 
Old 10-09-2015, 04:47 AM   #5
a22an
LQ Newbie
 
Registered: Oct 2015
Location: front of laptop
Distribution: opensuse
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
What is your real goal? What do you need?
i install Linux every month, 'training'
i want to shorten time to make a copy of Linux distro and recover it.
dd or tar?

Last edited by a22an; 10-09-2015 at 04:48 AM.
 
Old 10-09-2015, 04:49 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,433

Rep: Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769
in that case I suggest dd.
 
1 members found this post helpful.
Old 10-09-2015, 05:07 AM   #7
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 570

Rep: Reputation: 133Reputation: 133
dd creates partition or drive image (including bootloader, MBR, partition table, MFT, filesystems).
tar creates an archive that consists of files that belongs to filesystem, only files, without partition/drive/filesystem information, bootloader images at MBR.

Using dd you can restore system easily, but your partition layout should be the same as it was at dd image creation time. You shouldn't repartition your drive before restoring system from dd image.

With tar archive you can restore system to any partition that has enough space to fit unpacked filesystem.
However, you have to restore bootloader (if you changed partitions layout or if you restore a system to other drive).

In general using tar is faster than using dd because tar worsk at filesystem level.

Added:
Take a look at this article, it was written for Gentoo, but it works for any Linux.
http://www.gentoo-wiki.info/HOWTO_Custom_Stage4

I use it to backup my system.

Last edited by Teufel; 10-09-2015 at 05:12 AM.
 
2 members found this post helpful.
Old 10-09-2015, 05:58 AM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
In general tar works faster because it doesn't copy unused blocks or metadata blocks. It only copies data, with file identification (name+permissions+attributes). This makes the archive MUCH smaller than is possible with dd.

The fastest way to "recover" a system is to use PXE with a customized initrd.

The initrd can then create the partitions and filesystems needed, use an NFS mount to access the tar files, and restore the filesystems, reinstall the boot.... and if necessary, reboot/halt the system.

That way all you have to do is issue the pxe boot request.

Last edited by jpollard; 10-09-2015 at 06:02 AM.
 
2 members found this post helpful.
Old 10-09-2015, 04:47 PM   #9
a22an
LQ Newbie
 
Registered: Oct 2015
Location: front of laptop
Distribution: opensuse
Posts: 18

Original Poster
Rep: Reputation: Disabled
thanks all, another question:
is dd make formate to the partition when extracting iso?
 
Old 10-09-2015, 08:01 PM   #10
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
That depends on what you mean.

dd of an entire disk (such as /dev/sda) will copy everything -boot block (if any), partition table, filesystems... everything.

When copied to another disk (same size or larger) everything is copied back exactly the same.

dd of a partition (such as /dev/sda1) will copy everything in /dev/sda1. It will NOT copy the boot block (if any) it will NOT copy the partition table. It WILL copy just the filesystem in /dev/sda1.

This means that before that copy can be restored, the target disk must be partitioned (the same size or larger than the original partition), then the backup can be copied to that partition. If the partition is LARGER than the original, the filesystem must be retuned to set the new larger size (see the manpage/google on growfs, and you may have add that utility to use it) or the filesystem will just not use the larger size.
 
2 members found this post helpful.
Old 10-10-2015, 05:04 AM   #11
a22an
LQ Newbie
 
Registered: Oct 2015
Location: front of laptop
Distribution: opensuse
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
That depends on what you mean.
I mean when i was using windows and make formate to partition many times it cause a bad sector to hard disk,
could dd make bad sector too when i use it too many?
 
Old 10-10-2015, 05:21 AM   #12
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,433

Rep: Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769Reputation: 2769
no, dd cannot make bad sector, but may find one.... (or more)
 
1 members found this post helpful.
Old 10-10-2015, 05:46 AM   #13
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,702

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
Quote:
Originally Posted by a22an View Post
I mean when i was using windows and make formate to partition many times it cause a bad sector to hard disk,
could dd make bad sector too when i use it too many?
As stated above, dd cannot create bad sectors.

If a bad sector IS found, the disk should replace it with a good sector... unless the list of replacements has been exhausted (in which case, the disk has to be replaced).
 
  


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
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 02:48 AM
tar tar cvf - . | (cd /root/; tar xvf -) ewt3y Linux - General 10 02-19-2014 10:55 AM
"Invalid tar magic" error msg. when I try to tar ldmud *.tar file in DSL pixxi451 Linux - Newbie 4 07-04-2010 08:32 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM

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

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