Trying to find a general bugfix
Normally the computer will identify the boot drive as hd0
, but this is not the case in your computer. I will try to find a way to get around that problem. I tested with Lubuntu 17.04 in my Toshiba laptop in UEFI mode, and could not reproduce the bug. So I will need your help to test whatever bugfix I can find.
Edit: I have modified the shellscript dus-persistent
of mkusb and uploaded the new version 12.1.1 to the unstable PPA. The main improvements address a change in the boot structure of Ubuntu 17.04 and the fact that your computer does not boot from hd0. The main difference is how to identify partition #4 with the image from the iso file (the iso9660 file system),
search --set=root --fs-uuid <the-UUID-of-partition-no-4>
and it is done automatically by mkusb-dus. Please test if it solves the problem! You get the new version according to this link,
help.ubuntu.com/community/mkusb/gui#from_the_unstable_PPA
The unstable version is still developed and debugged. It is available from ppa:mkusb/unstable
via the following command lines,
sudo add-apt-repository universe # this line only for standard Ubuntu
sudo add-apt-repository ppa:mkusb/unstable
sudo apt-get update
sudo apt-get install mkusb # install
# sudo apt-get dist-upgrade # upgrade to current version (with all other upgrades), only for installed systems
sudo apt-get install mkusb guidus dus mkusb-common
# upgrade all mkusb basic components including dus
# for persistent live drives that work in UEFI and BIOS mode with 32-bit iso files, add
sudo apt-get install usb-pack-efi
Workaround - bugfix in your case
Thanks for the feedback (that you edited into the original question). It makes it easier to help.
"I tried editing the grub commands ("e") and changing hd0
to hd2
. That
works! The persistent flash drive boots as expected. (Wonder why grub
doesn't just set root to the disk it was loaded from ...?)"
I would suggest editing the grub.cfg
file in partition #3 of the 'USB drive to be persistent' (the 'usbboot' partition). This should make the bugfix persistent in your USB flash drive. But it would not work in other computers, that behave like my computers.
$ ls -l /media/lubuntu/usbboot/boot/grub/grub.cfg
-rw-r--r-- 1 lubuntu lubuntu 1312 Apr 29 06:31 /media/lubuntu/usbboot/boot/grub/grub.cfg
grub.cfg
has the following content, where you modify hd0,4
to hd2,4
. (You might also modify hd0,3
to hd2,3
, but Memtest86+ will not work in UEFI mode anyway.)
In your case you can expect 'Ubuntu' instead of 'Lubuntu', but otherwise it would look the same.
set timeout=10
set default=0
menuentry "Lubuntu-17.04-desktop-amd64.iso - persistent live" {
set root=(hd0,4)
linux ($root)/casper/vmlinuz.efi boot=casper quiet splash persistent --
initrd ($root)/casper/initrd.lz
}
menuentry "Lubuntu-17.04-desktop-amd64.iso - persistent live to RAM" {
set root=(hd0,4)
linux ($root)/casper/vmlinuz.efi boot=casper quiet splash toram persistent --
initrd ($root)/casper/initrd.lz
}
menuentry "Lubuntu-17.04-desktop-amd64.iso - live" {
set root=(hd0,4)
linux ($root)/casper/vmlinuz.efi boot=casper quiet splash --
initrd ($root)/casper/initrd.lz
}
menuentry "Lubuntu-17.04-desktop-amd64.iso - recovery mode" {
set root=(hd0,4)
linux ($root)/casper/vmlinuz.efi boot=casper ro recovery nomodeset
initrd ($root)/casper/initrd.lz
}
submenu "Memory test" {
menuentry "Memtest86+ works in BIOS alias CSM mode, but not in efi (UEFI) mode"{
echo "${grub_platform} mode; (memtest86+ does not work with efi (UEFI) mode)"
}
menuentry "Memtest86+ 4.20" {
set root=(hd0,3)
echo "${grub_platform} mode; (memtest86+ does not work with efi (UEFI) mode)"
linux16 /boot/memtest/memtest.bin
}
menuentry "Memtest86+-5.01" {
set root=(hd0,3)
echo "${grub_platform} mode; (memtest86+ does not work with efi (UEFI) mode)"
linux16 /boot/memtest/memtest86+-5.01.bin
}
}
Alternative
An alternative is to copy the menuentries of grub.cfg
and modify one of them to have two alternatives to make the USB flash drive boot easily in different computers.
...
menuentry "Ubuntu-17.04-desktop-amd64.iso - persistent live (hd2,4)" {
set root=(hd2,4)
linux ($root)/casper/vmlinuz.efi boot=casper quiet splash persistent --
initrd ($root)/casper/initrd.lz
}
menuentry "Ubuntu-17.04-desktop-amd64.iso - persistent live (hd0,4)" {
set root=(hd0,4)
linux ($root)/casper/vmlinuz.efi boot=casper quiet splash persistent --
initrd ($root)/casper/initrd.lz
}
...
Make persistent live systems boot in UEFI and BIOS mode
mkusb can create persistent live systems with Ubuntu and Debian (including Ubuntu community flavours and several (but not all) distros based on Ubuntu and Debian.
It is possible to make these persistent live systems boot both in BIOS and UEFI mode, both from 64-bit and 32-bit iso files.
Links
help.ubuntu.com/community/mkusb
help.ubuntu.com/community/mkusb/persistent
Demo example
I made an Ubuntu 16.04.1 LTS persistent live drive in a USB 3 128 GB pendrive. This pendrive has been used a lot, and is getting slow, but it is still working. (I think I will soon 'wipe the whole device' to make it faster again.)
Here is the 'console output',
$ dus ubuntu-16.04.1-desktop-amd64.iso
dus 12.3.0
live system or temporary superuser permissions
Drive that contains source file: /dev/sdc
Live drive, that is booted from: /dev/sda
Drive with a partition in fstab: /dev/sdb
cands=1
sdd
SanDisk_ExtremePro
119,2G
usb
USB or memory card
p_target: target=/dev/sdd
settings=
percent=90
Prepare persistent live system from
'ubuntu-16.04.1-desktop-amd64.iso'
to the target device (drive) '/dev/sdd'
MODEL NAME FSTYPE LABEL SIZE
ExtremePro sdd iso9660 TinyCore 119,2G
└─sdd1 iso9660 TinyCore 14M
ubuntu-16.04.1-desktop-amd64.iso
/dev/sdd
90
settings=
-----
live system or temporary superuser permissions
ubuntu-16.04.1-desktop-amd64.iso
/dev/sdd
90
settings=
source=ubuntu-16.04.1-desktop-amd64.iso
target=/dev/sdd
percent=90
msdos=false
upefi=false
dni=false
source=ubuntu-16.04.1-desktop-amd64.iso
ls -l ubuntu-16.04.1-desktop-amd64.iso
-rw-r--r-- 1 olle olle 1513308160 aug 30 2016 ubuntu-16.04.1-desktop-amd64.iso
---------------------------------------------------------------------------
start [dus-persistent 12.3.0] @ 2018-04-17 20:14:09
---------------------------------------------------------------------------
Making a USB boot drive or memory card ..........................
running operating system: ubuntu
grub_n_iso "$source" "$target" "$result"
grub_n_iso ubuntu-16.04.1-desktop-amd64.iso /dev/sdd
***** tu=/dev/sdd ****************************************************
selected target partition table: 'gpt'
dus-persistent wants the program 'usb-pack-efi': wanted in order to install 'persistent live'.
dus-persistent 12.3.0 wants usb-pack-efi but it is not installed.
wanted in order to install 'persistent live'.
mount: /dev/loop0 is write-protected, mounting read-only
Ubuntu 16.04.1 LTS "Xenial Xerus" - Release amd64
mount: /dev/loop0 is write-protected, mounting read-only
select_boot_system: usb-pack_efi is available
select_boot_system: usb-pack_efi: using variable 'upefi=false'
item 00
'ubuntu-16.04.1-desktop-amd64.iso' is identified as the source ISO file
<pre>
MODEL NAME FSTYPE LABEL MOUNTPOINT SIZE
ExtremePro sdd iso9660 TinyCore 119,2G
`-sdd1 iso9660 TinyCore 14M
</pre>
Using the file '/usr/share/mkusb/grub.cfg'
item 10
Clean for a GUID partition table
GPT fdisk (gdisk) version 1.0.1
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************
Warning! Main partition table overlaps the first partition by 34 blocks!
You will need to delete this partition or resize it in another utility.
Command (? for help): This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N):
Command (? for help):
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sdd.
The operation has completed successfully.
Wipe the first megabyte (mibibyte) to get a clean boot area
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,150058 s, 7,0 MB/s
Wait 5 seconds and a little more ...
item 20
---------------------------------------------------------------------------
Selected percentage of remaining space for persistence = 90
---------------------------------------------------------------------------
partition 1 - ntfs 'usbdata'
Warning: The resulting partition is not properly aligned for best performance.
partition 2 - bios_grub
partition 3 - fat32 boot,efi
partition 4 - iso9660 - cloned system
partition 5 - ext4 - 'casper-rw'
item 30
preparing /dev/sdd3 ------------------------------------------------
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,135527 s, 7,7 MB/s
umount: /dev/sdd3: not mounted
mkfs.fat 3.0.28 (2015-05-16)
/dev/sdd3 has 255 heads and 63 sectors per track,
hidden sectors 0x1000;
logical sector size is 512,
using 0xf8 media descriptor, with 499712 sectors;
drive number 0x80;
filesystem has 2 32-bit FATs and 1 sector per cluster.
FAT size is 3844 sectors, and provides 491992 clusters.
There are 32 reserved sectors.
Volume ID is 98e64270, no volume label.
item 40
preparing /dev/sdd1 ------------------------------------------------
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,0425365 s, 24,7 MB/s
umount: /dev/sdd1: not mounted
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
Creating root directory (mft record 5)
Creating $MFT (mft record 0)
Creating $MFTMirr (mft record 1)
Creating $LogFile (mft record 2)
Creating $AttrDef (mft record 4)
Creating $Bitmap (mft record 6)
Creating $Boot (mft record 7)
Creating backup boot sector.
Creating $Volume (mft record 3)
Creating $BadClus (mft record 8)
Creating $Secure (mft record 9)
Creating $UpCase (mft record 0xa)
Creating $Extend (mft record 11)
Creating system file (mft record 0xc)
Creating system file (mft record 0xd)
Creating system file (mft record 0xe)
Creating system file (mft record 0xf)
Creating $Quota (mft record 24)
Creating $ObjId (mft record 25)
Creating $Reparse (mft record 26)
Syncing root directory index record.
Syncing $Bitmap.
Syncing $MFT.
Updating $MFTMirr.
Syncing device.
mkntfs completed successfully. Have a nice day.
preparing /dev/sdd5 ------------------------------------------------
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,306058 s, 3,4 MB/s
umount: /dev/sdd5: not mounted
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 27739265 4k blocks and 6938624 inodes
Filesystem UUID: 8ab3dcb4-ef4e-4fce-a7a0-c30ff55e3556
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
item 50
mount: /media/multimed-2/CD/ubuntu/16.04/ubuntu-16.04.1-desktop-amd64.iso is already mounted
fatlabel: warning - lowercase labels might not work properly with DOS or Windows
tune2fs 1.42.13 (17-May-2015)
---------------------------------------------------------------------------
source=ubuntu-16.04.1-desktop-amd64.iso
---------------------------------------------------------------------------
item 60
umount: /dev/sdd3: not mounted
mount /dev/sdd3 /tmp/dus.9PLDBnyz6K
/dev/sdd3 241M 512 241M 1% /tmp/dus.9PLDBnyz6K
item 65
umount: /dev/sdd1: not mounted
/dev/sdd1 12G 62M 12G 1% /tmp/dus.S1WqEpXLsT
item 70
UEFI Bootloader: Installing for i386-pc platform.
Installation finished. No error reported.
item 80
64-bit bootloader: copy the boot files from the iso file
looper=/tmp/dus.9TDw3CrMfL
targ1=/tmp/dus.9PLDBnyz6K
rsync: symlink "/tmp/dus.9PLDBnyz6K/ubuntu" -> "." failed: Operation not permitted (1)
rsync: symlink "/tmp/dus.9PLDBnyz6K/dists/stable" -> "xenial" failed: Operation not permitted (1)
rsync: symlink "/tmp/dus.9PLDBnyz6K/dists/unstable" -> "xenial" failed: Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
rsync: don't worry, symlink errors are *expected*
because of the target file system.
Using the file '/tmp/dus.9PLDBnyz6K/boot/grub/grub.cfg'
set security upgrade action to 'Display immediately'
umount: /dev/sdd4: not mounted
---------------------------------------------------------------------------
do_n_show:
< "ubuntu-16.04.1-desktop-amd64.iso" pv -ni2 | dd of=/dev/sdd4 bs=4096
( < "ubuntu-16.04.1-desktop-amd64.iso" pv -ni2 | dd of=/dev/sdd4 bs=4096 && echo 'Done' > /dev/stderr ) 2>&1 || ( echo '# failed';sleep 1 )
Please wait for sync (flushing file system buffers to the device)
until 'Done' is written ...
'pv %'; 'dd final output'
7
12
13
13
13
13
14
15
15
16
17
18
19
20
24
26
26
27
27
27
29
31
34
35
36
37
41
45
49
53
58
62
66
69
71
73
77
81
85
89
94
98
100
369460+0 poster in
369460+0 poster ut
1513308160 byte (1,5 GB, 1,4 GiB) kopierade, 88,7954 s, 17,0 MB/s
Done
do_n_show: Work done
---------------------------------------------------------------------------
Syncing the target device ...
item 90
Wait 5 seconds and a little more ...
<pre>
parted -s "/dev/sdd" print
Model: SanDisk ExtremePro (scsi)
Disk /dev/sdd: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
2 1049kB 2097kB 1049kB primary bios_grub
3 2097kB 258MB 256MB fat32 primary boot, esp
4 258MB 1791MB 1533MB primary
5 1791MB 115GB 114GB ext2 primary
1 115GB 128GB 12,6GB ntfs primary msftdata
lsblk -o MODEL,NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE "/dev/sdd"
MODEL NAME FSTYPE LABEL MOUNTPOINT SIZE
ExtremePro sdd 119,2G
|-sdd1 ntfs usbdata 11,8G
|-sdd2 1M
|-sdd3 vfat usbboot 244M
|-sdd4 iso9660 Ubuntu 16.04.1 LTS amd64 1,4G
`-sdd5 ext4 casper-rw 105,8G
</pre>
Done :-)
The target device is ready to use.
'ubuntu-16.04.1-desktop-amd64.iso'
was installed
item 100
Cleanup after dus-persistent finished :-)
Cleanup after dus-persistent finished :-)
---------------------------------------------------------------------------
Total time used [by dus-persistent] = 204 s; 00:03:24
p_clean:
live system or temporary superuser permissions
clean if necessary and return
$
ubuntu-persistent-live-in-bios-mode.png:
ubuntu-persistent-live-in-uefi-mode.png:
Best Answer
More reasons not on the original list:
Bad USB flash drive. This could even be a new flash drive which I assume to be not corrupted. Ubuntu will boot after making the Ubuntu live USB on a different USB flash drive. It's worth a try if you have two or more USB flash drives.
Reformat the flash drive and reload the Ubuntu ISO from an application for making a live USB.
Check the Ubuntu ISO that you downloaded against its SHA256 checksum to verify that the checksums match.
Voltage irregularities that affect the smooth amount of voltage delivered from the motherboard to the USB flash drive. Possible causes of this are motherboard, power supply and even irregular house current. A very old computer is more likely than a new computer to have issues with the motherboard or power supply that affect booting to a live USB session.
Here are a few suggestions that worked when I tried them.
Don't plug in USB devices like mouse and keyboard next to each other. Plug in one USB device at the front and one at the back.
Disconnect unnecessary devices when booting the USB to reduce the power load, for example disconnect one HDD if there are two drives. If you have a 4-port USB splitter with switches on each port this is ideal, because you can turn the USB mouse off when you don't need it and you don't need to open the computer case to disconnect an internal drive in order to reduce the power load.
The Ubuntu live USB will sometimes be able to boot if the same computer is moved to another location that has a more controlled source of current or connected to an uninterruptible power supply (UPS).
Overheating may cause the computer to power off when trying to start the Ubuntu installer. The CPU temperature can be checked by accessing the UEFI/BIOS setup utility when the computer is booting.
Some applications for making Ubuntu live USBs seem to work better than others. For example, the built-in Startup Disk Creator application is better than most.
In case the BIOS Boot options do not recognize the USB device at all, some older BIOSs do not even correctly label USB flash drives in the Boot options. Instead they use some non-standard nomenclature for flash drives like USB-FDD or USB-HDD. USB-FDD stands for "floppy disk drive" which never works with USB flash drives, so in this case you should choose USB-HDD instead. Even though a USB flash drive is not a hard disk drive choosing this option frequently works.
If this was part of a flowchart I would group all of the hardware reasons as child nodes branching out from the same parent hardware node. Similarly I would group the Casper nodes together and the grub nodes together, branching out from a Casper parent node and a grub parent node respectively.
(Click images to enlarge)