103

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,736
  • 9
  • 58
  • 97
  • for UEFI I use sgdisk commands - I've made 6 distro live USBs this way in the last few months & it works beautifully for me – Zanna Jun 03 '16 at 08:00
  • @Zanna please explain the usage of sgdisk – Severus Tux Jun 03 '16 at 08:06
  • Are you sure that is the correct device? If it should be 16GB maybe it is /dev/sdc or something else. A lot of sd cards are 64GB and those don't usually work for booting. Your drive will not always show the same (sdb sdc) and it all depends on which drive was mounted first. – mchid Jun 03 '16 at 08:18
  • @mchid Yes, I am sure its the correct device. After deleting it .. facing a lot of warnings... It becomes 16GB again – Severus Tux Jun 03 '16 at 08:22
  • 1
    I format USBs with `mkfs` after an ISO. Works regardless of USB creation method. –  Jun 03 '16 at 08:28
  • 4
    Possible duplicate of [Unable to delete USB Drive partitions (Block size error)](http://askubuntu.com/questions/675649/unable-to-delete-usb-drive-partitions-block-size-error) – Braiam Jun 03 '16 at 17:01
  • You are using dd wrong. You shouldn't use `bs=4MB` because is larger than the blocks on the USB. The correct value is `512` bytes. – Braiam Jun 03 '16 at 17:05
  • @Braiam please see the Edit section on my post – Severus Tux Jun 03 '16 at 17:09
  • "How to create the USB without those errors" use the correct block size. "Why it does" because you are not using the correct block size. All of that is in the duplicated. Basically, **you are not doing it the right way**. – Braiam Jun 03 '16 at 17:10
  • @Braiam And even the "Startup Disk Creator" is **not doing it the right way ??** – Severus Tux Jun 03 '16 at 17:15
  • No. SDC is just reusing the same blocksizes that you set when you used dd. SDC is doing it right. It doesn't change the block size since it doesn't need to. – Braiam Jun 03 '16 at 17:19
  • @Braiam But I get the same problem when Block Size is proper. i,e I Insert a proper pendrive, create a bootable using SDC Open Gparted--> Warning. PLease try it once – Severus Tux Jun 03 '16 at 17:22
  • I did something better, [checked the sources](https://bazaar.launchpad.net/~ubuntu-branches/ubuntu/wily/usb-creator/wily/view/head:/bin/usb-creator-helper#L251). I asked someone else just in case I'm not seeing something but it doesn't looks like it modifies the block size. – Braiam Jun 03 '16 at 17:51
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/40713/discussion-between-severus-tux-and-braiam). – Severus Tux Jun 03 '16 at 17:53
  • [Rework the whole imaging process for writing to devices:](https://bazaar.launchpad.net/~usb-creator-hackers/usb-creator/trunk/revision/474) and that's how they break it. [They set block_size to 1000000](https://bazaar.launchpad.net/~usb-creator-hackers/usb-creator/trunk/view/474/bin/usb-creator-helper#L111) which is why libparted complains (different message I presume). I would file a bug report on the package so it gets fixed. – Braiam Jun 03 '16 at 22:02
  • I have the same issues with 2 USB-sticks, and one was created with Startup Disk Creator. – Ken Mollerup Jun 08 '16 at 15:39
  • @KenMollerup then please consider marking as "Yes it affects me" as [given here](http://askubuntu.com/a/781653/497359) – Severus Tux Jun 08 '16 at 15:44
  • @Severus Tux Please I looked all over for it, I clicked your link, but where is the It affects me too button?? I did not give any block size, and it still did it. ! I have reported the error, it affects the >Startup Disk Creator< too - Others have Reported these errors on LaunchePad too! – Ken Mollerup Jun 09 '16 at 05:04
  • I had the same problem burning Ubuntu 16.04 LTR on a usb stick, but I never used manually dd, so there is a problem in some Ubuntu tool.. – Antonello Nov 07 '16 at 10:47
  • Here's how that disk utility [should be](https://askubuntu.com/a/1065719/256054). – Lonnie Best Aug 15 '18 at 21:50

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
  • 69,223
  • 56
  • 216
  • 327
  • 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](http://i.stack.imgur.com/PhI7I.png) . 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
  • 3
    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](https://askubuntu.com/questions/996384/ubuntu-live-crashes-on-msi-gl62-7rd) 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
  • 69,223
  • 56
  • 216
  • 327
Gopal Prasad
  • 511
  • 4
  • 4
  • 2
    +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,736
  • 9
  • 58
  • 97
  • 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
  • 69,223
  • 56
  • 216
  • 327
wayofthefuture
  • 3,861
  • 3
  • 13
  • 11
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
Pierre.Vriens
  • 1,137
  • 37
  • 16
  • 21
trunk96
  • 200
  • 1
  • 1
  • 9
  • 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
Carlo P.
  • 69
  • 4
  • 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
  • 45,126
  • 5
  • 87
  • 151
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
  • 2
  • 12
  • 1. 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
0

It is a shame that many of these GUI disk utilities won't just allow you to delete the partition table off the USB, instead of just prompting with stupid errors like:

Physical block size is 2048 bytes, but Linux says it is 512 bytes

That error dialog should be coupled with this question:

Would you like delete the partition table on this device (all data will be lost)?

Since it doesn't do this, you can immediately do it yourself with this command:

sudo sgdisk --zap-all /dev/sd?

Be sure of two things before you do the command above:

  1. Make sure your terminal is logged into the computer you think it is.
  2. Make sure the device path is correct (see the question mark in he command above,you need to change that to the correct device path).

As others have mention, you can figure out the device path with:

sudo fdisk -l

After this, you can probably proceed by using the utility you were using when you got this error.

BTW, the dd command solutions for this problem are too slow for my needs. All I really want to do is get rid of that error, without waiting on dd to zero out the whole drive.

Lonnie Best
  • 2,174
  • 2
  • 32
  • 42
0

I had the exact same problem, even on a brand new SSD. I used Linux Mint 18.1 and Ubuntu 16.04 LTS ISO versions. No matter how many times I redownloaded the ISO's, rewrote the ISO's and did all tthe steps suggested above to resolve the error mention, it just wouldn't go away. Strangely I did have Mint 18.1 installed and wanted to do fresh install but then encountered the error. I even used the same USB sticks & SSD to install Windows 10, then rewrote the same USB disks AGAION with Ubuntu 16.04/Mint 18.1 and install failed. My opinion is that there was either fault with the ISO file or my particular hardware not compatible. I wasted several HOURS of my life.

** SOLUTION: Downloaded Ubuntu 17.04 ISO & installed. Worked fine on the exact same hardware, same USB drives/sticks where Ubuntu 16.04 wouldn't have any of it.****

0

Apparently the error lies with parted reading the drive incorrectly and not the dd command or the Startup Disk Creator program

Debian Bug report for parted: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788808

Workaround: If you use fdisk instead of parted then you will see the correct partitioning. Use fdisk instead of parted until the parted bug is fixed.

guest
  • 1