Clip out bad sectors

  • I have a 2TB Smasung F4 HDD with some bad blocks at the end. Encountered read/write errors while operating, and scanned with hdtune pro and a partition manager and confirmed there are 4-5 bad blocks on the drive. Due to its large size i still intened to use it for non-important media files which idont care about losing. Once a run a current hdtune pro scan and i get the current and up to date lba addresses of the bad blocks, how do i instruct the PC not to use those and keep the rest. This drive will then be used as part of a NAS system and formatted as ext4


    There are some youtube videos explaining how to dos this on DOS like environments but seem too complicated for me


    External Content www.youtube.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.


    I'd like to try this instead


    https://www.howtogeek.com/howt…-to-linux-disk-utilities/


    BTW Since i have my NAS without a screen and i communicate to console via putty, how can i run a command remotely and have it run without needing the computer to be open. Last time a tried command was executed for 5 hours and i shut down my laptop rnning putty cause i needed to go. How else can i do that

    • Official Post

    BTW Since i have my NAS without a screen and i communicate to console via putty, how can i run a command remotely and have it run without needing the computer to be open. Last time a tried command was executed for 5 hours and i shut down my laptop rnning putty cause i needed to go. How else can i do that

    Have a look for a program called "screen".
    https://www.howtoforge.com/linux_screen

  • Thanx i'll look into that


    But do you think running those commands will get things done?


    Does the following command check for errors? I already know i have bad vlocks so maybe it is of no use for me if its a read only command


    sudo badblocks -v /dev/sdb1


    So should i only hit those 2 lines


    sudo badblocks /dev/sdb > /home/zainul/bad-blocks


    sudo fsck -l bad-blocks /dev/sdb

    • Official Post

    badblocks was used when smart didn't exist. SMART automatically marks bad sectors and stops using them, every drives has some spare sectors to use when they go bad so they get replaced automatically. Once all spares are used then Offline uncorrectable starts to increase. Don't waste your time in this.....just keep using the drive if you don't care until it doesn't read sh*it.

  • I dont believe this to be true. Once i had content inside close to full, and somewhere on the end there where files that were unreasable. I deleted those files and wrote new ones. New ones were partially unreadable as well. IF SMART autocorrected drive functionally, once i had discrded of the first files, the newly acquired space should not have included that bad block wasted space. But somehow it did.

    • Official Post

    If you have uncorrectable then nothing smart can do because fs doesn’t know. You can use the badblocks as you said, in general people will get rid of the drive smart gives warning before the drives becomes unusable (bad blocks for most of the people is unusable)
    As you already know the scan takes several hours so if bad sectors are increasing at daily base then you will have to do it every day which wouldn’t be very practical.


    You don’t have to be logged in, you can use cron or log in and use screen or tmux to leave the job running.

  • But thats what i want SMART to do. MArk a sector as unusable once it finds it, instead of having to perform the command on a routine basis and have it run for hours. Otherwise whats the point of SMART knowing a sector is corrupt if its not doing anything about. And by doing something i dont mean correct it, i just mean mark it on the spot. Like instruct the drive not to store any files at that spot, and trim it live..

  • Like instruct the drive not to store any files at that spot, and trim it live..

    This can only be done at the filesystem layer and modern 'filesystems' that directly deal with disks (without additional layers like LVM or mdraid in between) can do here a much better job. You might want to read through this whole issue to get a deeper understanding of the challenges involved: https://github.com/zfsonlinux/zfs/issues/1256


    And of course SMART won't do anything here other than exposing drive metadata and allowing to access some drive parameters. And using disks with a daily growing list of hard persistent read errors is just insane...

  • Ok so anyway, formatted this bad disk as ext4 and put it inside my NAS. Since it is not permanently inside the system and i place it and eject it at will, two things happen that are unwanted.


    -First when its not inside, the startup procedure gets delayed while fsck looks for it for 1:30min to check it and cannot find it
    -If it is inside the system at boot, fsck locates bad blocks and enters some emergency mode


    How can disable the system startup fsck for this disk. I know it is defected and i dont want to run checks that cause delays

  • Anyway so setting the 6th field to zero, and adding the 'nofail switch (which already existed) did nothing. I had to completely remove the line that mentioned the drive on the fstab file to skip the check. But now i cannot mount the drive at all anymore. Inside the webui one i hit mount it says it did not find the drive inside the fstab

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!