104

I was using:

dd  if=/path/to/my/ubuntuiso/ubuntu.iso  of=/dev/sdb1  bs=4M  &&  sync

In order to create bootable Ubuntu USB drives on older Ubuntu versions. It was working perfectly. Sometimes I used the Startup Disk Creator program, which worked well.

But when I use the same methods on Ubuntu 16.04 LTS, I get some warnings while formatting it afterwards.

The installation media works as expected, but when I try to format that USB stick after my work is done, I get the following warning :

enter image description here

The partitioning of that Pendrive looks strange :

enter image description here

And it also shows my 16GB pendrive as 64GB.

After struggling a lot with Gparted, I will somehow format it. But Why is it happening like this ?? Is there any better methods of creating bootable Ubuntu in 16.04 ?

EDIT : there is a related question here. But my question is not about how to format it properly. My question is "How to create a bootable USB without that errors." & "Wht are the causes of that error"

Severus Tux
  • 9,866

11 Answers11

122

A command-line method to make a live USB for UEFI systems

Please note: this deletes all data on the target device.

Install prerequisite:

sudo apt-get install p7zip-full

Assuming the target USB is at /dev/sdb

(please check first with lsblk or gnome-disks or sudo fdisk -l and be sure you know what you are formatting)

Make sure the device has no mounted filesystem and unmount it if necessary, for example:

udisksctl unmount -b /dev/sdb1

Destroy existing partition table:

sudo sgdisk --zap-all /dev/sdb

Create new GPT:

sudo sgdisk --new=1:0:0 --typecode=1:ef00 /dev/sdb

Format as FAT32:

sudo mkfs.vfat -F32 /dev/sdb1

Check it:

sudo fdisk -l /dev/sdb

Should output something like:

Device     Start      End  Sectors  Size Type
/dev/sdb1   2048 15663070 15661023  7.5G EFI System

Mount the drive and extract iso onto it, replacing 'name-of-iso' with the actual filename of the iso you downloaded earlier

sudo mount -t vfat /dev/sdb1 /mnt
sudo 7z x name-of-iso -o/mnt/

Unmount

sudo umount /mnt

Now reboot & enjoy Ubuntu ^_^

(Here's where I originally learned to do this.)

Zanna
  • 70,465
  • 3
    Doing it... but this needs the packages p7zip-full , It would be better if you would add doing the same with tar in your answer. – Severus Tux Jun 03 '16 at 08:46
  • 3
    wow! Thank you very much . It works well. partition looks clean . It would be best if you add extracting using inbuilt tools like tar in your answer. (or even adding that 7z is available in p7zip-full) – Severus Tux Jun 03 '16 at 08:56
  • aww it seems like I can't use tar to extract an iso – Zanna Jun 03 '16 at 16:39
  • 1
    @Zanna I searched a lot, It seems like iso files cant be extracted using tar . All I have found is using mount -o loop . 7z is better even though its not inbuilt. – Severus Tux Jun 03 '16 at 17:03
  • Yeah I can't possibly enjoy Ubuntu with EVERY single usb bootable disk I create doing this.... every single one. – wayofthefuture Jul 29 '17 at 17:46
  • 3
    I'm upvoting this post because it is a nice description showing 'all' the basic steps :-) But there are also tools that make things automatically for the lazy user ;-) – sudodus Sep 06 '17 at 13:49
  • 4
    This is the only one working for me under 16.04. Thanks! The default app corrupts muy media with the wrong block size problem, and creates a read-only file system that I was unable to revert because of the block size problem. This method allows the user to enjoy all the remaining free space. – user334639 Oct 07 '17 at 00:11
  • After I did this Windows systems stopped recognizing my USB stick, I did the same but with a created msdos partition table and it worked just fine. – MaxNevermind Oct 11 '17 at 20:23
  • 3
    Ubuntu 17.04's usb-creator (Startup Disk Creator) "corrupts" my USB drive every single time. And this step-by-step here is the only way to revert it to a normal writable state. gparted can't. – isync Jan 10 '18 at 12:33
  • @sudodus Seems to me you wrote a lazy tool ;) – WinEunuuchs2Unix Jan 15 '18 at 03:37
  • @WinEunuuchs2Unix, A lazy tool for a lazy user :-D https://help.ubuntu.com/community/mkusb can burn an .ISO to USB in linux and also restore the USB drive to a standard storage device. – sudodus Jan 15 '18 at 06:22
  • @sudodus Your documentation is phenomenal. I can't wait to try out live/persistent feature. I just bought two USB thumb drives for Ubuntu 18.04, one for Unity 7.5 with XORG, the other for Gnome DM w/Wayland. – WinEunuuchs2Unix Jan 15 '18 at 11:49
  • @WinEunuuchs2Unix, You can share your experience at this link: https://ubuntuforums.org/showthread.php?t=1958073, if you have a user ID at the Ubuntu Forums :-) – sudodus Jan 15 '18 at 12:18
  • @sudodus Yeah I had Ubuntu Forums before I had Ask Ubuntu. it's the same user ID if you want to laugh at my old newbie posts :p – WinEunuuchs2Unix Jan 15 '18 at 12:50
  • @WinEunuuchs2Unix, Yeah, all of us have been newbies :-P – sudodus Jan 15 '18 at 13:11
  • @sudodus I found a question with live USB boot issues you might be able to solve if you have time. – WinEunuuchs2Unix Jan 17 '18 at 00:49
  • I did not want a bootable drive, but get a normal one back after having used it as Ubuntu installer. The same process worked; removed the boo flag with gpard, and only root can write to it. But well. – Raphael Feb 22 '18 at 23:08
  • 1
    On a GPT partition table you shouldn't use fdisk but gdisk ... like $ sudo gdisk /dev/sdf then type $ ? and type p for print in my case I get Number Start (sector) End (sector) Size Code Name 1 2048 30218808 14.4 GiB EF00 – Antonio Jan 18 '19 at 19:42
  • @Antonio thanks, I'll check it out next time I'm dealing with a flash drive – Zanna Jan 18 '19 at 20:09
  • Thank you for your solution @Zanna – fear_matrix May 15 '19 at 09:43
  • 1
    After a dozen of "why is this happening to me" with unetbootin and gparted, the outpout of 7zip in the terminal with "Everything is Ok" made my night. Thank you! – Bogotrax Mar 01 '20 at 04:02
  • @Bogotrax hahaha ikr. Happy it worked for you – Zanna Mar 01 '20 at 15:16
41

Here's how I solved the problem of getting this error when trying to reformat a USB after using it as installation media:

  • First open the Disks Application under Applications > Disks
  • Select the bootable pen drive.
  • There will be an option menu on top right corner
  • Select the Format drive option (CTRL + F)
  • A pop-up will be shown. Select 0 partition and format the disk
  • Now the disk will be empty but it will be not recognized by system. But you can see on Disks Application.
  • Select the pen drive and re-format it. Now the pendrive can be detect by any system.

The accepted answer is too complex to use, as it required lots of typing and remembering the particular disk name (otherwise you may end up with serious problem). Mine is super easy to implement.

Zanna
  • 70,465
  • 3
    +1, but I think this question has a misleading title - I have edited it. The accepted answer to this question is a method of creating installation media, as OP requested, not simply formatting the drive (and you always have to be sure you are selecting the right device when formatting, no matter what method you use!) – Zanna May 16 '17 at 18:06
  • Ok, Thanks for letting me know. Now As per your edited title, You can use startup disk creator to create an fresh installation media after formatting the drive. – Gopal Prasad May 16 '17 at 18:15
  • Thank you. The menu in top right corner was not obvious to find. – Tor Klingberg May 09 '18 at 12:58
17

It is found that the problem is due to a bug in usb-creator-gtk. It is setting improper block-size during the creation of bootable media.

If this bug affects you, you can mark it here : https://bugs.launchpad.net/ubuntu/+source/usb-creator/+bug/1589028

Severus Tux
  • 9,866
  • 1
    On the last comment on the above website, There's the user named EoflaOE, and below it, you see the comments and what affected me and what did I suggest so you never try to damage your USB like last time. If you need to make your own bootable USB, Use Rufus or Universal USB Creator until this bug is fixed. – Eofla Jan 27 '17 at 15:05
14

This was much easier. Just replace /dev/sdd with your device address. This can be found in the Disks or Gparted utility.

sudo dd if=/dev/zero of=/dev/sdd bs=2048 count=32

You can then use Startup Disk Creator to burn the image to the drive.

Zanna
  • 70,465
7

I use UNetbootin on Ubuntu (both older version and 16.04) and it works fine on my PC. Here's the link for more info.

sudo apt-get install unetbootin
trunk96
  • 200
  • 3
    thanks for your interests, but my question is not "any alternatives ? " my question is "Why are those methods not working as expected?". I would also appreciate any other methods which does not involve 3rd party tools. – Severus Tux Jun 03 '16 at 08:11
  • 7
    @SeverusTux Actually, unetbootin is no more 3rd party than anything else. It's available through apt-get. – mchid Jun 03 '16 at 08:16
  • Does not allow a disk image (multi-partition) install, insists one partition mounted already. – Gringo Suave Apr 29 '18 at 18:54
6

Try dd if=/path/to/my/ubuntuiso/ubuntu.iso of=/dev/sdb this way never failed me. (Note b not b1 at the end - will destroy other partitions if present)

Did you check if the ISO is corrupted?

Also doing this from TTY while not logged in the graphical environment could help in tracking down the problem.

Edit: instead of using the ISO you could use /dev/null to overwrite the partition table.

NoOneIsHere
  • 199
  • 4
  • 16
  • like this: dd if=/dev/null of=/dev/sdb ?

    This doesn't seem to do anything

    – quantumbutterfly Jan 10 '17 at 05:03
  • 2
    /dev/null points to 'nothing' and is used for output, but /dev/zero generates zero characters (ascii 0). – sudodus May 16 '17 at 18:08
  • The best answer imo, simple and efficient, with the slight exception of adding oflag=sync as an argument, to ensure all writes have been done before the command returns. However, it works because of a trick used by Canonical to create the image, that is both an ISO image and a partitioned disk image. – NovHak Aug 23 '20 at 22:34
2

The complaint about block size was probably caused by a bug in the software reading the iso9660 file system. A new version of gparted is released and is available at least in Ubuntu 17.10, where this bug is squashed.


You can use mkusb to clone the drive. This method is not sensitive to the content of the drive, so it is very reliable.

It is also very safe, because mkusb 'wraps a safely belt' around the powerful but dangerous dd command. The target drive is shown very clearly and you have a final checkpoint, where you can double-check, that you will be installing to the correct drive (and avoid mistakes).

See this link: https://help.ubuntu.com/community/mkusb

If it is still not working, you can try according to the following link,

Can't format my usb drive. I have already tried with mkdosfs and gparted - Analysis of the problem

Please notice that you need not start with formatting, because mkusb will overwrite the previous content of the drive anyway. You can go ahead directly and

  • install the operating system from the iso file (or image file) or
  • restore the drive to a standard storage device
sudodus
  • 46,324
  • 5
  • 88
  • 152
1

a problem that comes up with the chosen answer : The pen drive is now invisible upon inserting. (I'm on Lubuntu 16.04 64-bit) Solution: Open the Disks utility to mount it.

In Lubuntu: Start menu > Preferences > Disks.

What has worked with the chosen answer, is that we're back to good old way of the USB drive getting the bootable ISO written to it and still remaining a writable USB drive with remaining space available to store other files (from another existing OS where we're not running the live OS). With Startup Disk Creatoras of 16.04, it is wiping out the USB, creating a read-only partition akin to a CD, making the remaining portion of the USB unallocated (so a 32GB drive becomes a 900mb read-only drive), and I wasn't able to create any secondary partition in the unallocated space.

Update: Unetbootin seemed to do the job, the pen drive remained visible, didn't hide on inserting, and the remaining part of the disk remained available for storing other data. BUT the disk did NOT get recognized as a bootable USB when I booted my laptop! I used the Ubuntu version of UNetBootin.

Nikhil VJ
  • 291
  • You might have better luck, if you install Unetbootin from the developer's PPA, because the version in Ubuntu's repository can be too old (not up to date to cope with new versions of Ubuntu); 2. The error message in the title of this question is because the software does not understand the iso9660 file system of a cloned boot drive; 3. And if you have problems to restore the drive to a standard storage device, you can use mkusb according to the link in my answer. (It is possible with gparted and Disks too, but maybe more difficult.)
  • – sudodus Oct 07 '17 at 09:49