I have an HDD bought a few years I have not touch since at least a year.When connecting it to my laptop, the drive does not appear in the drive list in the file explorer.I used fdisk to be sure it was connected and detected as /dev/sdb:berhthun@debian:~$ sudo fdisk -l[sudo] password for berhthun: Disque /dev/sda: 465,8 GiB, 500107862016octets, 976773168secteursUnits: secteur de 1  512 = 512octetsTaille de secteur (logique / physique): 512octets / 4096octetstaille d'E/S (minimale / optimale): 4096octets / 4096octetsType d'tiquette de disque: dosIdentifiant de disque: 0x0b1495d8Device     Boot    Start       End   Sectors   Size Id Type/dev/sda1  *        2048  40011775  40009728  19,1G 83 Linux/dev/sda2       40011776 976773167 936761392 446,7G  5 Extended/dev/sda5       40013824  56307711  16293888   7,8G 82 Linux swap / Solaris/dev/sda6       56309760 976773119 920463360 438,9G 83 LinuxDisque /dev/sdb: 465,7 GiB, 500074283008octets, 976707584secteursUnits: secteur de 1  512 = 512octetsTaille de secteur (logique / physique): 512octets / 512octetstaille d'E/S (minimale / optimale): 512octets / 512octetsType d'tiquette de disque: dosIdentifiant de disque: 0x00038e76Device     Boot Start       End   Sectors   Size Id Type/dev/sdb1        2048 976707583 976705536 465,7G 83 LinuxAfter lookin on the Internet, I tried to use mkfs command to format it:berhthun@debian:~$ sudo mkfs.ntfs /dev/sdb1[sudo] password for berhthun: Cluster size has been automatically set to 4096 bytes.Initializing device with zeroes: 100% - Done.Creating NTFS volume structures.Error writing to /dev/sdb1: Erreur d'entre/sortieError writing non-resident attribute value.add_attr_sd failed: Erreur d'entre/sortieCouldn't create root directory: Erreur d'entre/sortieFailed to fsync device /dev/sdb1: Erreur d'entre/sortieWarning: Could not close /dev/sdb1: Erreur d'entre/sortieberhthun@debian:~$ I went to gnome-disks, the HDD is also detected. Partition format is unknown. It tells me the disk have a 500 Go space and that's it.If I try to format the drive, it also tells me an error message:Erreur lors du formatage du disqueError creating file system: Command-line `parted --script /dev/sdb mktable msdos' exited with non-zero exit status 1: Error: Erreur d'entre/sortie during read on /dev/sdbError: Erreur d'entre/sortie during write on /dev/sdb (udisks-error-quark, 0)What can I do to make it work again ?Thank you for your help.Update after Stephen Kitt comment:When using dmesg I find the following errors about the hdd:[  748.613769] end_request: critical medium error, dev sdb, sector 976707456[  748.613777] Buffer I/O error on device sdb, logical block 122088432[  756.133563] end_request: critical medium error, dev sdb, sector 976707456[  756.133571] Buffer I/O error on device sdb, logical block 122088432[  868.845815] end_request: critical medium error, dev sdb, sector 976707456[  868.845821] Buffer I/O error on device sdb1, logical block 122088176[  945.172666] end_request: critical medium error, dev sdb, sector 976707456[  945.172674] Buffer I/O error on device sdb1, logical block 122088176[  975.727890] end_request: critical medium error, dev sdb, sector 976707456[  975.727898] Buffer I/O error on device sdb, logical block 122088432And so on.
Debian gnome-disks and mkfs can not format external hdd
debian;filesystems;hard disk
If the failing sectors are all at the end of the disk (976707456 and so on), you could use your disk with a shorter partition: delete sdb1 and re-create a partition that's one or two megabytes shorter.But I wouldn't trust such a disk: unless you use it for throwaway data, it's not worth the hassle and risk...