LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 10-07-2008, 07:27 PM   #1
DeadlyMuffin
Member
 
Registered: Feb 2003
Distribution: Gentoo, Debian, Openslug, Slackware
Posts: 46

Rep: Reputation: 15
Using dd for backup screws up drive geometry


I copied an entire disk to a larger one using:

dd if=/dev/source of=image
dd if=image of=/dev/target

The source drive was 40gigs, the target drive 110gigs. Everything seems to have worked, but now the drive geometry on the target drive reads the same as the source drive. Is there any way to recover the unused space?
 
Old 10-08-2008, 01:58 AM   #2
FewClues
Member
 
Registered: Jul 2005
Location: Mission TX
Distribution: Ubuntu, Mint
Posts: 122

Rep: Reputation: 20
Drive geometry

Quote:
Originally Posted by DeadlyMuffin View Post
I copied an entire disk to a larger one using:

dd if=/dev/source of=image
dd if=image of=/dev/target

The source drive was 40gigs, the target drive 110gigs. Everything seems to have worked, but now the drive geometry on the target drive reads the same as the source drive. Is there any way to recover the unused space?
You should be able to use parted to stretch the current partions and/or create an additional partition. Since you will be making major changes to your hard drive you need to be SuperUser or use sudo parted and follow the menu.

Last edited by FewClues; 10-08-2008 at 01:59 AM.
 
Old 10-08-2008, 11:30 AM   #3
DeadlyMuffin
Member
 
Registered: Feb 2003
Distribution: Gentoo, Debian, Openslug, Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Really? Fdisk and cfdisk both show the drive as a 40 gig (which it isn't). Would parted be able to figure it out?
 
Old 10-08-2008, 12:05 PM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Using dd like that means you have rewritten the partition table on your 110G disk, so it now thinks it is a 40G disk.
What you should have done was to create a 40G + a bit for safety partition on the 110G disk and then dd'd the original drive to that partition

eg

Code:
dd   if=/dev/hda   of=/dev/hdc1
Where /dev/hda is your 40G disk and /dev/hdc1 is the slightly bigger than 40G partition on your 110G disk.
 
Old 10-08-2008, 02:25 PM   #5
DeadlyMuffin
Member
 
Registered: Feb 2003
Distribution: Gentoo, Debian, Openslug, Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by tredegar View Post
Using dd like that means you have rewritten the partition table on your 110G disk, so it now thinks it is a 40G disk.
What you should have done was to create a 40G + a bit for safety partition on the 110G disk and then dd'd the original drive to that partition

eg

Code:
dd   if=/dev/hda   of=/dev/hdc1
Where /dev/hda is your 40G disk and /dev/hdc1 is the slightly bigger than 40G partition on your 110G disk.
Yup, I realized that once I started doing some digging, but I'm afraid it's too late to go back. What I'm looking for is how to fix the drive as it is now.
 
Old 10-08-2008, 02:59 PM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
What I'm looking for is how to fix the drive as it is now.
Fix which drive?
I assume the original 40G is still working OK. So you don't need the (backup?) copy right now.

In which case plug in the 110GB drive and repartition it (Delete all partitions, create new ones, write the changes to it).

Then do the dd again to the correctly sized (and add a bit!) partition you created earlier, with the benefit of hindsight.
 
Old 10-08-2008, 03:16 PM   #7
DeadlyMuffin
Member
 
Registered: Feb 2003
Distribution: Gentoo, Debian, Openslug, Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Quite right, the 40 gig drive is fine, but the 110 gig drive reads as 40 gigs in fdisk, so even if I wipe the partitions and make a new one, it will be a 40 gig partition.
 
Old 10-08-2008, 07:40 PM   #8
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
but the 110 gig drive reads as 40 gigs in fdisk, so even if I wipe the partitions and make a new one, it will be a 40 gig partition.
No, it won't. You have missed the point.
Just fdisk the 110GB again. Delete all the partitions. Write these changes to the disk.

Then create new partitions as you wish.

You have not understood the difference between
/dev/hdx and /dev/hdx1 or /dev/hdx2 , the first and second partitions on the device /dev/hdx
Try again.
 
Old 10-08-2008, 08:35 PM   #9
DeadlyMuffin
Member
 
Registered: Feb 2003
Distribution: Gentoo, Debian, Openslug, Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Actually, I think you're misunderstanding what I'm saying.

I do understand the difference between copying a single partition and copying the whole disk. In retrospect, I should've copied it partition by partition. Hindsight is always 20-20.

The problem now is that every tool I use sees the 110 gig drive as a 40 gig drive. This includes fdisk. If I manually enter the correct heads/sectors/cylinders in fdisk and force it to create a partition that actually fits on the disk no utilities accept it, and everything complains that the partition extends beyond the end of the disk.

I don't care about the partitions right now, what I want to do is get my 110 recognized as 110 gigs. I've tried deleting the old partitions, adding new ones, whatever, it doesn't seem to take.

Irritatingly enough even writing changes to the number of heads/sectors/cylinders in fdisk doesn't seem to take.
 
Old 10-08-2008, 08:41 PM   #10
CJS
Member
 
Registered: May 2008
Location: California, USA
Distribution: Ubuntu 8.10
Posts: 247

Rep: Reputation: 49
If you don't care about your partitions or anything else on that HDD, you could just delete your HDD's partition table with:
Code:
dd if=/dev/zero of=/dev/hdc bs=512 count=1
Or replace hdc with whatever is your HDD. The above command will delete the entire MBR (Master Boot Record) and make your HDD appear like it has never been formatted before. That should do the trick of getting it recognized as 110 GB again. Let me know how it goes.
 
Old 10-09-2008, 07:53 AM   #11
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,637

Rep: Reputation: Disabled
To learn about dd there is this

http://www.linuxquestions.org/questi...ommand-366442/

and follow the link to the newer thread. There use the search-thread-function and search for MBR or any key word you deem of interest. There is also lots to learn in the follow up posts.
 
Old 10-09-2008, 10:26 AM   #12
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
The problem now is that every tool I use sees the 110 gig drive as a 40 gig drive. This includes fdisk. If I manually enter the correct heads/sectors/cylinders in fdisk and force it to create a partition that actually fits on the disk no utilities accept it, and everything complains that the partition extends beyond the end of the disk.
This is very strange behaviour. fdisk - delete the partition(s) - create partitions always works for me.
No offense intended, but I suppose you have made absolutely sure you have identified your disks correctly?
If necessary by unplugging one, reading the label, and re-testing the one that is still plugged in?
 
Old 10-09-2008, 11:37 AM   #13
DeadlyMuffin
Member
 
Registered: Feb 2003
Distribution: Gentoo, Debian, Openslug, Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Yep, I'm certain it's the same drive. I think I may be SOL on this one.
 
Old 10-09-2008, 12:36 PM   #14
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora40
Posts: 6,153

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Did you try zeroing out the drive as CJS suggested? Please be very careful that you are choosing the correct device, and remember, you are zeroing the disk, not a partition.
Once you have done that, could you please post the output of
Code:
fdisk -l
With both drives attached (you'll need to be root).
 
Old 10-09-2008, 01:31 PM   #15
DeadlyMuffin
Member
 
Registered: Feb 2003
Distribution: Gentoo, Debian, Openslug, Slackware
Posts: 46

Original Poster
Rep: Reputation: 15
Zeroing the partition table deletes the partitions, but the drive still reads as the wrong size.

I don't have the original 40 gig drive installed, this is the output for the large drive (it's actually a 160 not a 110, I was mistaken)


fdisk -l /dev/sda

Disk /dev/sda: 38.5 GB, 38502535680 bytes
64 heads, 32 sectors/track, 36718 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

Device Boot Start End Blocks Id

This was after zeroing it. The irritating part is, I know what the correct heads/sectors/cylinders should be, but when I change them in fdisk they change right back as soon as I exit.
 
  


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
Drive Geometry Problems jcmalc Debian 1 09-23-2005 03:13 AM
Hard drive geometry possibly borked, weird random errors. purplecow Linux - Hardware 2 06-15-2005 02:11 PM
Debian Sarge netinst & businesscard, grub, changes drive geometry...Y? Outabux Debian 1 10-20-2004 11:57 PM
manually entering drive geometry artofluke Slackware 1 12-08-2003 03:06 AM
drive geometry problems artofluke Linux - Hardware 1 11-22-2003 04:40 PM

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

All times are GMT -5. The time now is 09:05 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
Open Source Consulting | Domain Registration