7

I have sandisk 8GB

I had kali linux installed. I tried to create Bootable live Ubuntu pendrive. I went to the terminal and issued the following commands:

sudo dd if=/dev/zero of=/dev/sdb bs=1k count=2048

sudo parted /dev/sdb mklabel msdos

sudo parted -a none /dev/sdb mkpart  primary fat32 0 2048

mkfs.vfat -n "Disk" /dev/sdb1

sudo dd if=./ubuntu.iso of=/dev/sdd bs=8129

It created bootable live USB installer for Ubuntu successfully.

After dual booting my latop with Ubuntu and Kali linux I now need the pendrive for data storing purpose

It was showing a capacity of only 64 MB. I used dd command to reformat it but that wouldn't help. I also used gparted but that didn't help.

What to do now?

  • 1
    since its a pen drive .. did you go into gparted and just delete all the partitions then create a new one with the file system you are looking for ... most likely you are only viewing a small partition on the drive and there is other partitions or unpartitioned space on the drive. – John Orion Jun 5 '16 at 15:22
5

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.

  • I followed your instructions but problem is half solved – rancho Jun 5 '16 at 16:08
  • @rancho What do you mean by "half solved" - what isn't working ? – JonasCz Jun 5 '16 at 16:15
  • After executing the dd command in terminal gparted correctly determined the size to be 8 GB. I went to Devicce --> Create partition table -->gpt --> Apply. I got the error that the task was successfully carried out but system was unable to inform the kernel. I right clicked on unallocated spaces and issued command to create fat32 partition using the entire space. It gave a pop up window saying an error occurred while applying the operation. What to do now? – rancho Jun 5 '16 at 16:16
  • @rancho Close gparted, Unplug USB stick and plug it in again, and then try creating the partition with gparted again. – JonasCz Jun 5 '16 at 16:18
  • @JonazCz Can you please follow my conversation with Bharadwaj Raju. It would be of great help to me? – rancho Jun 5 '16 at 16:50
2

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 followed your instructions. But still the problem is not solved completely. Now when viewed in the result in gparted, there is a red exclamation mark on the immediate right of /dev/sdb. Is it something to be worried about? – rancho Jun 5 '16 at 16:38
  • Most probably no. – UniversallyUniqueID Jun 5 '16 at 16:38
  • In gparted the option to delete the partition is greyed out. I can do this operation in other pen drives. Also I am unable to resize the partition so as to create two partitions. Something is surely wrong. – rancho Jun 5 '16 at 16:46
  • @rancho - try closing gparted, unplugging the USB drive, and then try again. Perhaps also reboot if that doesn't work ? – JonasCz Jun 5 '16 at 16:51
  • 1
    @rancho: The -I switch to mkfs.vfat creates filesystems without a partition. That is, the filesystem takes up the whole disk, with no room left over for the partition table or other such metadata. I imagine that is why you are unable to resize partitions: There is no partition to resize. – Kevin Jun 6 '16 at 0:06
1

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.