*** HELP *** Need Step-by-Step guide or application on Booting from USB 3.0


Recommended Posts

Let me set this up for you guys...

 

1) I have Windows 7 on my main hard drive

2) I have a USB 3.0 32 Gigabyte stick that is FAT32.

3) I do not have GRUB installed on my Windows 7 Hard drive

4) My Bios is set to boot to USB first and then DVD and then Hard drive (This has been validated)

5) I have a computer with 16 Gigabytes of DDR3 - 1600 RAM so I don't really need a Linux scratch disk

6) When I use a Live CD ISO to USB it boots fine, but when I try to add in persistence by formatting and installing the boot on SB1 it works great but it will not boot. 

 

    I love virtual machines, but some programs like Music software needs Jack, so I am trying to install Ubuntu Studio like I would on a hard drive but do so on a USB stick and it should boot, but it doesn't it just boots directly into Windows.  I know that I have done it the right way, I have had help from someone from IRC and I have used Youtube and it just would not boot.  This Linux guru on IRC said it's because I don't have GRUB on my Windows 7 Hard Drive, but I told him that I wanted to make sure first before causing a mess that might make me lose data. 

 

   Now, when I try the ISO to USB programs it boots fine, but that has no persistence, so all my changes are lost when I reboot. 

 

   Is there a program that will make this very easy and still keep my persistence?  Now let me say that I don't want 4 Gigs of persistence, I want as much as my USB stick allows.  How can I do this without using GRUB?

Link to comment
Share on other sites

Consider adding a 2nd HDD and disconnecting your main HDD for your testing then you can set Windows 7's boot loader to boot the 2nd HDD later if you want dual boot. Safest approach in my opinion.

Getting say Ubuntu to boot correctly off usb into an installed environment as opposed to Live is not exactly easy unless you can do GPT partition booting from my experiences.

I have a PCI-E/USB based internal SDCard reader which I can boot off of for Ubuntu which is GPT / Secureboot then I use my SSD for Windows 8.

Link to comment
Share on other sites

Consider adding a 2nd HDD and disconnecting your main HDD for your testing then you can set Windows 7's boot loader to boot the 2nd HDD later if you want dual boot. Safest approach in my opinion.

Getting say Ubuntu to boot correctly off usb into an installed environment as opposed to Live is not exactly easy unless you can do GPT partition booting from my experiences.

I have a PCI-E/USB based internal SDCard reader which I can boot off of for Ubuntu which is GPT / Secureboot then I use my SSD for Windows 8.

 

   What if I don't have a second HDD and don't have money for another one?  Is there another easier way?  I know some Linux distros allow you to boot directly from USB with persistence, but I want to do this with any distro and have more than 4 GB of Persistence.   I can do this from a Virtual Machine I suppose.

Link to comment
Share on other sites

use Rufus to create bootable USB for any nix distro you want.

 

http://rufus.akeo.ie/

 

Doesn't support Persistence, so it's useless for me :-(  Thanks for the help though. 

 

I don't want to have just a "Live" bootable USB stick.  I want it installed or to have Persistence so that I can save my changes.

Think of a portable computer and I can take it anywhere and boot.  I have a memory stick that is 32 Gigabytes and I would like to buy another that is 64 or 128 GB with USB 3.0 and fast flash so I can use it as a portable Linux system and take my desktop with me. 

 

Rufus will just take an ISO and turn it into a bootable USB, which won't allow me to save changes, it's basically the same as taking a LIVE CD or DVD and burning and booting into that, it won't allow you to save changes.

Link to comment
Share on other sites

I guess, when you create the USB from Rufus or any tool, you can save change to your usb stick since you have write permission on USB stick.

I never had such experience, but just guessing ....

if its not the case, you can partition your usb stick into duo, install the linux distro into 1st partition & mount the second partition with rw permission.

Link to comment
Share on other sites

You should have no problem booting GRUB from your USB disk. I don't know who told you that you need it on your primary disk as well, but he was blatantly wrong. Although most utilities for creating bootable USB flash drives from Linux ISOs use Syslinux, GRUB works just as well, if not better. For years I have maintained a utility that is used internally at my work place to boot various Windows, Linux, and DOS-based disk images from a USB flash drive - and it makes heavy use of GRUB 2. We have booted this image on thousands of computers from various manufacturers, although primarily Dell and Lenovo, and it has always worked perfectly. (Or I have spent a day or two tracing the issue and writing a patch, but that doesn't happen very often anymore now that the software has matured.)

 

You essentially have two methods for achieving persistence on your disk. The first, and probably easiest, method is to write the Ubuntu ISO to your flash drive and create a persistence file. This is essentially the method Xahid was suggesting, except I recommend that you use UNetbootin to create the image. (If you are using Windows or OS X download it from the project website. If you are using Linux it should be available in your distribution's repository.) To use it, (1) format your flash drive as FAT32 and mount it; (2) select "Diskimage" in UNetbootin and point it to your Ubuntu Studio ISO; (3) enter a value for the "space used to preserve files across reboots", which will be adjusted to use the maximum space available on your flash drive if it exceeds the actual space available; (4) select your flash drive from the "Drive:" drop-down box; and (5) click "OK" to create your image.

 

The other viable method is to boot from your Ubuntu Studio disc and choose to install it to your flash drive. This will obviously achieve persistence because it will be a full Ubuntu installation rather than the hybrid employed by the first method. The installation should proceed smoothly, but you need to be very careful to choose to install GRUB to the flash drive NOT to the MBR during the installation! You should probably have your Windows 7 disc (or the always handy Super Grub2 disk) on-hand just-in-case so you can repair your bootloader if necessary. Also make sure to tell Ubuntu to install to a single partition with no swap partition. You will have to modify the defaults to achieve this, but it should not be hard.

 

Each method has different advantages. The first method will probably boot faster on most machines, and will initially use less disk space. However, you will have some duplication in the persistence file if you install system updates or modify system files since the base system image cannot be directly modified. This caveat could also negatively affect system performance in some cases. You will also have less RAM available for use than with the second method because of the merged filesystem overlay. Additionally this method uses Syslinux to boot instead of GRUB 2. The second method is a full Ubuntu installation and has all the advantages thereof, including slightly more available RAM compared to the first method. It will initially use more disk space than the first method, but may actually use less over time depending on your use case. The principal disadvantage of this method is that it will boot more slowly. If you are planning on using this installation exclusively on systems that have USB 3, the speed difference will not be too noticeable. If you will also be using this on systems with USB 2, the speed difference will be very stark.

 

In summary, method 1 is easier and faster at the expense of more RAM, and method 2 is a full Ubuntu installation limited only by the speed of your flash drive (and the speed of the USB host controller on your system).

Link to comment
Share on other sites

You should have no problem booting GRUB from your USB disk. I don't know who told you that you need it on your primary disk as well, but he was blatantly wrong. Although most utilities for creating bootable USB flash drives from Linux ISOs use Syslinux, GRUB works just as well, if not better. For years I have maintained a utility that is used internally at my work place to boot various Windows, Linux, and DOS-based disk images from a USB flash drive - and it makes heavy use of GRUB 2. We have booted this image on thousands of computers from various manufacturers, although primarily Dell and Lenovo, and it has always worked perfectly. (Or I have spent a day or two tracing the issue and writing a patch, but that doesn't happen very often anymore now that the software has matured.)

 

You essentially have two methods for achieving persistence on your disk. The first, and probably easiest, method is to write the Ubuntu ISO to your flash drive and create a persistence file. This is essentially the method Xahid was suggesting, except I recommend that you use UNetbootin to create the image. (If you are using Windows or OS X download it from the project website. If you are using Linux it should be available in your distribution's repository.) To use it, (1) format your flash drive as FAT32 and mount it; (2) select "Diskimage" in UNetbootin and point it to your Ubuntu Studio ISO; (3) enter a value for the "space used to preserve files across reboots", which will be adjusted to use the maximum space available on your flash drive if it exceeds the actual space available; (4) select your flash drive from the "Drive:" drop-down box; and (5) click "OK" to create your image.

 

The other viable method is to boot from your Ubuntu Studio disc and choose to install it to your flash drive. This will obviously achieve persistence because it will be a full Ubuntu installation rather than the hybrid employed by the first method. The installation should proceed smoothly, but you need to be very careful to choose to install GRUB to the flash drive NOT to the MBR during the installation! You should probably have your Windows 7 disc (or the always handy Super Grub2 disk) on-hand just-in-case so you can repair your bootloader if necessary. Also make sure to tell Ubuntu to install to a single partition with no swap partition. You will have to modify the defaults to achieve this, but it should not be hard.

 

Each method has different advantages. The first method will probably boot faster on most machines, and will initially use less disk space. However, you will have some duplication in the persistence file if you install system updates or modify system files since the base system image cannot be directly modified. This caveat could also negatively affect system performance in some cases. You will also have less RAM available for use than with the second method because of the merged filesystem overlay. Additionally this method uses Syslinux to boot instead of GRUB 2. The second method is a full Ubuntu installation and has all the advantages thereof, including slightly more available RAM compared to the first method. It will initially use more disk space than the first method, but may actually use less over time depending on your use case. The principal disadvantage of this method is that it will boot more slowly. If you are planning on using this installation exclusively on systems that have USB 3, the speed difference will not be too noticeable. If you will also be using this on systems with USB 2, the speed difference will be very stark.

 

In summary, method 1 is easier and faster at the expense of more RAM, and method 2 is a full Ubuntu installation limited only by the speed of your flash drive (and the speed of the USB host controller on your system).

 

I want to do method #2, but it never boots.  it will boot only to Windows.

 

  I have made sure that it writes to the SB1 (USB 3 stick) and it does, I can see it writing and the hard drive light is off.

I know I can get it to work with method #1 easily as I have tried it before in another ISO to USB program and it booted great.  However, when I do the method #2 it won't boot to the stick, it just goes directly to the hard drive and boots windows

 

  Do you have any ideas on why this happens?

 

  I want method #2 but I can't seem to get it to work at all.  It is set for "/" and Ext4 on sb1 (which I verified as the USB Stick.  The Boot loader is set to be the USB stick and no other sticks are in the computer, just the one.  

Link to comment
Share on other sites

I have seen a few computers that refuse to load GRUB 2 (or GRUB Legacy) from a secondary disk, but it is fairly rare. GRUB itself has a number of workarounds for broken firmware, which is often what causes this type of problem. Unfortunately its remediation isn't foolproof so sometimes it fails to load, or the firmware fails to load its core image. The same thing happens to Syslinux sometimes too, but I have yet to see them both fail on the same computer. Therefore my solution was to create a secondary flash drive with Syslinux that would chainload my primary flash drive with GRUB 2. Since we know that Syslinux works properly from your flash drive, I have a variation of this approach that might work for you.

 

To make this procedure as simple as possible, I am going to assume that you already have Ubuntu installed using the second method I described in my last post, and you are currently booted into that installation. I have not gone completely insane yet; I know that the whole problem we are trying to solve is booting into the installation! Use Super Grub2 Disk to boot into your installation temporarily; then follow this procedure to make it permanent.

 

The first step is to install Extlinux (the variant of Syslinux that works on EXT2/3/4 filesystems) on your flash drive. Then you simply need to create a syslinux.cfg and reboot. Easy. Unfortunately, every time Canonical pushes a kernel update for Ubuntu you will have to modify your Syslinux configuration file to take advantage of it. The same is true with GRUB 2, but there is an automated utility - update-grub - that takes care of generating a new grub.cfg for you. Therefore to make this as easy as possible I hacked together a Perl script - grubcfg2syslinuxcfg.pl - that can be invoked by update-grub after it has generated a new grub.cfg to keep your syslinux.cfg in sync with it. You will need to copy/pate the contents of this script into grubcfg2syslinuxcfg.pl before following my instructions below.

 

grubcfg2syslinuxcfg.pl:

#!/usr/bin/perl
#
# GRUB 2 to SYSLINUX Configuration Translator
# Version:  0.1.1
# Released: 13 July 2013
#
# (c) 2013 xorangekiller
#
# This package is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#

use strict;
use warnings;

use Tie::File;
use Fcntl;

# Configuration file constants
use constant GRUB_CFG => '/boot/grub/grub.cfg';
use constant SYSLINUX_CFG => '/boot/syslinux/syslinux.cfg';

# Stages for parsing the GRUB 2 configuration file
use constant STAGE_MENUENTRY => 0;
use constant STAGE_KERNEL => 1;
use constant STAGE_INITRD => 2;

my @file; # Array tied to a configuration file
my @args; # Arguments parsed from the GRUB 2 configuration file
my $arg; # Hash of a single argument in @args
my $stage; # Position tracking in the GRUB 2 configuration file

tie @file, 'Tie::File', GRUB_CFG, mode => O_RDONLY or die "$!\n";
$stage = STAGE_MENUENTRY;
for my $line (@file)
{
    if (my ($menuentry) = $line =~ /menuentry[\s]+["'](.+)["'][\s]+.+--class gnu-linux/)
    {
        $stage == STAGE_MENUENTRY or die "Expected stage " . STAGE_MENUENTRY . " but got $stage instead!\n";
        $arg = {};
        $arg->{'menuentry'} = $menuentry;
        $stage = STAGE_KERNEL;
    }
    elsif ($stage > 0)
    {
        if (my ($kernel, $kargs) = $line =~ /linux[\s]+(.*vmlinuz[A-Za-z0-9.\-_]*)[\s]+(.+)/)
        {
            $stage == STAGE_KERNEL or die "Expected stage " . STAGE_KERNEL . " but got $stage instead!\n";
            $arg->{'kernel'} = $kernel;
            $arg->{'kargs'} = $kargs;
            $stage = STAGE_INITRD;
        }
        elsif (my ($initrd) = $line =~ /initrd[\s]+(.*initrd.img[A-Za-z0-9.\-_]*)/)
        {
            $stage == STAGE_INITRD or die "Expected stage " . STAGE_INITRD . " but got $stage instead!\n";
            $arg->{'initrd'} = $initrd;
            push (@args, $arg);
            $stage = STAGE_MENUENTRY;
        };
    };
};
untie @file;

open (SYSLINUX_CFG_FILE, '>' . SYSLINUX_CFG) or die "$!\n";
print SYSLINUX_CFG_FILE 'DEFAULT ' . $args[0]->{'menuentry'} . "\n\n";
for $arg (@args)
{
    print SYSLINUX_CFG_FILE "LABEL " . $arg->{'menuentry'} . "\n";
    print SYSLINUX_CFG_FILE "\tKERNEL " . $arg->{'kernel'} . "\n";
    print SYSLINUX_CFG_FILE "\tAPPEND " . ' ' . $arg->{'kargs'} . ' initrd=' . $arg->{'initrd'} . "\n";
    print SYSLINUX_CFG_FILE "\n";
};
close (SYSLINUX_CFG_FILE);

exit 0;

Instructions:

sudo -s

apt-get install extlinux
extlinux --install /boot

# WARNING: Change "/dev/sda" in the following commands to the disk containing /boot.
# If you ignore this directive, you will overwrite the bootloader on your primary disk!
dd if=/usr/lib/extlinux/mbr.bin of=/dev/sda bs=440 count=1 conv=notrunc
parted /dev/sda set 1 boot on

mkdir /boot/syslinux
cp grubcfg2syslinuxcfg.pl /etc/grub.d/90_syslinux
chown root:root /etc/grub.d/90_syslinux
chmod 755 /etc/grub.d/90_syslinux
update-grub

reboot

Edit: I added a minor bugfix to grubcfg2syslinuxcfg.pl.

 

Edit 2: After some testing I discovered how to grubcfg2syslinuxcfg.pl in some new ways, so this edit has a new version with those fixes.

Edited by xorangekiller
Link to comment
Share on other sites

I wrote a new script that completely automates the procedure I outlined in my last post. It can be run from within the installation for which you wish to use Extlinux instead of GRUB, just like my previous instructions require, but it can also be run directly from your Ubuntu 13.04 installation disc after you have completed the installation (or anytime thereafter). Therefore there is no need to download Super Grub2 Disk to boot the Ubuntu installation on your flash drive before installing Extlinux! I have extensively tested both scripts in a test environment, so I am fairly sure they work.

 

Before following my instructions below you must copy/paste the following script into the home directory of the live user on the Ubuntu installation disc (or your home folder if you are running this from within the installation itself). My instructions assume it is present in ~ as ubuntu-extlinux-bootstrap.sh

#!/bin/sh
#
# Ubuntu Extlinux Bootstrapper
# Version:  0.1
# Released: 13 July 2013
#
# This script should be run from an Ubuntu 13.04 installation disc after
# the installation is complete. It will install Extlinux as the default
# bootloader in place of GRUB 2. However it will be configured so that
# the changes made to grub.cfg by update-grub when Linux kernel updates
# are installed are also reflected in syslinux.cfg.
#
# Check the following thread for a more detailed explanation of this
# script's operation:
#   https://www.neowin.net/forum/topic/1163976-help-need-step-by-step-
#   guide-or-application-on-booting-from-usb-30
#
# (c) 2013 xorangekiller
#
# This package is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#

# Configuration constants
target='/target'
apt_get='apt-get --yes --force-yes'

# Target status indicators
TARGET_UNKNOWN=0
TARGET_IS_ROOT=1
TARGET_MOUNTED_USER=2
TARGET_MOUNTED_HERE=3

# Gobal variables
dev=''
dev_num=1
root_dev=''
chroot=''
target_status=$TARGET_UNKNOWN

mount_target()
{
    if [ $target_status -eq $TARGET_MOUNTED_HERE ]; then
        [ -d $target ] || mkdir -p $target
        
        mount $dev $target -o rw,errors=remount-ro || exit 5
        mount /proc $target/proc -o rw,bind || exit 6
        mount /sys $target/sys -o rw,bind || exit 6
        mount /dev/pts $target/dev/pts -o rw,noexec,nosuid,gid=5,mode=620,bind || exit 6
        mount /run $target/run -o bind || exit 6
        
        chroot="chroot $target"
    elif [ $target_status -eq $TARGET_MOUNTED_USER ]; then
        chroot="chroot $target"
    elif [ $target_status -eq $TARGET_IS_ROOT ]; then
        chroot=''
    else
        echo "ERROR: Unknown target status $target_status"
        exit 17
    fi
}

umount_target()
{
    $chroot mount -l | awk '{if($3 == "/boot") print $3}' | grep -Eqs '.+'
    [ $? -eq 0 ] && $chroot umount /boot
    
    if [ $target_status -eq $TARGET_MOUNTED_HERE ]; then
        umount $target/run
        umount $target/dev/pts
        umount $target/sys
        umount $target/proc
        umount $target
        
        ls -1 $target 2>/dev/null | grep -Eqs '.+'
        [ $? -eq 0 ] && rm -rf $target
    fi
}

if [ $(id -u) -ne 0 ]; then
    echo "ERROR: This script requires superuser privileges!"
    exit 1
fi

if [ "x$1" = "x" ]; then
    echo "Usage: $0 TARGET_DEVICE"
    exit 2
fi

dev=$1
if [ ! -b $dev ]; then
    echo "ERROR: TARGET_DEVICE must be a block device (normally /dev/sda1 or similar)"
    exit 3
fi

echo $dev | grep -qs '/dev/disk/by'
if [ $? -eq 0 ]; then
    root_dev=$(ls -l $dev | awk '{print $NF}' | grep -E '\.\./\.\./[a-z]+[0-9]*')
    if [ "x$root_dev" = "x" ]; then
        echo "ERROR: $dev is an invalid TARGET_DEVICE"
        exit 10
    fi
else
    root_dev=$dev
fi
dev_num=$(echo $root_dev | awk 'BEGIN {FS="/"} {n=split($NF,array,""); for(i=1;i<=n;i++) if(array[i] ~ /[0-9]/) {printf array[i]}; printf "\n"}')
root_dev=/dev/$(echo $root_dev | awk 'BEGIN {FS="/"} {n=split($NF,array,""); for(i=1;i<=n;i++) if(array[i] ~ /[0-9]/) {break} else {printf array[i]}; printf "\n"}')
[ "x$dev_num" = "x" ] && dev_num=0
if [ ! -b $root_dev ]; then
    echo "ERROR: Failed to puzzle root device for $dev"
    exit 11
fi

mount -l | awk "{if(\$1 == \"$dev\") print \$0}" | grep -Eqs '.+'
if [ $? -eq 0 ]; then
    mount -l | awk "{if(\$1 == \"$dev\") print \$3}" | grep -Eqs "^${target}\$"
    if [ $? -eq 0 ]; then
        echo "WARNING: $dev is already mounted on $target"
        target_status=$TARGET_MOUNTED_USER
    else
        mount -l | awk "{if(\$1 == \"$dev\") print \$3}" | grep -Eqs "^/\$"
        if [ $? -eq 0 ]; then
            echo "WARNING: $dev is the current root filesystem"
            target=''
            target_status=$TARGET_IS_ROOT
        else
            target=$(mount -l | awk "{if(\$1 == \"$dev\") print \$3}")
            echo "ERROR: $dev is already mounted on $target"
            exit 4
        fi
    fi
else
    target_status=$TARGET_MOUNTED_HERE
fi

mount_target

if [ ! -e $target/boot/grub/grub.cfg ]; then
    grubcfg_exists=0
    
    ls -1 $target/boot 2>/dev/null | grep -Eqs '.+'
    if [ $? -eq 1 ]; then
        cat $target/etc/fstab | awk '{if($1 !~ /^\s*#/ && $2 == "/boot") print $2}' | grep -Eqs '.+'
        if [ $? -eq 0 ]; then
            $chroot mount /boot
            if [ $? -ne 0 ]; then
                umount_target
                exit 7
            fi
            [ -e $target/boot/grub/grub.cfg ] && grubcfg_exists=1
        fi
    fi
    
    if [ $grubcfg_exists -eq 0 ]; then
        echo "ERROR: Cannot find target grub.cfg"
        umount_target
        exit 8
    fi
fi

$chroot which extlinux 1>/dev/null 2>&1
if [ $? -ne 0 ]; then
    $chroot $apt_get install extlinux
    if [ $? -ne 0 ]; then
        echo "ERROR: extlinux cannot be installed!"
        umount_target
        exit 9
    fi
fi
## FIXME: Extlinux should not need to be installed on the host and in the chroot
if [ "x$chroot" != "x" ]; then
    which extlinux 1>/dev/null 2>&1
    if [ $? -ne 0 ]; then
        $apt_get install extlinux
        if [ $? -ne 0 ]; then
            echo "ERROR: extlinux failed to install on this host"
            umount_target
            exit 19
        fi
    fi
fi
extlinux --install $target/boot
if [ ! -f $target/boot/ldlinux.sys ]; then
    echo "ERROR: Failed to install Extlinux to $target/boot/ldlinux.sys"
    umount_target
    exit 18
fi
dd if=$target/usr/lib/extlinux/mbr.bin of=$root_dev bs=440 count=1 conv=notrunc
if [ $? -ne 0 ]; then
    echo "ERROR: Installation of Extlinux MBR to $root_dev failed!"
    umount_target
    exit 12
fi

which parted 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
    parted $root_dev set $dev_num boot on
else
    $chroot which parted 1>/dev/null 2>&1
    if [ $? -ne 0 ]; then
        $chroot $apt_get install parted
        if [ $? -ne 0 ]; then
            echo "ERROR: parted cannot be installed!"
            umount_target
            exit 13
        fi
    fi
    $chroot parted $root_dev set $dev_num boot on
fi

if [ ! -d $target/boot/syslinux ]; then
    mkdir $target/boot/syslinux
    if [ $? -ne 0 ]; then
        echo "ERROR: Failed to create directory $target/boot/syslinux"
        umount_target
        exit 14
    fi
fi

if [ -e $target/etc/grub.d/90_syslinux ]; then
    echo "WARNING: $target/etc/grub.d/90_syslinux already exists and will not be verified"
else
    cat << 'EOF' > $target/etc/grub.d/90_syslinux
#!/usr/bin/perl
#
# GRUB 2 to SYSLINUX Configuration Translator
# Version:  0.1.1
# Released: 13 July 2013
#
# (c) 2013 xorangekiller
#
# This package is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this package; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#

use strict;
use warnings;

use Tie::File;
use Fcntl;

# Configuration file constants
use constant GRUB_CFG => '/boot/grub/grub.cfg';
use constant SYSLINUX_CFG => '/boot/syslinux/syslinux.cfg';

# Stages for parsing the GRUB 2 configuration file
use constant STAGE_MENUENTRY => 0;
use constant STAGE_KERNEL => 1;
use constant STAGE_INITRD => 2;

my @file; # Array tied to a configuration file
my @args; # Arguments parsed from the GRUB 2 configuration file
my $arg; # Hash of a single argument in @args
my $stage; # Position tracking in the GRUB 2 configuration file

tie @file, 'Tie::File', GRUB_CFG, mode => O_RDONLY or die "$!\n";
$stage = STAGE_MENUENTRY;
for my $line (@file)
{
    if (my ($menuentry) = $line =~ /menuentry[\s]+["'](.+)["'][\s]+.+--class gnu-linux/)
    {
        $stage == STAGE_MENUENTRY or die "Expected stage " . STAGE_MENUENTRY . " but got $stage instead!\n";
        $arg = {};
        $arg->{'menuentry'} = $menuentry;
        $stage = STAGE_KERNEL;
    }
    elsif ($stage > 0)
    {
        if (my ($kernel, $kargs) = $line =~ /linux[\s]+(.*vmlinuz[A-Za-z0-9.\-_]*)[\s]+(.+)/)
        {
            $stage == STAGE_KERNEL or die "Expected stage " . STAGE_KERNEL . " but got $stage instead!\n";
            $arg->{'kernel'} = $kernel;
            $arg->{'kargs'} = $kargs;
            $stage = STAGE_INITRD;
        }
        elsif (my ($initrd) = $line =~ /initrd[\s]+(.*initrd.img[A-Za-z0-9.\-_]*)/)
        {
            $stage == STAGE_INITRD or die "Expected stage " . STAGE_INITRD . " but got $stage instead!\n";
            $arg->{'initrd'} = $initrd;
            push (@args, $arg);
            $stage = STAGE_MENUENTRY;
        };
    };
};
untie @file;

open (SYSLINUX_CFG_FILE, '>' . SYSLINUX_CFG) or die "$!\n";
print SYSLINUX_CFG_FILE 'DEFAULT ' . $args[0]->{'menuentry'} . "\n\n";
for $arg (@args)
{
    print SYSLINUX_CFG_FILE "LABEL " . $arg->{'menuentry'} . "\n";
    print SYSLINUX_CFG_FILE "\tKERNEL " . $arg->{'kernel'} . "\n";
    print SYSLINUX_CFG_FILE "\tAPPEND " . ' ' . $arg->{'kargs'} . ' initrd=' . $arg->{'initrd'} . "\n";
    print SYSLINUX_CFG_FILE "\n";
};
close (SYSLINUX_CFG_FILE);

exit 0;
EOF
    chown root:root $target/etc/grub.d/90_syslinux
    chmod 755 $target/etc/grub.d/90_syslinux
fi
if [ ! -x $target/etc/grub.d/90_syslinux ]; then
    echo "ERROR: $target/etc/grub.d/90_syslinux failed the execution test!"
    echo "Extlinux configuration file cannot be automatically generated"
    umount_target
    exit 15
fi
$chroot update-grub
if [ $? -ne 0 ]; then
    echo "WARNING: update-grub failed to generate a new GRUB 2 configuration file"
    echo "OVERRIDE: Executing $target/etc/grub.d/90_syslinux hook anyway . . ."
    $chroot /etc/grub.d/90_syslinux
    if [ $? -ne 0 ]; then
        echo "ERROR: GRUB 2 to SYSLINUX Configuration Translator failed to generate a Syslinux configuration file!"
        umount_target
        exit 16
    fi
fi

umount_target

echo "SUCCESS: Extlinux is now your default bootloader on $dev"
exit 0

Once the Ubuntu 13.04 installation is complete click the "continue testing" button from the live disc, open a terminal, and run the following commands. Note that you will need to replace /dev/sda1 with the designation of the disk you chose to install Ubuntu onto. If you split it up into multiple partitions (such as /, /boot, /home, /opt, /etc), you will need to specify the root partition (the one that mounts to /) of your new installation.

chmod 755 ubuntu-extlinux-bootstrap.sh
sudo ./ubuntu-extlinux-bootstrap.sh /dev/sda1
sudo reboot

If everything went well, you should be able to boot from the Ubuntu installation using Extlinux instead of GRUB when you reboot.

  • Like 1
Link to comment
Share on other sites

I wrote a new script that completely automates the procedure I outlined in my last post. It can be run from within the installation for which you wish to use Extlinux instead of GRUB, just like my previous instructions require, but it can also be run directly from your Ubuntu 13.04 installation disc after you have completed the installation (or anytime thereafter). Therefore there is no need to download Super Grub2 Disk to boot the Ubuntu installation on your flash drive before installing Extlinux! I have extensively tested both scripts in a test environment, so I am fairly sure they work.

 

Before following my instructions below you must copy/paste the following script into the home directory of the live user on the Ubuntu installation disc (or your home folder if you are running this from within the installation itself). My instructions assume it is present in ~ as ubuntu-extlinux-bootstrap.sh

 

  I am kind of sorry that you went through all of this work.  I don't need it.  The problem has been resolved.

 

  My desktop is brand new, all of the parts are from 2012 and the motherboard has a "Legacy+UEFI" mode and then another mode that is "UEFI Only".

 

  On the Legacy+UEFI mode, my USB stick was first on booting and the DVD and then hard drive.  However, the UEFI ONLY mode the USB stick was not first and this is why it wasn't booting.  When I changed that it booted normally.

 

  So, it's very confusing to have two different BIOS modes for OSes and have two different boot settings for each mode.   They are now set the same with USB/DVD/HDD.  Does this make sense?

 

  So, basically when I used ISO to USB programs it would work with the legacy setting, but when I tried it for Ubuntu Studio, it would not work.  Now, everything works as it should.  

 

  Thanks for your help. :) :) :) :)

Link to comment
Share on other sites

I probably should have asked about UEFI support. That somehow didn't occur to me yesterday, or apparently the day before either. Lesson learned. It completely explains why you were having the problem you described in your initial post. You would just need to install Ubuntu with the UEFI version of GRUB, which works fairly well in my experience, and the full installation method should work with no further alterations. UEFI + Secure Boot, as opposed to just UEFI, would cause other problems and still prevent even the UEFI version of GRUB from booting, but that is another discussion entirely. That said, I'm glad you solved your problem. Maybe my ridiculously long bootstrap script will help someone else someday when Google directs him to this thread. I regret nothing.

Link to comment
Share on other sites

This topic is now closed to further replies.