Hot answers tagged

20

Let /dev/sda be the new drive on which to test destructive-rw and /dev/sdb the old drive where you want non-destructive-r # badblocks -wsv /dev/sda # badblocks -sv /dev/sdb -s gives the process indicator -v gives verbose output -w enables destructive read-write -n would be non-destructive read-write Read-only testing is the default and doesn't need ...


14

From examining the source code, I find that: If you didn't specify -n or -w, badblocks doesn't write to the disk at all, so you're safe interrupting it. If you specified -w, badblocks has already overwritten the filesystem, so it's much too late to worry about interrupting the process. If you specified -n, badblocks uses a signal handler to prevent the ...


14

All these "poke the sector" answers are, quite frankly, insane. They risk (possibly hidden) filesystem corruption. If the data were already gone, because that disk stored the only copy, it'd be reasonable. But there is a perfectly good copy on the mirror. You just need to have mdraid scrub the mirror. It'll notice the bad sector, and rewrite it ...


14

Your guess is correct. The source code looks like this: if (v_flag) fprintf(stderr, _("Pass completed, %u bad blocks found. (%d/%d/%d errors)\n"), bb_count, num_read_errors, num_write_errors, num_corruption_errors); So its read/write/corruption errors. And corruption means comparison with previously written data: if (t_flag) {...


10

Bad sectors are always an indication of a failing HDD, in fact the moment you see an I/O error such as this, you probably already lost/corrupted some data. Make a backup if you haven't one already, run a self test smartctl -t long /dev/disk and check SMART data smartctl -a /dev/disk. Get a replacement if you can. Bad sectors can't be repaired, only replaced ...


8

When you're using ext4, you can check for badblocks with the command e2fsck -c /dev/sda1 or whatever. This will "blacklist" the blocks by adding them to the bad block inode. e2fsck -c runs badblocks on the underlying hard disk. You can use the badblocks command directly on a LVM physical volume (assuming that the PV is in fact a hard disk, and not some ...


7

You're working from a shaky premise, being that badblocks can solve your problem in the first place. Why badblocks Is an Untrustworthy Repair Method As you use a hard drive, it continually does its best to hide problems from you by swapping fresh sectors in for dodgy ones. The hard disk ships from the factory with a pool of spare sectors for this very ...


6

If you're looking for advanced filesystems for general-purpose computers in the Linux world, there are two candidates: ZFS and BTRFS. ZFS is older and more mature, but it's originally from Solaris and the port to Linux isn't seamless. BTRFS is still under heavy development, and not all features are ready for prime time yet. Both filesystems offer per-file ...


5

No, bad sectors are not always an indication of a failing drive. Sometimes if a write is in progress at the time of a power failure, the data in the sector will be corrupted, resulting in an error when you try to read it. Attempting to write new data to the sector may work just fine since there's nothing physically wrong with it. You can run badblocks -n ...


5

Your disk had some problems with reading data from the surface, but it seems that the disk dealt with it. I had similar situation: Error 29 occurred at disk power-on lifetime: 18836 hours (784 days + 20 hours) When the command that caused the error occurred, the device was active or idle. After command completion occurred, registers were: ER ST SC SN ...


4

I've just had pretty much the same problem with a RAID1 array. The bad sector was right at the beginning of one of the partitions - sector 16 of /dev/sdb2. I followed the instructions above: after verifying that logical block 2 was not in use by the file system and being careful to get dd seek and skip the right way around, and zeroed out 1 file system block:...


4

There are no reallocated sectors because they failed to reallocate. Your drive is showing 5 Offline_Uncorrectable sectors, which happens when automatic repair fails. There are obvious read failures shown in the dmesg output, SMART errors, and read failures from SMART tests. There are ways of repairing these sectors as you have mentioned in the question, but ...


4

Sounds like you have a bad cable. The drive renaming itself is indicative of the USB connection being dropped and restarted and the kernel assigning the next device name to the subsequent connection. I'd watch dmesg for USB errors while accessing the drive. If it works with the short cable, that further reinforces your long cable is bad. Also keep in ...


3

I'm pretty sure LVM doesn't handle bad blocks; it expects the underlying storage to. And most, if not all, modern hard disks do. You may need to perform a write to the sector, but the disk should remap it. (You may need it to do an offline surface scan first, with e.g., smartctl /dev/sda -t offline). That said, LVM doesn't actually move data around unless ...


3

ZFS has by default multiple copies of every meta data block. You can enable this feature for data blocks and then have some protection against (localized and non massive) disk errors. http://blogs.oracle.com/bill/entry/ditto_blocks_the_amazing_tape Automatic ZFS Snapshots are also a popular way to protect files against accidental deletion or corruption.


3

No, you can't. You should also check the drive's SMART status either with the gnome disk utility or with smartctl from the smartmontools package. If it is only a few bad sectors, md should have tried to rewrite them, which should have triggered the drive to automatically remap them to the spare pool. If you have enough bad sectors that the spare pool has ...


3

Try dumpe2fs -b /dev/<WHATEVER>


3

Patch to limit badblocks to 2^32 There appears to have been a patch made for badblocks to add this particular limitation. See here, titled: Re: [PATCH 04/25] libext2fs: reject 64bit badblocks numbers. From: "Darrick J. Wong" <darrick.wong <at> oracle.com> Date: Wed, 23 Oct 2013 19:43:32 -0400 Subject: [PATCH] libext2fs: reject 64bit badblocks ...


2

The last few lines of that strace tell a fairly boring tale: badblocks opens the drive device, gets its size, closes it, reopens it and then goes off to do some work, which fails in some way strace doesn't show. You'd have to use gdb or similar to dig deeper. Your symptom may go away if you unmount the partition so badblocks has a stable thing to work on. ...


2

BtrFS can do "RAID1" with a single HDD. Meaning it will put a file twice across the disk. It also stores a checksum of each file, if one file becomes corrupted it can give you the other copy. Check out their wiki.


2

To make the drive to reallocate the sectors, you need to write something to them. However, dd (disk destroyer) does not always work, and is very unsafe: if you confuse the skip and seek, you can easily shoot yourself in the foot by seeking /dev/zero by N and write that to the sector 0 of your harddisk. If you really know you want to force the sector be ...


2

I have no exact answer to your question, but i know openmoko project which had badblocks support on s2410. http://wiki.openmoko.org/wiki/NAND_bad_blocks


2

Can the disk (ATA) be setup so that a failing read doesn't take too long, so that it can be dropped, and the reading process and the disk wouldn't be blocked, and the next read could be attempted? No. My understanding of this is that it's a logical problem resulting from a design choice (not unique to linux) that favours performance and stability for ...


2

Tell badblocks to use the larger block size and it will work above 2TB. I used this on a WD 6TB drive: badblocks -b 4096 -v /dev/sda


2

Letting badblocks write the pattern in the first place should be no slower than writing it any other way. Especially if you use the -b block-size and -c blocks-at-once options so it doesn't do small reads/writes. This example overwrites the disk with "random" pattern in 1MiB blocks: badblocks -v -w -t random -b 4096 -c 256 /dev/thedisk If there is a ...


2

First things first, you should check whether or not your process is still attached to your terminal. $ ps -eo comm,tty | grep fsck Now, if you can still see a TTY value next to your process, you can still get its output (from this TTY). You can get your current TTY's ID using tty. However, if there's a ? next to your process, I'm afraid you can't get its ...


2

If you really want to do this with dd, you need to split your reads up: dd if=/dev/sda bs=512 count=60515006 | gzip -9 > dump1.gz will dump the first 60515006 sectors of /dev/sda to dump1.gz, compressing with gzip. Then dd if=/dev/sda bs=512 skip=60517093 count=... | gzip -9 > dump2.gz will skip the failed part and dump the next however many ...


2

Here are the relevant excerpts for the same question which have been answered already at How do I choose the right parameters when using badblocks? and Using badblocks on modern disks. There is a badblocks benchmark script available that should suit your purpose. With regards to the -b option: this depends on your disk. Modern, large disks have 4KB blocks, ...


2

You need to add the -c option to do more than 64 blocks and probabky -b to specify a block size other than 1KiB. Right now you're doing 64KiB at a time, which is a lot of seeks. Something like: badblocks -c 2560 -b 4096 -wsv -t random /dev/«device» ought to run much faster. That's 10MiB (= 4KiB × 2560) at a time; go higher with -c if that's still not ...


2

You might be able to re-detect it without reboot, by unloading / re-loading the correct module (or just un-binding and re-binding the driver). For example: [ 978.527221] sd 11:0:0:1: [sdk] Attached SCSI removable disk #~> echo 11:0:0:1 > /sys/bus/scsi/drivers/sd/unbind #~> echo 11:0:0:1 > /sys/bus/scsi/drivers/sd/bind [ 5572.027119] sd 11:0:0:...



Only top voted, non community-wiki answers of a minimum length are eligible