6

I was trying to create a Kali installation suite on my 16 GB sandisk pendrive. I used the dd command and umount to mount the iso into my USB. After the installation is complete I formated my pendrive and now it shows it has only 10 GB of usable space. How to format it properly so that i can use the entire space?

  • 1
    did you tried deleting all the partitions on it ? also can you edit and show it from GParted – Edward Torvalds Dec 9 '14 at 12:49
5

You need to remove the image of the install disk completely. Run the following series of commands:

sudo fdisk /dev/sd_ # Insert drive letter as appropriate
    p         # This will list partitions on it. CHECK it's the pendrive!
    d         # Delete partition (repeat until all deleted).
    p         # If you still have partitions, run d again
    n         # Create a new partition. Physical, accept defaults for size etc
    t         # Change type - use option b (vfat). Consider c (bigger USB sticks).
    w         # Write out changes & quit fdisk

sudo mkfs -t vfat /dev/sd_1
0

I once used dd to copy a live iso onto a usb drive (sd card specifically). It didn't use a regular MBR, apparently no MBR at all, just something like the cd-type ISO9660.

What should have worked to fix it (that I didn't try at the time) would be to use something like gparted to:

  1. write a new MBR to the drive, then create new partition(s) and
  2. format them with your chosen FS.

If that didn't restore the full size of the USB drive, that's a problem... I don't know of a tool better than parted/gparted... there have been some "fake" usb drives & flash cards sold that are specially formatted to appear larger than they actually are (to be sold at a higher price than they're worth).


In the case of my odd iso-dd'd drive, even after re-partitioning it with gparted weeks later the old live iso would show up sometimes (somehow - don't remember exactly how, some unusual way of mounting, maybe gnome-disks) but I could still read lots of the old iso's files (their md5's were even good) and that was after re-partitioning and reformatting and writing some new files to the new partition.

Eventually I searched the raw device for any mention of the old iso & overwrote the first 700-odd blocks on the drive.


FYI, these commands should save a backup copy of the MBR & partition layout, maybe not useful in your case but related to new MBR'ing and re-partitioning a drive:

Backup copy of mbr (first 512 bytes):

sudo dd if=/dev/sdb of=sdb-first512-mbr bs=512 count=1

Backup copy of partition table with sfdisk (text list)

sudo sfdisk -d /dev/sdb > sdb-parttable-sfdisk

0
  1. Install gparted and open it
  2. Select usb disk(e.g. /dev/sdb) from top right corner
  3. Delete all existing partitions
  4. Create new primary fat32 partition with full space
  5. Click on apply(It'll work even if you see error at the end of this operation)
  6. Use windows pc to format this drive

Instruction(3-5) will destroy old partition table created by dd when you were created bootable disk and create new partition table with.

You can now use this usb stick in windows and format it. It will show you full space of your usb drive.

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