LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-22-2010, 04:12 AM   #1
Jezzalien
LQ Newbie
 
Registered: Dec 2008
Posts: 3

Rep: Reputation: 0
Create image of HDD to smaller HDD, using dd or similar.


Is it possible to copy the contents of a hard drive to a smaller hard drive. It should be assumed that the source drive is operational and fault-free, whereas the target drive is also fault-free but has no operating system or partition(s). The OS is Redhat. The source drive is by no means "full" or contain data exceeding the size of the target drive.

I've been using dd to copy to equal/larger-sized drives with success, but have noticed that there are some dd command options to limit the "amount" of sectors copied. Can these options be used to limit the copy-process to just the "used" portion of the source drive, so that only the data is copied, and the remainder left untouched?

On a similar vein, can the source filesystem/data be re-arranged so that the data is moved to the "beginning" of the drive?

Regards,
Jezzalien.
 
Old 07-22-2010, 04:22 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
If the partitions on the source drive are not completely in use then maybe this could better be done by creating a partition table on the destination disk with deflated sizes, mounting partitions and then rsyncing data?
 
1 members found this post helpful.
Old 07-22-2010, 04:59 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,103

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
Rule #1: Never use dd to image a filesystem except for forensics.
Rule #2: there is only one rule.

Even were you could to get all the data to the "front" of the filesystem, the filesystem metadata has an inode table that describes the entire f/s. Chopping some portion off it is unlikely to be appreciated by fsck.
dd does an appalling job of resolving errors on the source. As per unSpawn, use a filesystem aware tool - rsync, cp, tar, ....
 
1 members found this post helpful.
Old 07-22-2010, 03:04 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,939

Rep: Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619Reputation: 3619
You can attempt that but dd usually works best if equal or greater. Since this is RH you really have other options. We use dd on some OS's that difficult to clone.

One way to condense a partition may be to tar it to some external and then copy back. I belive tar is supposed to take file by file even if fragmented. Since it was such an old command I believe it still works that way.
 
1 members found this post helpful.
Old 07-22-2010, 04:49 PM   #5
phil.d.g
Senior Member
 
Registered: Oct 2004
Posts: 1,272

Rep: Reputation: 154Reputation: 154
You could resize the source filesystem, then the source partition, then create a partition on the target drive of equal or greater size and then dd across...

...but you'd want to make backups before doing any of that. By far the easiest way is to create a partition and filesystem on the target and use tar or rsync.

If this is partition contains an OS, and you are worried that the target drive won't boot after, we can guide you through installing the boot loader on the target drive after you've tar'ed/rsync'ed the files across.
 
1 members found this post helpful.
Old 07-23-2010, 12:31 AM   #6
Jezzalien
LQ Newbie
 
Registered: Dec 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks everyone,

Plenty of options to choose from. I particularly like the sound of "create new partitions and tar/rsync"-styled options. I'll look into doing this soon, but don't hold your breath...

Thanks again,
Jezzalien.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create an Image for a 300GB hdd drive over the internet ytd Linux - General 1 05-14-2010 01:20 PM
Create Smaller USB Flash Drive Image? Githlar Linux - Software 3 09-25-2007 12:07 PM
How to create custom Linux installation cd from HDD image? chuddy117 Linux - General 0 06-18-2006 02:16 PM
how to make mirror image of one hdd to 2 hdd raj_1 General 1 12-02-2004 06:19 PM
How to make mirror image of linux partion to one1 HDD TO 2 HDD raj_1 Linux - General 2 11-04-2004 01:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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