LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 12-26-2003, 09:58 AM   #1
sthemage
LQ Newbie
 
Registered: Jul 2003
Posts: 22

Rep: Reputation: 0
Badblocks and using dd?


I've been writing my own harddrive backup script lately. It backs up to external harddrive over USB2. A little slow, but it's better than having to burn CDRW disks.

Anyway, I use gtar in the first backup pass. In the second pass, I use "dd" to make a backup of the harddrive image itself just because I'd like to have an option of simply rewriting the image instead of having to use gtar. But I noticed that "dd" failed by saying that there was some unspecified "I/O error". I looked at my /var/log/messages file and saw:

kernel: attempt to access beyond end of device
kernel: 03:04: rw=0, want=23053276, limit=23053275

All I was doing was:
dd if=/dev/hda4 of=/mnt/sda1/hda4.image

It seems like /var/log/messages is telling me that "dd" is attempting to read past the end of the partition. But why would it do that? Also, here's something else I noticed: When I used badblocks to tell me which blocks were bad on my disk, it reports 3 blocks right at the end of the partition I'm trying to copy:

23053272
23053273
23053274

Notice that the end of my partition is apparently at 23053275. So I'm thinking maybe dd is skipping those 3 bad blocks and thinking that it still has to read 3 blocks from somewhere and tries to read past the end of the partition. Does that make sense?

I figure I could try to repartition my harddrive so that the partition ends at block 23053271 instead. Then I'd just have 4 blocks at the end of my harddrive that I don't touch. I could use resize2fs first to resize my ext2 filesystem before I do this.

Does it sound like I'm on the right track? Or is this due to something else?

This is a maxtor IDE disk too. I wonder if using the Maxtor utilities to identify badblocks would help? Would it identify those 3 bad blocks and then simply remove them? So if I ran the utility, would I come back into linux and see that the end of my harddrive is now at 23053272 instead of 23053275? And if so, would I have to use resize2fs, and could I even do that afterwards?

Thanks,
Steve
 
Old 12-26-2003, 02:52 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
"This is a maxtor IDE disk too. I wonder if using the Maxtor utilities to identify badblocks would help? Would it identify those 3 bad blocks and then simply remove them? So if I ran the utility, would I come back into linux and see that the end of my harddrive is now at 23053272 instead of 23053275? And if so, would I have to use resize2fs, and could I even do that afterwards?"

If you use the Maxtor utility to do a low level format of the drive then it will make the bad blocks dissapear. Every new hard drive has some spare blocks beyond the end of the hard drive. When the low level format finds a bad block it reassigns that address to one of the spare blocks. Software, such as dd, never know that the blocks have been rearranged. Everything then works OK.

"Anyway, I use gtar in the first backup pass. In the second pass, I use "dd" to make a backup of the harddrive image itself just because I'd like to have an option of simply rewriting the image instead of having to use gtar."

dd is subject to all sorts of fluky errors that tar is not. Even after you get the current problem fixed you are more likely to run into future problems with dd than with tar. Most importantly you are more likely to run into restore problems with dd than with tar.

"I figure I could try to repartition my harddrive so that the partition ends at block 23053271 instead. Then I'd just have 4 blocks at the end of my harddrive that I don't touch. I could use resize2fs first to resize my ext2 filesystem before I do this."

That is a neat idea and I would be interested in knowing if it works. Also check to see if a restore will work after you do this.

___________________________________
Be prepared. Create a LifeBoat CD.
http://users.rcn.com/srstites/LifeBo...home.page.html

Steve Stites
 
  


Reply



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
badblocks time linuxhippy Slackware 20 07-16-2005 10:48 PM
badblocks trouble gsgleason Linux - Hardware 12 03-03-2005 09:34 PM
reiser fs and badblocks munkie_poo Slackware 3 11-19-2004 04:48 PM
Badblocks odd Linux - Software 1 06-03-2004 01:54 PM
When and how to use e2fsck and badblocks Silly22 Linux - Newbie 5 05-29-2002 03:28 PM

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

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