Not able to format an external USB harddrive on RHEL 6.9

Latest response

A USB harddrive with 1TB size was attached to the RHEL 6.9 server, however, the drive is recognised by the OS, but it cannot be formatted for some reason even after a number of reboot.

Please kindly advise how we can format this attached USB harddisk, attached please find the relevant screenshots for your investigation. Thank you for your attention on this matter.

Attachments

Responses

Hi ! :)

  • First identify the USB drive - execute : sudo parted -l
  • Unmount the USB drive - execute : sudo umount /dev/sdX
  • Prepare the USB drive - execute : sudo fdisk /dev/sdX
  • Press "n" and Enter | Press "p" and Enter | Press "w" and Enter
  • Format the USB drive - execute : sudo mkfs.vfat /dev/sdXY

Note : Replace 'X' with the letter of the USB disk you've identified with the first command.
Replace 'Y' with the partition number (partition you've created before - usually number 1).
The last command formats the disk with FAT32, the commonly used format for USB disks.
Replace mkfs.vfat with mkfs.ext4 or mkfs.ntfs, if you want one of those formats.

If this (for whatever reason) doesn't work - download GParted, write the ISO file to a CD/DVD or USB stick.
Boot from the created medium and format the external USB drive from within the GParted GUI application.
First create a new partition table and then create a new partition and format the partition with a file system.
Be extremely careful with what you're doing - double-check everything before you run the given commands.

Regards,
Christian

Yes, check if you could fix the issue as Christian mentioned before, otherwise, please show the following command outputs:

- lsblk
- df -PTh
- fdisk -l /dev/sdj
- pvs
- vgs
- lvs
- lsof /dev/sdj

For the original poster who goes by "IT Support"

To mount the drive (and since it is an external drive), once it's successfully formatted, make a directory such as /1tb to mount it when needed.

/bin/mkdir -p /1tb/notmounted

I use the -p so that you can make an additional subdirectory named "notmounted". This creates a mountpoint named "1tb" and you can mount it there. You can pick whatever directory name you wish of course.

After the drive is successfully created/formatted as explained by Christian and Sadashiva, you can mount it using the UUID or device name.

You can get the device name using the command fdisk -l and make note of the drive that seems to be 1tb in size, and with a device name that comes after your previously existing drives.

You can also run the command blkid and make note of the drive's "UUID" number. Let's say for the sake of discussion, your device name is /dev/sdb1 for your new external drive (it may certainly be different and the UUID will certainly be different).

 ~]# blkid
/dev/sdb1: UUID="7fa9c421-0054-4555-b0ca-b470a97a3d84" TYPE="ext4"

You can mount the drive using one of the below commands (again, your drive's UUID will be different).

/bin/ls /1tb
notmounted

This ls command above shows the sub-directory named notmounted which is in the path /1tb/notmounted if you used the suggestion I provided earlier

Now to mount it

mount UUID="7fa9c421-0054-4555-b0ca-b470a97a3d84"  /1tb
ls /1tb
Lost+Found

You will no longer see the subdirectory named notmounted after the drive successfully mounts

Alternatively you can use the device name to mount the drive, this assumes a device name of /dev/sdb1, it may be different on your system:

mount /dev/sdb1 /1tb
ls /1tb
Lost+Found

Diagnosing a failed mount

  • Use the root account to perform any necessary partitioning,formatting, mount/umount commands.
  • Pay attention to the output from commands that will give some clues to failed mount, such as "mount: mount point /1tb does not exist"
  • Make sure you properly created the partitioned on the drive as explained earlier by Christian and Sadashiva
  • Make sure you properly formatted the drive as explained earlier by Christian and Sadashiva
  • Make sure you created a mount point (directory) using the /bin/mkdir command explained earlier.
  • Make sure the external drive is plugged in to power, and is turned on if necessary
  • If necessary, reboot the system so that the system can "see" the new partition and (only if necessary) redo the format as explained earlier by Christian and Sadashiva (if and only if the drive is not formatted)
  • Using the blkid command will show active file systems, if you do not see your new drive you partitioned and formatted, you may need to revisit steps above.

  • Come back here for assistance as needed, please let us know how it goes and thanks Christian and Sadashiva

Since this is an external drive, you probably do not want to make a persistent entry into your /etc/fstab file, but mount the drive as needed after connecting it to your system. (Note, a RHEL 7.x (current RHEL7 system ought to just "pick up" the external drive and mount it under /run/media/home/youruserid/[device_name_or_uuid] automatically)

Kind Regards, RJ

Hi RJ,

Thanks for your (as always) useful information. Let me add something that I forgot to mention before.
In case "IT Support" selects ntfs as format for the external drive, he needs to install some packages.
sudo yum install ntfs-3g ntfsprogs, otherwise he won't be able to read and write the data. :)

Regards,
Christian

Thank you for everyone's comment and contribution.

Upon further investigation by our consultant, the issue was due to the drive was automatically mounted by the multipathing configuration after the server reboot, hence the drive initializing had failed.

And we have to unmount it with using the mathipathing command in addition to the regular umount command as a resolution.

Unfortunately I had not been noting down the exact command as it was involved with several steps. I will see if I can find anything and re-post it here.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.