0

Here is my situation :
I have an external hard drive of 320Gb.
The drive is plugged using a disk docking, and mounts automatically when started.
I can explore the directory tree, read and write in the mounted partition.

The mounted partition seems to be FAT32 ("seems" cause I can't find the information).

My goal is to erase the disk, and create a new exFat partition. I did not succeed to achieve this.
I tried formating the disk with gnome-disks : Error synchronizing after initial wipe: Timed out waiting for object (udisks-error-​quark, 0)
I tried gparted and on startup it says end of file while reading /dev/sdb” and then show that the disk is unallocated of size 512B.

Note that I immediately made a backup.
I also tried to connect the disk using different dockings.

I read many threads about hard drive problematics, but didn't find one where someone is the same situation, so before starting messing up I'd like to get some advices as I am definitely not skilled there.

Here is some informations :

What dmesg gives me when I plug the disk :

$ sudo dmesg
[72866.922181] usb 1-2: new high-speed USB device number 39 using xhci_hcd
[72867.074593] usb 1-2: New USB device found, idVendor=059f, idProduct=0828, bcdDevice= 0.00
[72867.074601] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[72867.074605] usb 1-2: Product: d2 Quadra
[72867.074609] usb 1-2: Manufacturer: LaCie   
[72867.074613] usb 1-2: SerialNumber: 00D04B7A10097C8E
[72867.082929] usb-storage 1-2:1.0: USB Mass Storage device detected
[72867.084025] scsi host2: usb-storage 1-2:1.0
[72867.086319] input: LaCie    d2 Quadra as /devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.1/0003:059F:0828.0008/input/input25
[72867.147133] hid-generic 0003:059F:0828.0008: input,hidraw1: USB HID v1.11 Device [LaCie    d2 Quadra] on usb-0000:00:15.0-2/input1
[72868.096079] scsi 2:0:0:0: Direct-Access     ST332082 0AS              3.AA PQ: 0 ANSI: 4
[72868.099156] sd 2:0:0:0: Attached scsi generic sg1 type 0
[72868.101805] sd 2:0:0:0: [sdb] 625142448 512-byte logical blocks: (320 GB/298 GiB)
[72868.102191] sd 2:0:0:0: [sdb] Write Protect is off
[72868.102193] sd 2:0:0:0: [sdb] Mode Sense: 10 00 00 00
[72868.104502] sd 2:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[72868.121742]  sdb: sdb1
[72868.123517] sd 2:0:0:0: [sdb] Attached SCSI disk

The partition is mounted at /media/user/BACKUP :

$ lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda            8:0    0 111,8G  0 disk 
└─sda1         8:1    0 111,8G  0 part /home
sdb            8:16   0 298,1G  0 disk 
└─sdb1         8:17   0 298,1G  0 part /media/user/BACKUP
mmcblk0      179:0    0  29,1G  0 disk 
├─mmcblk0p1  179:1    0   512M  0 part /boot/efi
├─mmcblk0p2  179:2    0  27,7G  0 part /
└─mmcblk0p3  179:3    0   976M  0 part [SWAP]
mmcblk0boot0 179:256  0     4M  1 disk 
mmcblk0boot1 179:512  0     4M  1 disk 

This is telling me that the partition is FAT32 :

$ cp ~/movies/BigMovie.mkv /media/user/BACKUP/BigMovie.mkv 
cp: error writin '/media/user/BACKUP/BigMovie.mkv': File too large

ls -l /media/user/BACKUP/ 
total 4194368
-rw-r--r--  1 user user 4294967295 juin  29 10:51 BigMovie.mkv

The (non-existent) partition table on parted (or using fdisk) :

$ sudo parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
                                                                          
(parted) print
Model:  (file)
Disk /dev/sdb: 512B
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End  Size  Type  File system  Flags

                                                                          
(parted)

$ sudo fdisk /dev/sdb
Commande (m pour l'aide) : p
Disque /dev/sdb : 512 B, 512 octets, 1 secteurs
Unités : secteur de 1 × 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 512 octets
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
Type d'étiquette de disque : dos
Identifiant de disque : 0xfd445558

I've tried anyway to alterate the partition scheme with fdisk :

$ sudo fdisk /dev/sdb
# trying a dos partition table
Command (m for help): o
Created a new DOS disklabel with disk identifier 0x98d9e56d.

# at this point it seems alreayd lost
Command (m for help): n
All space for primary partitions is in use.

Command (m for help): w
The partition table has been altered.
Syncing disks.

# nothing changed
Command (m for help): p
Disk /dev/sdb: 512 B, 512 bytes, 1 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x98d9e56d

# trying GPT
Command (m for help): g
Created a new GPT disklabel (GUID: 9E30965C-889B-A249-B6D7-71580BCE1CBE).

Command (m for help): n
Partition number (1-128, default 1): 
First sector (34-18446744073709551583, default 34): 
Last sector, +/-sectors or +/-size{K,M,G,T,P} (34-18446744073709551583, default 18446744073709551583): 

# 16 EiB ? I'd like too !
Created a new partition 1 of type 'Linux filesystem' and of size 16 EiB.

# as expected
Command (m for help): w
fdisk: failed to write disklabel: Invalid argument

Thanks for your help !

T3e
  • 101
  • 3
  • is there some data on disk you need to save or you just want to erase everything and create new partition? – Shah Fahad Jun 29 '21 at 10:53
  • Everything is backed up, so erasing all is ok. – T3e Jun 29 '21 at 11:06
  • I think the problem is with your partition table but just to be sure check with another tool `fdisk`. Run `sudo fdisk /dev/sdb` and in interactive mode use the `p` command. – Shah Fahad Jun 29 '21 at 11:09
  • I edited my message with the results of `sudo fdisk /dev/sdb`, but I don't find it more relevant. – T3e Jun 29 '21 at 11:23

2 Answers2

0

You can use fdisk. Assuming you disk is /dev/sdb, run sudo fdisk /dev/sdb and in interactive mode use the option g to create a gpt partition table or o to create a dos partition table. After that create a new partition using the command n, by default it creates a partition with partition type Linux Filesystem, you can change that using the t option and then selecting Microsoft basic data as the partition type, then use the p option to see the final partition layout, then use the w option to write changes to the disk. Now after that you can use the command sudo mkfs.exfat /dev/sdb1 to format the partition as exfat. Finally you can once again use the command sudo fdisk /dev/sdb and then p option to make sure everything is correct and after that you can mount the partition wherever you want.

Shah Fahad
  • 167
  • 6
  • I edited my message with the results of the `fdisk` procedure. It looks like fdisk is lost with that disk. – T3e Jun 29 '21 at 11:51
  • Try to zero out the first sector of disk, use `dd if=/dev/null of=/dev/sdb bs=512 count=1` and then move forward and see what happens. Make sure disk is unmounted – Shah Fahad Jun 29 '21 at 11:57
0

I followed Shah Fahad instructions and after running dd if=/dev/null of=/dev/sdb bs=512 count=1, I tried again to format the drive :

$ sudo fdisk /dev/sdb
fdisk: unable to open /dev/sdb: No such file or directory

Google guided me to this guided me to this answer : https://unix.stackexchange.com/a/56519/267558 and reboot fixed my problem.

So it looks like that trying to get things up, I had unfortunately unmounted /dev/sdb ...

I hope dd didn't broke anything.

T3e
  • 101
  • 3
  • why would `dd` break anything? It was removing the partition table on your disk. In the comment above i meant to say: make sure partition is unmounted – Shah Fahad Jun 29 '21 at 12:46
  • The partition was unmounted. I don't really know how `dd` works, for me it looks like that I have written data on `/dev/sdb` while `/dev/sdb` was not pointing to the drive. So where did the data was written ? Hope nowhere important. That is my worry. – T3e Jun 29 '21 at 13:07
  • `dd` does not need a partition to be mounted to write to it. It works at block level. It is highly likely that the data was written to your drive i.e `/dev/sdb` because `dd` would have thrown an error if it was not able to write. Also by doing this your `dos partition table` was cleared, which was creating problem while creating new partition table. Thus when you rebooted you got a completely erased disk. – Shah Fahad Jun 29 '21 at 13:44