Storage Solutions Network Drive error

LaatSahab

Skilled
I have a Seagate 2 TB drive (almost 12 years old) connected to my Raspberry Pi and shared on network as a Samba share. It's ext4 partition. It is also my seedbox drive. After a power outage today when I rebooted the system, some folders have gone missing, some older deleted ones have resurfaced and it's accessible over the network anymore, plus nothing is being allowed to be written on it. I'm even unable to check it's health as it's not being listed by drive listing commands, only the fstab shows it's entry. Beyond that I'm unable to check it for errors, let alone salvage anything from it.
 
some folders have gone missing, some older deleted ones have resurfaced and it's accessible over the network anymore, plus nothing is being allowed to be written on it.

This looks like a journal update/corruption issue, I guess you already know this but I am including just for information completeness, When we add/delete the folders/files the ext4 system will make a journal entry regarding the same, sometime the journal will get corrupted and it may have not been updated properly and so reflect the old state. There is also the possibility of the new ones never getting updated on the hard disk in the first place(they might have been in the cache waiting for wire but never got it)

I'm even unable to check it's health as it's not being listed by drive listing commands, only the fstab shows it's entry. Beyond that I'm unable to check it for errors, let alone salvage anything from it.
I think the drive is mounted read-only due to it failing the filesystem check. You can verify that by running the mount command, it will show if the drive is mounted read-only.
If you can try to check the drive at a different system and see if that fixes file/folder issue, If that fails then you need to run fsck and check/fix for file system corruption and then you can remount it as usual.
 
When I hooked the drive to other system(s) it was detected by the OS (Win 7 and 11) but neither mounted it by assigning it a drive letter. Will report back here with output of mount command.
 
I have no idea about windows(OS) but I think they cant read ext4 file system, may be that is the reason? It is worth checking that too. Sure do please most mount command output and also dmesg output, just the part on hdd will do.

Also check if there is any entries in the log files on the first boot after crash to get some clues.
 
running sudo mount -l gave a whole bunch of entries out of which I found this to be the relevant one for case at hand.
/dev/sda1 on /mnt/WD type ext4 (rw,nosuid,nodev,noexec,relatime)

Edit:- I had disconnected the drive for 4-5 hours and now when I reconnected it and rebooted the Pi, it's working normally. Is there anyway to check it's health now and repair it if any issues are there?
Also tried running smartctl on it, below is the result
Code:
pi@rpi4:~$ sudo smartctl -a /dev/sda1
smartctl 6.6 2017-11-05 r4594 [aarch64-linux-5.10.103-v8+] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Vendor:               Seagate
Product:              FA GoFlex Desk
Revision:             0155
User Capacity:        2,000,398,933,504 bytes [2.00 TB]
Logical block size:   512 bytes
Serial number:        NA0KVWAV
Device type:          disk
Local Time is:        Fri Oct 14 19:50:09 2022 IST
SMART support is:     Unavailable - device lacks SMART capability.

=== START OF READ SMART DATA SECTION ===
Current Drive Temperature:     0 C
Drive Trip Temperature:        0 C

Error Counter logging not supported

Device does not support Self Test logging
 
Last edited:
It appears the hdd is mounted read-write so it sould be writable, what happens if you do "touch test_file /mnt/WD"
And also is there any log messages? Also can you list what is in the /etc/fstab for this mount point, also check the folder permision(owner,group,etc) on /mnt/WD just to be safe
Try to unmount and remount it, just incase and see if there is any error messages.
 
It appears the hdd is mounted read-write so it sould be writable, what happens if you do "touch test_file /mnt/WD"
And also is there any log messages? Also can you list what is in the /etc/fstab for this mount point, also check the folder permision(owner,group,etc) on /mnt/WD just to be safe
Try to unmount and remount it, just incase and see if there is any error messages.
Doing the "touch" does nothing, neither on the drive nor on screen, no error message nothing. Rummaging around I found that it created the test file at /home/pi/ . The fstab entry is below
Code:
pi@rpi4:~$ cat /etc/fstab
proc            /proc           proc    defaults          0       0
PARTUUID=8a66865c-01  /boot           vfat    defaults          0       2
PARTUUID=8a66865c-02  /               ext4    defaults,noatime  0       1
PARTUUID=61632238-01 /mnt/WD ext4 defaults,auto,users,rw,nofail 0 0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
Yesterday GParted wasn't even detecting the external drive, today it was so went ahead with GUI route and umounted the drive and "checked" it through there.
Code:
GParted 0.32.0 --enable-libparted-dmraid --enable-online-resize

Libparted 3.2
Check and repair file system (ext4) on /dev/sda1  00:02:00    ( SUCCESS )
        
calibrate /dev/sda1  00:00:00    ( SUCCESS )
        
path: /dev/sda1 (partition)
start: 63
end: 3907024127
size: 3907024065 (1.82 TiB)
check file system on /dev/sda1 for errors and (if possible) fix them  00:02:00    ( SUCCESS )
        
e2fsck -f -y -v -C 0 '/dev/sda1'  00:02:00    ( SUCCESS )
        
Pass 1: Checking inodes, blocks, and sizes
Inode 52690949 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52690955 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690957 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52690959 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52690961 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690962 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690964 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52690965 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52690966 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690967 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690968 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690970 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52690971 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690972 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690973 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690974 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690979 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690985 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52690996 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52690998 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52690999 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691000 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691001 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691018 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691031 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691034 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691041 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691043 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691173 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691325 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691349 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691401 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691447 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691456 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691549 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691568 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691574 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691577 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691578 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691590 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691661 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691917 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691929 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691932 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691936 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691944 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52691946 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52691954 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692013 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692052 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692056 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692060 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692068 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692071 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692085 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692103 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692241 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692249 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692250 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692255 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692257 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692261 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692262 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692263 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692268 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692597 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692608 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692665 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692672 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692711 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692713 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692721 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692722 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692723 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692724 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692728 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692810 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692816 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692829 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692830 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692831 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692833 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692834 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692835 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692836 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692837 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692838 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52692839 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52692840 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693027 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693070 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693388 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693391 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52693393 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52693394 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52693395 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693396 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52693399 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52693400 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693401 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693643 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52693649 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52693669 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693680 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693703 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693704 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52693799 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52693825 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694059 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52694060 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52694105 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52694107 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52694108 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52694109 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694110 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694111 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694112 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52694114 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694115 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694117 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52694130 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694163 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694172 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694276 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694277 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694279 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694280 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694282 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52694314 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694315 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694318 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694320 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694327 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694333 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694343 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694354 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694355 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694356 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694358 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694359 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694360 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694362 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694383 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694384 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694385 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694386 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694387 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694388 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694389 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694390 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52694391 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52695837 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52695838 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52695854 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52696117 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52696118 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52696119 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52696120 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52696124 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52696834 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52696836 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52822017 extent tree (at level 2) could be narrower. Optimize? yes

Inode 52953118 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52953146 extent tree (at level 1) could be narrower. Optimize? yes

Inode 52953580 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53084172 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53084510 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53084709 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53084899 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085147 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53085160 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085164 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085165 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53085166 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085295 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53085386 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085410 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53085424 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085455 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53085575 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085661 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53085699 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085720 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085749 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085781 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085828 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085883 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085903 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085913 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53085963 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086001 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53086077 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086124 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086148 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086197 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086219 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086227 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086241 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086246 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53086251 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53086254 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086264 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086269 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086272 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086295 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53086312 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086320 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086346 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086347 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53086377 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086386 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086387 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086400 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086403 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086470 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086474 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53086477 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53086484 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086529 extent tree (at level 2) could be narrower. Optimize? yes

Inode 53086533 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53086546 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53215253 extent tree (at level 1) could be narrower. Optimize? yes

Inode 53215358 extent tree (at level 1) could be narrower. Optimize? yes

Pass 1E: Optimizing extent trees
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found. Create? yes

Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/sda1: ***** FILE SYSTEM WAS MODIFIED *****

14701 inodes used (0.01%, out of 122101760)
6850 non-contiguous files (46.6%)
13 non-contiguous directories (0.1%)
# of inodes with ind/dind/tind blocks: 0/0/0
Extent depth histogram: 11443/3122/127
356008820 blocks used (72.90%, out of 488378008)
0 bad blocks
195 large files

13816 regular files
875 directories
0 character device files
0 block device files
0 fifos
0 links
0 symbolic links (0 fast symbolic links)
0 sockets
------------
14691 files
e2fsck 1.44.5 (15-Dec-2018)
grow file system to fill the partition  00:00:00    ( SUCCESS )
        
resize2fs -p '/dev/sda1'  00:00:00    ( SUCCESS )
        
resize2fs 1.44.5 (15-Dec-2018)
The filesystem is already 488378008 (4k) blocks long. Nothing to do!

========================================
Even now it's throwing errors in some torrents I'm downloading after a certain random time. Doing a Recheck from the Deluge isn't fixing anything.
 
Edit:- I had disconnected the drive for 4-5 hours and now when I reconnected it and rebooted the Pi, it's working normally. Is there anyway to check it's health now and repair it if any issues are there?
Also tried running smartctl on it, below is the result
I believe this to be an external hdd, in that case SMART tools wont work due to the number of controllers on the way, in this case it is usb to uas to scsi to sat to sata and we can be sure that most of them wont be implementing all the features of the underlying hardware so even if the hdd is capable of self monitoring that information will never reach the OS :(

From what you have said, I believe the power crash had messed the head(may it was writing something at that time and had crashed on the sectors). There are few things that we need to take into account,
1. HDD will self repair badblocks 99% of the time, if that didn't happen then either they are full and have no replacement sectors to map or the controller is unware of the bad sectors.
2. If the case is later, then we can run a badblock program and create a list of badblocks and use hdparm to write to that sector therby making the controller aware of badblocks
2.1 badblocks command : badblocks -v /dev/sda1 > ~/badblocks-list.txt (assuming /dev/sda1 is the hdd)
2.2 hdparm command hdparm --repair-sector (sector number from the output of badblocks, one sector at a time)

Note, the badblocks scan will take a lot time to finish.

Doing the "touch" does nothing, neither on the drive nor on screen, no error message nothing. Rummaging around I found that it created the test file at /home/pi/
That is my mistake I forgot to include the trailing "/" at touch test_file /mnt/WD/
This will create a file at /mnt/WD/ called test_file. I am sorry for the confusion and mistake.

The fstab entry is below
Code:
pi@rpi4:~$ cat /etc/fstab
proc            /proc           proc    defaults          0       0
PARTUUID=8a66865c-01  /boot           vfat    defaults          0       2
PARTUUID=8a66865c-02  /               ext4    defaults,noatime  0       1
PARTUUID=61632238-01 /mnt/WD ext4 defaults,auto,users,rw,nofail 0 0

[/QUOTE]
FSTAB looks good, the trailing 0 0 says no fscheck, enabling them will check the disk for errors at boot time and it will rebuild the journel/filesystem/recover the files/etc but will take a log time to boot, If you ask me it is a tradeoff that is worth considering.

[QUOTE="LaatSahab, post: 2407670, member: 21401"]
Yesterday GParted wasn't even detecting the external drive, today it was so went ahead with GUI route and umounted the drive and "checked" it through there.
Code:
Check and repair file system (ext4) on /dev/sda1  00:02:00    ( SUCCESS )
    
calibrate /dev/sda1  00:00:00    ( SUCCESS )
     
path: /dev/sda1 (partition)
start: 63
end: 3907024127
size: 3907024065 (1.82 TiB)
check file system on /dev/sda1 for errors and (if possible) fix them  00:02:00    ( SUCCESS )
     
e2fsck -f -y -v -C 0 '/dev/sda1'  00:02:00    ( SUCCESS )
     
Pass 1: Checking inodes, blocks, and sizes
-snip-
Pass 1E: Optimizing extent trees
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found. Create? yes
Pass 4: Checking reference counts
Pass 5: Checking group summary information

/dev/sda1: ***** FILE SYSTEM WAS MODIFIED *****
[/QUOTE]
Everything looks good here, nothing to worry about

[QUOTE="LaatSahab, post: 2407670, member: 21401"]
14701 inodes used (0.01%, out of 122101760)
6850 non-contiguous files (46.6%)
13 non-contiguous directories (0.1%)
# of inodes with ind/dind/tind blocks: 0/0/0
Extent depth histogram: 11443/3122/127
356008820 blocks used (72.90%, out of 488378008)
0 bad blocks
195 large files

13816 regular files
875 directories
0 character device files
0 block device files
0 fifos
0 links
0 symbolic links (0 fast symbolic links)
0 sockets
------------
14691 files
e2fsck 1.44.5 (15-Dec-2018)
grow file system to fill the partition  00:00:00    ( SUCCESS )
     
resize2fs -p '/dev/sda1'  00:00:00    ( SUCCESS )
     
resize2fs 1.44.5 (15-Dec-2018)
The filesystem is already 488378008 (4k) blocks long. Nothing to do!
[/QUOTE]
[/QUOTE]
Few observations,
1. The disk is using almost 75% of available sectors 356008820 blocks used (72.90%, out of 488378008) and it appers the average sector usage of each file is ~25767(with folders ~24233), which means the number of spare sectors on the drive may be low and as a result the controller may be having hardtime remapping the sectors.
2. 4K blocksize is good if your files are smaller but in your case you can increase the size if all your files are of large size. Point to note is, if you increase the block size and more blocks go bad then you will loose a lot of disk space though, please that that into consideration.


Even now it's throwing errors in some torrents I'm downloading after a certain random time. Doing a Recheck from the Deluge isn't fixing anything.
I think it has nothing to do with deluge, it has more to do with the current state of the harddisk, I believe the harddisk controller has not foundout all the badsectors and has not remapped them.
 
It took almost 2 days but finally the Badbloacks command ran to completion.
Code:
pi@rpi4:~$ sudo badblocks -v /dev/sda1 >~/badblocks-list.txt
Checking blocks 0 to 1953512031
Checking for bad blocks (read-only test): done                                 
Pass completed, 5385 bad blocks found. (5385/0/0 errors)
pi@rpi4:~$
And the output file is attached below.
Now what would be the syntax of hdparm command to check badblocks mentioned in the list, I'm assuming we have to pipe the input but how so exactly ?
 

Attachments

  • badblocks-list.txt
    57.8 KB · Views: 70
Good Morning,
Few things to note,
1. When we use the hdparm with --repair-sector it will write 0x0 to the sector and will force the hdd to fix that badblock by remapping a free sector
2. If there is no free sector(possiblility is in single digits though) it will be marked as bad and the controller will omit the sector from that time forward
3. If the second point turns out to be true you will be loosing disk capacity but the controller will still be reporting 2TB so plan accordingly
4. If these bad sectors are part of some files then those files will have recovery issues. Re-checking the files will help in redownloading the missing/corrupt sections.

Said that,
Fixing the sectors is a one sector at a time job so each sector has to be piped using a script of your choice. I have included a bash script for reference

Bash:
#!/bin/bash

File_Name="badblocks-list.txt"

while read -r bad_block; do
    hdparm --repair-sector $bad_block --yes-i-know-what-i-am-doing /dev/sda
    sleep 2
done <$File_Name

I have included "sleep 2" to give the hdparm time to finish the write command, you can increase the time(in seconds) as you see fit.

Man page for hdparm: https://www.man7.org/linux/man-pages/man8/hdparm.8.html

Hope this helps

Edit 1: Changed /dev/sdb to /dev/sda
 
Last edited:
Back
Top