Getting an “is not a block special device.” error when trying to mount an 8TB disk in CentOS 7.6
Your device might already have been partitioned and have a file system. You may need to first get rid of everything.
Use fdisk
on the disk itself, /dev/sdc
rather than on the partition
/dev/sdc1
:
sudo fdisk -cu /dev/sdc
If you have any existing partitions, first delete them using the command d
,
and finally w
to write the partition table and exit.
Reissue fdisk -cu /dev/sdc
and use n
to create a new partition with
maximum size and w
again.
Check that everything is correct using fdisk -lu /dev/sdc
.
You may finally format the new partition:
sudo mke2fs -t ext4 /dev/sdc1
Or alternatively:
sudo mkfs.ext4 /dev/sdc1
My guess is you had created a regular file there somehow (or maybe a symlink to such file). Check it. If it was a block device then in the output of
ls -l /dev/sdc1
the first letter would be b
; additionally
file /dev/sdc1
would say block special
. If this is not the case, investigate what the object really is. It probably shouldn't be there in the first place. Note mounting a regular file uses a loop device, this fits your case.
If the object is indeed a regular file or a symlink, umount
it, then remove (rm
) or move (mv
) it out of the way. Keep in mind mke2fs
operated on the file, so if you already put any important data in the filesystem, it's in the file, not in the partition.
To recreate a proper /dev/sdc1
as a block device, invoke sudo partprobe
. This assumes there is no problem with /dev/sdc
and its partition table. You should also invoke mke2fs
again because the partition wasn't even touched by your previous mke2fs
.
A plausible cause of having a regular file there is writing an image file to /dev/sdc1
without making sure the target exists (normally as a block device). Such operation on an nonexistent target creates a regular file.
If the problem reappears (like after reboot, after connecting the external drive again) it means something recreates the file. This may be due to some poorly written script that assumes /dev/sdc1
always exists. Be warned such script can overwrite your actual partition when the drive is connected. Hopefully there is no script at all and the whole problem is because of one-time mishap as described above.