Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Ubuntu on USB stick not booting properly

  1. #1
    Join Date
    May 2013
    Location
    Paris, France
    Beans
    174
    Distro
    Ubuntu Gnome 16.04 Xenial Xerus

    Ubuntu on USB stick not booting properly

    Environment: Ubuntu 14.04 on sda (HDD) and sdb (USB stick); grub-customizer 4.0.6; GPT system
    Grub-Customizer.jpg

    Hello guys,

    I've been struggling with this weird issue for a long time and have not found the root cause yet.

    Symptom: when booting, I get the grub menu, when I choose to boot from the USB stick, I get the following error messages:

    error: failure reading sector 0xfc from 'hd0'
    error: failure reading sector 0xe0 from 'hd0'
    error: failure reading sector 0x0 from 'hd0'
    last 3 lines repeated
    error: no such device: <USB-stick-UUID>

    There are multiple strange facts:
    1) hd0 is sda and I'm trying to boot from sdb which is hd1
    2) one might think the boot sector of sda is corrupted. I've checked it:

    sudo dosfsck -w -r -l -v -t /dev/sda1

    [sudo] password for actionmystique:
    fsck.fat 3.0.26 (2014-03-07)
    fsck.fat 3.0.26 (2014-03-07)
    Checking we can access the last sector of the filesystem
    Boot sector contents:
    System ID "mkfs.fat"
    Media byte 0xf8 (hard disk)
    512 bytes per logical sector
    4096 bytes per cluster
    32 reserved sectors
    First FAT starts at byte 16384 (sector 32)
    2 FATs, 32 bit entries
    500224 bytes per FAT (= 977 sectors)
    Root directory start at cluster 2 (arbitrary size)
    Data area starts at byte 1016832 (sector 1986)
    124935 data clusters (511733760 bytes)
    63 sectors/track, 255 heads
    2048 hidden sectors
    1001472 sectors total
    Checking file /
    Checking file /EFI
    Checking file /MSI-GE60-Ef (MSI-GE60.-EF)
    Checking file /$RECYCLE.BIN
    Checking file /EFI/.
    Checking file /EFI/..
    Checking file /EFI/ubuntu (UBUNTU)
    Checking file /EFI/ubuntu/.
    Checking file /EFI/ubuntu/..
    Checking file /EFI/ubuntu/shimx64.efi (SHIMX64.EFI)
    Checking file /EFI/ubuntu/grubx64.efi (GRUBX64.EFI)
    Checking file /EFI/ubuntu/MokManager.efi (MOKMAN~1.EFI)
    Checking file /EFI/ubuntu/grub.cfg (GRUB.CFG)
    Checking file /$RECYCLE.BIN/.
    Checking file /$RECYCLE.BIN/..
    Checking file /$RECYCLE.BIN/DESKTOP.INI
    Checking for bad clusters.
    Checking for unused clusters.
    Checking free cluster summary.
    /dev/sda1: 9 files, 859/124935 clusters
    actionmystique@MSI-GE60-Ubuntu-14:~$ sudo fsck.vfat -V -r /dev/sda1
    fsck.fat 3.0.26 (2014-03-07)
    Starting check/repair pass.
    Starting verification pass.
    /
    Bad short file name ().
    1) Drop file
    2) Rename file
    3) Auto-rename
    4) Keep it
    ? 4
    /dev/sda1: 9 files, 859/124935 clusters

    The first check passes, the second's result is strange: how can '/' be a "bad short file name"?

    3) I have no problem booting on hd0 (the primary HDD): I believe that this proves there's nothing wrong with the boot sector on hd0...
    4) when I press any key after the boot error messages, the USB stick boots normally and works fine...
    5) After shutting down and booting on hd0, I've tried to update the grub configuration:

    sudo update-grub2

    Generating grub configuration file ...
    using custom appearance settings
    Found background image: /boot/grub/themes/Road_milky_way.jpg
    Found linux image: /boot/vmlinuz-3.13.0-30-generic
    Found initrd image: /boot/initrd.img-3.13.0-30-generic
    Found linux image: /boot/vmlinuz-3.13.0-29-generic
    Found initrd image: /boot/initrd.img-3.13.0-29-generic
    Found linux image: /boot/vmlinuz-3.13.0-27-generic
    Found initrd image: /boot/initrd.img-3.13.0-27-generic
    Found linux image: /boot/vmlinuz-3.13.0-24-generic
    Found initrd image: /boot/initrd.img-3.13.0-24-generic
    Found linux image: /boot/vmlinuz-3.13.0-30-generic
    Found initrd image: /boot/initrd.img-3.13.0-30-generic
    Found linux image: /boot/vmlinuz-3.13.0-29-generic
    Found initrd image: /boot/initrd.img-3.13.0-29-generic
    Found linux image: /boot/vmlinuz-3.13.0-27-generic
    Found initrd image: /boot/initrd.img-3.13.0-27-generic
    Found linux image: /boot/vmlinuz-3.13.0-24-generic
    Found initrd image: /boot/initrd.img-3.13.0-24-generic
    No volume groups found
    Found Ubuntu 14.04 LTS (14.04) on /dev/sdb2
    Found linux image: /boot/vmlinuz-3.13.0-30-generic
    Found initrd image: /boot/initrd.img-3.13.0-30-generic
    Found linux image: /boot/vmlinuz-3.13.0-29-generic
    Found initrd image: /boot/initrd.img-3.13.0-29-generic
    Found linux image: /boot/vmlinuz-3.13.0-27-generic
    Found initrd image: /boot/initrd.img-3.13.0-27-generic
    Found linux image: /boot/vmlinuz-3.13.0-24-generic
    Found initrd image: /boot/initrd.img-3.13.0-24-generic
    Found linux image: /boot/vmlinuz-3.13.0-30-generic
    Found initrd image: /boot/initrd.img-3.13.0-30-generic
    Found linux image: /boot/vmlinuz-3.13.0-29-generic
    Found initrd image: /boot/initrd.img-3.13.0-29-generic
    Found linux image: /boot/vmlinuz-3.13.0-27-generic
    Found initrd image: /boot/initrd.img-3.13.0-27-generic
    Found linux image: /boot/vmlinuz-3.13.0-24-generic
    Found initrd image: /boot/initrd.img-3.13.0-24-generic
    Adding boot menu entry for EFI firmware configuration
    done

    Then running grub-customizer does not show any difference in the grub menu.

    I'm running out of idea: any suggestion to solve this issue would be greatly appreciated.

    N.B: below is the boot script for hd1 for those who know how to decipher it
    insmod part_gpt
    insmod ext2
    set root='hd1,gpt2'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2 0544873e-3a01-44c3-b61e-12f3739ed514
    else
    search --no-floppy --fs-uuid --set=root 0544873e-3a01-44c3-b61e-12f3739ed514
    fi
    linux /boot/vmlinuz-3.13.0-30-generic.efi.signed root=UUID=0544873e-3a01-44c3-b61e-12f3739ed514 ro quiet splash $vt_handoff
    initrd /boot/initrd.img-3.13.0-30-generic

  2. #2
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Ubuntu on USB stick not booting properly

    Quote Originally Posted by actionmystique View Post
    ...
    Symptom: when booting, I get the grub menu, when I choose to boot from the USB stick, I get the following error messages:

    error: failure reading sector 0xfc from 'hd0'
    error: failure reading sector 0xe0 from 'hd0'
    error: failure reading sector 0x0 from 'hd0'
    last 3 lines repeated
    error: no such device: <USB-stick-UUID>

    ...
    3) I have no problem booting on hd0 (the primary HDD): I believe that this proves there's nothing wrong with the boot sector on hd0...
    4) when I press any key after the boot error messages, the USB stick boots normally and works fine...
    ...
    Is your 'only real' problem, that you have to press a key after the error messages, in order to continue the boot into the USB stick? Or is it worse, for example that it takes long time before the computer responds to a key press? Or maybe I have not understood your problem at all?

    Could it be, that the system wants to check the root file system (which takes long time particularly on a pendrive), and pressing a key will interrupt it?

    Can your USB stick boot other computers?

    -o-

    Maybe the following link can give you some tips towards a solution

    Portable installed system booting from UEFI & BIOS

  3. #3
    Join Date
    May 2013
    Location
    Paris, France
    Beans
    174
    Distro
    Ubuntu Gnome 16.04 Xenial Xerus

    Re: Ubuntu on USB stick not booting properly

    Quote Originally Posted by sudodus View Post
    Is your 'only real' problem, that you have to press a key after the error messages, in order to continue the boot into the USB stick? Or is it worse, for example that it takes long time before the computer responds to a key press? Or maybe I have not understood your problem at all?
    Hmm, ironic

    Quote Originally Posted by sudodus View Post
    Can your USB stick boot other computers?
    Yes, without any issue
    Last edited by actionmystique; July 3rd, 2014 at 10:19 AM.

  4. #4
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Ubuntu on USB stick not booting properly

    I'm sorry, did not mean to be ironic. It is quite possible that I have not understood your problem at all. Please explain!

    -o-

    I don't know what is wrong, but here are some observations, guesses and tips:


    Grub and Ubuntu can recognize the drives in different order, which can make it confusing to identify the drives (hd0 and /dev/sda may not always match).

    I'm quite used to warnings and error messages during booting, particularly with installed systems, that were created in another computer. But the systems will work without issues anyway (in spite of the warnings and error messages). This is typical for installed systems in USB sticks.

    Are there any differences between the installed system in the internal drive and in the USB stick? For example, there might be some proprietary driver in the installed system.

    Are there different UUIDs, or are the two systems cloned? If the UUIDs are identical, I suggest that you change them in one of the systems (and modify /etc/fstab accordingly and rerun sudo update-grub).

    Since the stick is booting other computers without any issue, I really don't know, why it gets stuck in this one. Maybe there is a hidden prompt (waiting for you to select something or simply to confirm something). What would happen if you remove the boot options 'quiet splash' and watch the output?

    Maybe some file is read or written too slowly, and not ready, when the next task needs its result, or maybe some hardware device is identified too slowly causing the same kind of problem.
    Last edited by sudodus; July 3rd, 2014 at 11:20 AM. Reason: more details about changing UUIDs

  5. #5
    Join Date
    May 2013
    Location
    Paris, France
    Beans
    174
    Distro
    Ubuntu Gnome 16.04 Xenial Xerus

    Re: Ubuntu on USB stick not booting properly

    Quote Originally Posted by sudodus View Post
    IAre there any differences between the installed system in the internal drive and in the USB stick? For example, there might be some proprietary driver in the installed system.
    No, same Ubuntu 14.04 with all updates.

    Quote Originally Posted by sudodus View Post
    IAre there different UUIDs, or are the two systems cloned? If the UUIDs are identical, I suggest that you change them in one of the systems (and modify /etc/fstab accordingly and rerun sudo update-grub).
    Different UUID.

    Quote Originally Posted by sudodus View Post
    Since the stick is booting other computers without any issue, I really don't know, why it gets stuck in this one.
    I have not been clear enough on this point, but the bootloader is located only on the hard drive of my systems, never on the USB stick.

    Quote Originally Posted by sudodus View Post
    IMaybe some file is read or written too slowly, and not ready, when the next task needs its result, or maybe some hardware device is identified too slowly causing the same kind of problem.
    My guess is there must be something wrong with the grub configuration which I have manipulated on several occasions with "grub-customizer". I'm not completely confident with that sofware which has not been updated for quite some time and withg which I have experienced some crashes recently.

    I probably should reinstall grub completely and manually. That means reading the grub manual which is going to be lengthy....

  6. #6
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Ubuntu on USB stick not booting properly

    To make the USB stick portable, you should have a bootloader installed into the head of it /dev/sdb. And you can either press a hotkey for a boot menu or chainload to it.

    This link might help you install grub into the USB stick

    https://help.ubuntu.com/community/Gr...Working_System

    This link explains chainloading

    https://help.ubuntu.com/community/In...puter_from_USB

    but it might be enough to run

    Code:
    sudo update-grub
    when booted into the internal drive's system

  7. #7
    Join Date
    May 2013
    Location
    Paris, France
    Beans
    174
    Distro
    Ubuntu Gnome 16.04 Xenial Xerus

    Re: Ubuntu on USB stick not booting properly

    Quote Originally Posted by sudodus View Post
    To make the USB stick portable, you should have a bootloader installed into the head of it /dev/sdb. And you can either press a hotkey for a boot menu or chainload to it.
    Yes, you're right. Thanks for the advice.

  8. #8
    Join Date
    May 2013
    Location
    Paris, France
    Beans
    174
    Distro
    Ubuntu Gnome 16.04 Xenial Xerus

    Re: Ubuntu on USB stick not booting properly

    A few comments after reading your links:

    • do you confirm that running "grub-install /dev/sdb" from sda won't modify the GPT of sda, but rather the GPT of sdb and only that one?
    • if I understand correctly, chainloading removes the need to change boot order in the BIOS in order to boot on the USB stick, right?
    • when I take a closer look at the boot scripts, I notice that the hd number are hard-coded: hd0, hd1... However, even though my primary HD never changes (hd0), the USB stick shares the USB ports with other devices which can be inserted in random order; this results in the USB stick being assigned different device name: sdb, sdc, sdd... It should be possible to derive the hdn from the UUID, instead of hard-coding it; same remark for ahci:

    ...
    set root='hd1,gpt2'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2 <USB-Stick-UUID>
    ...

  9. #9
    Join Date
    Nov 2011
    Location
    /dev/root
    Beans
    Hidden!

    Re: Ubuntu on USB stick not booting properly

    Quote Originally Posted by actionmystique View Post
    A few comments after reading your links:

    • do you confirm that running "grub-install /dev/sdb" from sda won't modify the GPT of sda, but rather the GPT of sdb and only that one?
    When you boot from another system you must also point to the correct location of the boot directory. (If the systems are different, you need also use chroot.) So specify --boot-directory=...

    From the wiki page:

    When using a LiveCD, due to GRUB 2 changes between Ubuntu releases, it is recommended that the user boots a LiveCD of the same release (11.10, 12.04, etc) as the release to be repaired. If the user has installed a different version of GRUB 2, use a LiveCD with the same GRUB 2 version.

    If necessary, use the fdisk command to help determine the partition on which Ubuntu is installed. The fdisk option "-l" is a lowercase "L". Look for one of the appropriate size or formatting. Running sudo blkid may provide more information to help locate the proper partition, especially if the partitions are labeled. The '

    • sudo fdisk -l
      sudo blkid

    In the following commands:

    • Use the partition number of the Ubuntu installation with mount command.
    • Do not use the partition number with the grub-install command.
    • X is the drive letter (a, b, c, etc.); Y is the partition number (1, 5, etc).
    • --boot-directory is the folder in which the GRUB folder is located. This is normally /boot but should be changed if the grub folder is located elsewhere.
    • On systems with a separate /boot partition, that partition should be mounted to /mnt/boot. For instance: sudo mount /dev/sda6 /mnt/boot
    • grub-install will restore missing files in the grub folder but will not restore intentionally deleted or corrupted files. To accomplish these tasks GRUB 2 must be completely removed and reinstalled.
      Code:
      sudo mount /dev/sdXY /mnt # Example: sudo mount /dev/sda5 /mnt
      sudo grub-install --boot-directory=/mnt/boot /dev/sdX # Example: sudo grub-install --boot-directory=/mnt/boot /dev/sda

    • if I understand correctly, chainloading removes the need to change boot order in the BIOS in order to boot on the USB stick, right?
    yes


    • when I take a closer look at the boot scripts, I notice that the hd number are hard-coded: hd0, hd1... However, even though my primary HD never changes (hd0), the USB stick shares the USB ports with other devices which can be inserted in random order; this results in the USB stick being assigned different device name: sdb, sdc, sdd... It should be possible to derive the hdn from the UUID, instead of hard-coding it; same remark for ahci:

    ...
    set root='hd1,gpt2'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd1,gpt2 --hint-efi=hd1,gpt2 --hint-baremetal=ahci1,gpt2 <USB-Stick-UUID>
    ...
    It is better to use UUID in the grub script (which is done automatically when running sudo update-grub)

  10. #10
    Join Date
    May 2013
    Location
    Paris, France
    Beans
    174
    Distro
    Ubuntu Gnome 16.04 Xenial Xerus

    Re: Ubuntu on USB stick not booting properly

    I've tried to install grub directly from the USB stick:
    • grub-install /dev/sdb
    • update-grub


    Well, it is apparently installed in the correct folders: /boot/grub ...
    However, when I try to boot directly on it, it always goes through the original grub menu on sda, even though I've checked that the USB is booted before sda on the BIOS menu.
    If I try to boot with a function key, (F11 on MSI GE60), the USB stick does not even appear on the list... Btw, the secure boot is disabled on my system.

    So, it does not work.

Page 1 of 4 123 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •