Ubuntu – Can’t mount SATA drives when moved from USB enclosure to internal

ext4hard drivemountsataUbuntu

I have had 4 external drives connected over USB to my Dell Precision 490 workstation.

They are in /etc/fstab by uuid and formated as UUID.

UUID=04c37bff-b93e-440e-acd0-3d984ddb2ec3 /mnt/drive0 ext4 defaults,nobootwait 0 2
UUID=210765f4-30e5-4863-a40b-aa1fffefe5ca /mnt/drive1 ext4 defaults,nobootwait 0 2
UUID=b981c5e7-249e-4430-9887-96ca674e0733 /mnt/drive2 ext4 defaults,nobootwait 0 2
UUID=22c8a274-3cf9-403f-9558-feb531e407c7 /mnt/drive3 ext4 defaults,nobootwait 0 2

I put three drives inside but only one mounts automatically (drive3, drive2 is still connected externally)

$ mount | grep /dev/sd
/dev/sdc1 on /boot type ext2 (rw)
/dev/sdb1 on /mnt/drive3 type ext4 (rw)
/dev/sdf1 on /mnt/drive2 type ext4 (rw)

But they all show up:

$ sudo fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.


Disk /dev/sda: 120.0 GB, 120034123776 bytes
<snip>

Disk /dev/sdb: 5001.0 GB, 5000981078016 bytes
255 heads, 63 sectors/track, 608001 cylinders, total 9767541168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xdd494cbf

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1  4294967295  2147483647+  ee  GPT
Partition 1 does not start on physical sector boundary.

Disk /dev/sdd: 5001.0 GB, 5000981078016 bytes
42 heads, 62 sectors/track, 3750975 cylinders, total 9767541168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xec15dda8

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1             256  1220942644   610471194+  83  Linux

Disk /dev/sde: 5001.0 GB, 5000981078016 bytes
255 heads, 63 sectors/track, 608001 cylinders, total 9767541168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x4cd5215a

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1              63  1220942644   610471291   83  Linux
Partition 1 does not start on physical sector boundary.

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
<snip>

Disk /dev/sdf: 5001.0 GB, 5000981073920 bytes
255 heads, 63 sectors/track, 76000 cylinders, total 1220942645 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x6b6805d9

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1              63  1220942644   588803032   83  Linux

$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sdb  /dev/sdb1  /dev/sdc  /dev/sdc1  /dev/sdc2  /dev/sdc5  /dev/sdd  /dev/sdd1  /dev/sde  /dev/sde1  /dev/sdf  /dev/sdf1

If I try to mount normally:

$ sudo mkdir /mnt/temp
$ sudo mount -t ext4 /dev/sde1 /mnt/temp                                                                                                    
  mount: wrong fs type, bad option, bad superblock on /dev/sde1,
   missing codepage or helper program, or other error
   In some cases useful info is found in syslog - try
   dmesg | tail  or so
$ dmesg | tail
[87143.301150] EXT4-fs (sde1): VFS: Can't find ext4 filesystem
[87295.537835] EXT4-fs (sde1): VFS: Can't find ext4 filesystem
[87315.780147] EXT4-fs (sde1): VFS: Can't find ext4 filesystem
[87315.780290] EXT4-fs (sde1): VFS: Can't find ext4 filesystem
[87315.780421] EXT4-fs (sde1): VFS: Can't find ext4 filesystem

The machine has 5 SATA ports, I also bought a PCIe SATA controller and tried that. No difference. Moving devices between ports still yields no difference. The two other drives always mount.

I put them back in their respective external cases with USB controllers and they worked. Although when I tried to use the case from one of the drives that did mount directly connected, it was not recognized.

Thanks!

Edit: Adding output from gdisk

$ sudo gdisk /dev/sde
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************


Command (? for help): p
Disk /dev/sde: 9767541168 sectors, 4.5 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 00C22148-8C82-4062-BEC5-6759E7E23856
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 9767541134
Partitions will be aligned on 8-sector boundaries
Total free space is 8546598519 sectors (4.0 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              63      1220942644   582.2 GiB   8300  Linux filesystem

$ sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sdb: 9767541168 sectors, 4.5 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): E76C335B-FBA1-4FE0-9DC2-C5CADBECA6B0
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 9767541133
Partitions will be aligned on 8-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34      9767541133   4.5 TiB     8300  disk4

Interesting, looks like the disks that don't mount use MBR instead of GPT?

Best Answer

This sounds like the problem described at https://superuser.com/questions/679725/how-to-correct-512-byte-sector-mbr-on-a-4096-byte-sector-disk: the USB enclosures reported a different sector size than the motherboard, and as result the partition tables are interpreted differently.

I had a similar problem with a 4TB disk that I had moved from a USB enclosure to an internal SATA port. Apparently the USB enclosure had reported 4k sectors, and thus I was able to use an old-fashioned MBR partition table to create a 4TB ext4 partition. After connecting the disk via SATA, the ext4 partition wasn't found any more, apparently because the disk was accessed with 512B sectors now.

I got it solved with the following steps, using the Testdisk data recovery tool which is available in Ubuntu:

  • created a backup of the original partition table (sfdisk -d /dev/sdb > sfdisk-sdb.txt), for safety
  • used testdisk /dev/sdb to find the original ext4 file system
  • let testdisk write a new MBR partition table to disk
  • since MBR table doesn't support 4TB partitions, the ext4 partition still couldn't be mounted, with error EXT4-fs (sdb1): bad geometry: block count 976751744 exceeds size of device (536870911 blocks)
  • used gdisk /dev/sdb to convert the MBR to GPT format, and write the GPT to disk
  • used testdisk /dev/sdb again to find the original ext4 file system (it detected the wrong file system type but that didn't matter), and let it write a new GPT table to disk
  • used gdisk /dev/sdb to change the incorrectly detected file system type to 8300

Maybe I just got lucky, but after this procedure the ext4 file system could be mounted as usual. fsck -f /dev/sdb1 didn't detect any errors, and blkid /dev/sdb1 and tune2fs /dev/sdb1 gave same results as when using the USB enclosure.

Related Topic