Score:0

How to mount an external hard drive when it disappeared after formatting it to ext4 with parted?

mo flag

I have a 'My passport' external hard drive that I wanted to format to EXT4 to use for Linux Ubuntu 22.04.

The drive is almost empty but has a few files by default that I didn't mind keeping, so I tried to create a partition from about 1GB until the end of the disk. After running the formatting, my disk doesn't appear in my /media/username/ anymore. How can I cd into this disk, and how can I check if it has been properly formatted to ext4?

I tried to follow this: Terminal method of formatting storage drive

Unfortunately, creating the partition led to some errors:

$ sudo parted /dev/sda1 mklabel gpt 
Warning: Partition(s) on /dev/sda1 are being used.
Ignore/Cancel? Ignore                                                     
Warning: The existing disk label on /dev/sda1 will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes                                                               
Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/sda1 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.
Ignore/Cancel? Ignore                                                     
Information: You may need to update /etc/fstab.

It complained about the disk being in use, but I don't think I was doing anything with the disk. I had not opened files nor entered the disk, so I ignored the warning.

Then I tried to format the disk and tried to align the blocks:

$ sudo parted --align optimal /dev/sda1 -- mkpart primary ext4 1902592s -1s
Warning: You requested a partition from 974MB to 5001GB (sectors 1902592..9767471103).
The closest location we can manage is 974MB to 5001GB (sectors 1902592..9767471070).
Is this still acceptable to you?
Yes/No? Yes                                                               
Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/sda1 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.
Ignore/Cancel?

Since it's an external hard drive, I don't understand why I have to reboot, so I just unmounted the disk. When I mounted it back, it didn't appear any longer.

$ cd /media/username
$ ls
$

Does anyone have an idea how to mount the disk, how to fix the formatting if necessary, and how to handle these error messages?

guiverc avatar
cn flag
I'd check your commands, your `sudo parted /dev/sda1 mklabel gpt` attempted to make a new partition table on an existing partition (not a drive!). ie. you're trying to create a nested list of partition tables on the same drive? Did you intend to instead do it to the drive? and not try and create a partition table within a partition on the pre-existing partition table as per your command? Your issue is likely related to what you've done & incorrect commands/understanding as you don't follow the doc you listed as I understand what you did.
guiverc avatar
cn flag
In the example link you provided you'll note is said "*You should replace that with the device you need (/dev/sda, for example)*" but you didn't use a device, but instead fed it a partition (sda1) instead of a device (sda is a device).
mixmax avatar
mo flag
Ah OK, that makes sense. Can I still apply the modified command now ?
mixmax avatar
mo flag
It seems that GParted can actually detect the disk, which does not mount automatically. Therefore, I think I could fix the formatting with GParted (more successfully than with parted). Then I could mount the disk with the "Disks" Ubuntu application back to /media/username .
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.