LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-22-2006, 10:27 AM   #1
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
dd empty space question


i made image of hda1...
there is some empty space on it...
how to make image without that empty space??

dd if=/dev/hda1 of=/home/image bs=4096 conv=notrunc,noerror
 
Old 09-22-2006, 10:33 AM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
I believe that you cannot realistically do that because you cannot count on all of the free space being contiguous.

You can mount the partition and use dd if=<mount point> but then I doubt that it is any better than using tar.
 
Old 09-22-2006, 10:40 AM   #3
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
does tar copy all data...??
tar -cpf image.tar /dev/hda1 ??
 
Old 09-22-2006, 10:44 AM   #4
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
tar won't copy to or from an unmounted disk partition but it will copy all of the files in a mounted file system.

What I meant was that if you want to dump a disk partition then you probably can't get rid of the free space.
 
Old 09-22-2006, 10:45 AM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 126Reputation: 126
dd makes a bitwise copy of the drive (i.e., an image). The image must contain all data present on the original disk. tar, OTOH, works on the filesystem and you can create a tar file that contains all the files on the filesystem, but it will not be an 'exact copy' in the sense of an image.
 
Old 09-22-2006, 10:52 AM   #6
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
howto to archive all dirs in "/" using tar
except "/home"?
 
Old 09-22-2006, 10:57 AM   #7
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 126Reputation: 126
Use tar with the --exclude option to avoid /home. But you'll also want to avoid /sys, /dev, and /proc. You may also want to explore tar's 'l' option.
 
Old 09-22-2006, 11:00 AM   #8
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
tar -cpf tt.tar * --exclude comics/
not working...

tar -cpfl image.tar /
how to exclude /sys, /dev, and /proc?

Last edited by ygloo; 09-22-2006 at 11:03 AM.
 
Old 09-22-2006, 11:50 AM   #9
Denes
Member
 
Registered: Mar 2004
Distribution: CentOS 4.3/4.5
Posts: 72

Rep: Reputation: 15
I would suggest using partimage. You can download a live cd such as SystemRescueCD which has that on it already. That app ignores all empty space and does compression for you. I have used it to clone a linux hd. In fact I use it in an embedded application to clone linux from a compact flash so that reinstallation is not necessary. It is very fast compared with doing a dd.
 
Old 09-22-2006, 11:56 AM   #10
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,437
Blog Entries: 1

Rep: Reputation: 66
compress the image

Quote:
Originally Posted by ygloo
i made image of hda1...
there is some empty space on it...
how to make image without that empty space??

dd if=/dev/hda1 of=/home/image bs=4096 conv=notrunc,noerror
Hi,

I use this method here in the work to deal with MS_Windows images.
The images are good for a fast restore of a windows machine.

To deal with the large empty space in the image, I store the image in compressed mode with gzip. For a typical 40Gbytes image of an entire hard disk, the compressed image is just about 3G! I have a dozen of compressed images for several kinds of hardware and applications pre-loaded.
 
Old 09-22-2006, 12:02 PM   #11
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
!! 10 fold compression...
any1 knows how to exclude dirs using tar?

Last edited by ygloo; 09-22-2006 at 12:15 PM.
 
Old 09-22-2006, 01:00 PM   #12
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
dd copies MBR??
tar copies MBR??

Last edited by ygloo; 09-22-2006 at 01:03 PM.
 
Old 09-22-2006, 01:06 PM   #13
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 126Reputation: 126
Quote:
Originally Posted by ygloo
dd copies MBR??
Depends on how you use it.
Quote:
Originally Posted by ygloo
tar copies MBR??
No. The MBR is not a file.
 
Old 09-22-2006, 01:09 PM   #14
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Original Poster
Rep: Reputation: 30
how to copy MBR with dd?
 
Old 09-22-2006, 01:15 PM   #15
Denes
Member
 
Registered: Mar 2004
Distribution: CentOS 4.3/4.5
Posts: 72

Rep: Reputation: 15
dd does copy the mbr.
dd if=/hda of=hda.mbr bs=512 count=1 will copy it to the file hda.mbr.

Here is a sample script for backing up and restoring using partimage but you can use dd instead if you like.

#!/bin/sh
# Backup master boot record (MBR)
echo "Backing up master boot record"
dd if=/dev/hda of=Image.mbr count=1 bs=512

# Backup partition table
echo "Backing up partition table"
/sbin/sfdisk -d /dev/hda > Image.sf

# Create image
echo "Backing up first partition"
/usr/sbin/partimage -z1 -c -d -o -b save /dev/hda1 ImageP0
echo "Backing up second partition"
/usr/sbin/partimage -z1 -c -d -o -b save /dev/hda2 ImageP1
echo "Backing up third partition"
/usr/sbin/partimage -z1 -c -d -o -b save /dev/hda3 ImageP2
echo "Backup complete!"

Here is another one for restore

#!/bin/sh
# Write master boot record (MBR)
echo "Writing master boot record"
dd if=Image.mbr of=/dev/hda count=1 bs=512

# Write partition table
echo "Writing parition table"
/sbin/sfdisk /dev/hda < Image.sf

# Write images
echo "Writing first partition"
/usr/sbin/partimage -b restore /dev/hda1 ImageP0.000
echo "Writing second parition"
/usr/sbin/partimage -b restore /dev/hda2 ImageP1.000
echo "Writing third partition"
/usr/sbin/partimage -b restore /dev/hda3 ImageP2.000
echo "Clone complete!"
 
  


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 to delete non-empty directories? Also have a terminal question Nylex Linux - General 10 07-16-2005 12:51 AM
Gentoo VNC, empty dialog box !! "Question" window is empty ! TheHushedCaskeT Linux - Software 0 02-01-2005 11:14 PM
Parted won't partition empty space phillywize Linux - Newbie 4 01-04-2005 11:42 AM
Restore a partition from empty space Rotwang Linux - Software 4 03-16-2004 10:26 PM
Knoppix Empty HD Boot Question. rvijay Linux - Newbie 6 09-22-2003 04:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration