Corrupt pendrive after making live Ubuntu installer
You can try to select "Create partition table", under the device menu in Gparted, in order to fully reformat it. (Select msdos as the partition table type). Then, you should be able to create a new partition on the USB stick.
If that doesn't work, a very simple (But slow, and I'm sure there's a better way) way to fix this would be to simply overwrite the entire drive with dd
, by using something like this:
sudo dd if=/dev/zero of=/dev/sdb bs=4M
Which will overwrite the entire contents with zeroes, after which you should be able to create a partition table and a partition with Gparted as described above.
Try mkfs.vfat
.
Assuming your pendrive is /dev/sdb
sudo mkfs.vfat -I -n "Name you want" /dev/sdb
will create a new FAT32 filesystem on /dev/sdb
. (If you want NTFS, replace mkfs.vfat
with mkfs.ntfs
)
Explanation of -I
:
-I
creates a filesystem on the entire /dev/sdb
device, removing any previous partitions.
From man mkfs.vfat
:
-I It is typical for fixed disk devices to be partitioned so, by default, you are not permitted to create a filesystem across the entire device. mkfs.fat will complain and tell you that it refuses to work. This is different when using MO disks. One doesn't always need partitions on MO disks. The filesystem can go
directly to the whole disk. Under other OSes this is known as the 'superfloppy' format. This switch will force mkfs.fat to work properly.
I finally managed to solve the problem. It's quite easy once you gain the basic understanding. The main thing is that in Linux you should never use graphical user interface and always stick with terminal. I did the following in terminal:
sudo su
This makes me sudo user by default without the need to put sudo at first everytime
fdisk -l
This checks for the present disks. Thus I can safely determine my pendrive to be sdb. dd is destructive command and has to be carefully used against correct drive
dd if=/dev/zero of=/dev/sdb bs=4M
This overwrites the entire disk with zeros. It wipes all present file systems and partition tables. The disk at this point is useless.
parted /dev/sdb
This starts the parted program which is a powerful CLI program to create partition tables
mklabel gpt
This creates gpt partition table for the disk
quit
This quits parted program
mpunt -a
After altering or creating a new partition table /etc/fstab has to be reloaded. This can be done by rebooting the computer. However this one line terminal command also does the same job
umount /dev/sdb
Now in order to create partitions of different file systems /dev/sdb has to be unmounted first
mkfs -t ext4 -L SANDISK /dev/sdb
This creates file partition of type ext4. Here -t argument is for file type. -L argument is for the label of the disk. Here the disk is named 'SANDISK'
That's it