Starting linux from usb

Ubuntu Documentation

Unsupported Version
This article applies to an unsupported version of Ubuntu. More info.

Introduction

PCs use a system called the BIOS (Basic Input/Output System) to start the machine. A modern BIOS (written after 2002) usually contains USB drivers and a boot from USB option but older computers often don’t have these features. There are two common problems:

  1. They may lack a BIOS setting to allow booting from USB.
  2. They may not recognize USB drives initially, and may require operating system drivers to accomplish this.

An alternative for older machines is to let the BIOS start a minimal Linux system on a BIOS supported drive such as a floppy disk, CD, or HD, and then transfer control to the USB drive to continue booting the full operating system. A minimal Linux system contains the necessary USB drivers to continue the boot process.

Note: If the computer was made between 2002 and 2005, it may contain USB drivers, but not an option to boot from USB. In this case the GRUB bootloader can do the job directly, without the need of an initial Linux system.

Booting via GRUB

The easiest way to boot from a USB Drive is to boot via GRUB. To check if your BIOS is able to detect the USB drive and hand it over to GRUB, just run GRUB from your hard drive if it already installed, or from a GRUB boot floppy or CD. At the GRUB menu, hit the C key to enter command mode. Now search for your USB drive, using the root command to choose a drive/partition and the find command to see if you found the right one.

You can go through your devices like in this example:

Note: If you have two internal drives including your CD/DVD drive, the USB drive probably is hd2,0 and so on.

Boot the drive by entering:

For convenience, add these commands to your GRUB configuration (usually in /boot/grub/menu.lst):

Of course, if you don’t have GRUB installed on your hard drive, change the menu.lst on your GRUB floppy or CD.

If you are not able to find the drive with the help of GRUB, you have to use the Linux kernel as explained in following sections.

Warning!

The method described above constitutes the biggest security risk in Linux. Using GRUB, any OS can be booted from any USB or CD/DVD drive (as above), circumventing BIOS restrictions. Placing passwords or locking menu items (in the GRUB configuration files) does not prevent a user from booting manually using commands entered at the GRUB command-line. Once a foreign OS is booted, it can be used to access any part of an unencrypted hard drive.

The minimal Linux method

The most minimal system would be the Linux kernel itself. Though a stripped-down Linux kernel is actually small enough to fit onto a high density (1.44MB) floppy disk, the standard Ubuntu kernel is a little larger than this. Therefore a CD or HD boot is easier to create. Besides, the standard Ubuntu kernel does not have all of the drivers needed to boot a USB drive. To solve this problem, extra driver modules must be put into an «initial RAM disk» image. This image is called initrd and gets copied into the RAM during boot to enable the kernel to access the extra modules it contains.

Note: Since the kernel and initrd are copied into RAM during the boot and run from there, it is not necessary for the CD to be in the drive after booting has finished. Thus, if you only have one CD-ROM drive, it will not be tied up like it would be with a live CD.

Using a CD

To build your own boot CD, you can either use an Ubuntu system or the Live CD. Since an Ubuntu system could not be available, we will show how to build it from the Live CD.

Читайте также:  Windows 10 1909 professional x64 matros v10

Boot your Live CD (this procedure was tested with Ubuntu 9.04 beta) and wait for the whole system to load.

Open a terminal and create the CD folder structure:

Copy initrd and vmlinuz to the boot folder:

We need to include some more modules to initrd, so we do:

Which will open the text editor with that file. You need to add these lines to the end of the file:

It is always a good idea to put comments in any manually changed configurations so you don’t get confused later. Now save the file and exit gedit.

There is one small problem before we carry on: USB drives take a few seconds before they are engaged properly by Linux, and your boot would fail before the drive becomes accessible. To sort this, we need to tell the initrd to wait a few seconds before it gets carried away and fails. You can do this by running:

Now add these lines at the very top of the file:

Then save the file and exit the text editor.

Now that we have corrected the initrd‘s setup we must use this setup to rebuild the initrd using our new guidelines. To do this you must enter your system by running:

Where is the version of Linux you have installed that you wish to reconfigure. The default for Ubuntu 9.04 is 2.6.28-11-generic.

Now that you have a kernel which can boot your USB drive, it is time to put it on a bootable CD. You will need to copy the stage2_eltorito file to the top folder of the live CD (the location varies slightly between 32bit and 64bit PCs):

Next we need to create GRUB’s menu:

Add the following lines:

Note: You can change some of the other options here if you want a hidden menu or a different timeout before the default entry is booted but never set this to zero or you will not be able to enter recovery mode.

That is the entire contents of your bootable CD, so now we have to build it. Open a terminal (by default it will be in the home folder) and run (all on one line):

You should now have a CD image called UbuntuBootCDForUSB.iso which you can write to a recordable CD using many common CD writing programs, such as Brasero. If you don’t have your CD-RW drive accessible (because you are running the live CD from it) then you can copy the CD image somewhere to keep it safely stored on a real drive. You should also copy over the iso folder, like this:

Note: Don’t forget to replace /somewhereelse with a real path.

Now you just have to boot off the CD you have written whilst your USB drive is plugged in and (depending on how you set up GRUB) you will be sent into Ubuntu’s boot procedure.

Important!

Whenever Ubuntu’s kernel is updated you will not notice. This is because you will still be running the older kernel from your CD. You can fix this easily by replacing the vmlinuz and initrd.img files by the new ones in the boot folder and making a new image by rerunning the above sudo mkisofs command. New kernels will automatically contain our modifications since we added the changes to the system’s configuration files. After writing the new image to disc you can use it to boot into your new kernel. I would not recommend using a single CD-RW disc and overwriting it every time, as you will be in trouble if it doesn’t work. Instead I suggest using two CD-RW discs and updating one at a time.

Using an internal hard drive

This section is only for those who have an internal drive that can be written to and has grub installed. It makes sense if you prefer to install Ubuntu to an external hard drive instead of the internal one, but still have the possibility to customize the internal hard drive a little in order to boot the Ubuntu installation on your external drive.

Читайте также:  Tinyumbrella не запускается ошибка java windows 10

Basically, you just copy the initrd file and vmlinuz from your Ubuntu installation onto the internal disk. If you have the possibility to repartition the disk, you can make a new ext3 partition (anything more than 20MB should be enough) and use it as a «boot» partition.

Note: You don’t have to make an ext3 partition, but you need to use a partition type that GRUB can read, which is pretty much everything except NTFS. I.e. if your disk has a FAT32 partition already, you can copy vmlinuz and initrd there instead of making a new partition. In the case you only have an NTFS partition, there’s still one solution: Install «GRUB for DOS» (grubldr.exe) on the NTFS partition. See the GRUB for DOS wiki for more information.

Either boot from the Ubuntu Desktop Live CD or mount it in the filesystem. Suppose that Ubuntu is running and the live CD is mounted in /media/cdrom (as simple as sudo mount karmic-desktop-i386.iso /media/cdrom), let’s make a new dir and store vmlinuz and initrd in it:

Edit your GRUB’s menu (with gksudo gedit /boot/grub/menu.lst) and add at the end:

Now you can reboot your system with your Ubuntu Bootable usb device plugged in and choose USB FLASH DRIVE (tested with Ubuntu 9.10 Karmic Koala Alpha 3).

See Also

Building a bootable GRUB CD — This is GNU GRUB’s official documentation which I used when writing this guide

BootFromUSB (последним исправлял пользователь frankbooth 2011-08-30 10:09:08)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

Источник

Booting from USB Media: A Comprehensive Overview

While fans of different operating systems might debate which one is the most stable, reliable, flexible or user-friendly, there’s one inarguable point: Every machine – regardless of the OS – can run into issues.

And while users historically would pop a boot media disk into their DVD or CD drive, many computers no longer come with optical disk drives. As a result, booting from USB media is becoming the standard.

How you start that rescue media can vary depending on the operating system you are using, but there are a few general guidelines that can help get your machine started, regardless of the OS you prefer.

So if your system is unstable, you need to run a diagnostic tool on the hard drive, or you just want to load a Linux desktop just to see what it’s all about, let’s look at how you start your machine using rescue USB boot media.

How to boot a Mac from USB media

Getting your Mac to load from a USB drive is fairly straightforward.

  1. Insert the USB boot media into an open USB slot.
  2. Press the Power button to turn on your Mac (or Restart your Mac if it’s already on).
  3. When you hear the startup chime, press and hold the Option key. Holding that key gives you access to OS X’s Startup Manager. Once the Startup Manager screen appears, release the Option key. The utility will look for any available drives that include bootable content.
  4. Using either the pointer or arrow keys on the keyboard, select the USB drive you wish to boot from.
  5. Once selected, either hit the Return key or double-click your selection. The machine will start to boot from the USB drive.

NOTE: Have multiple USB devices connected to your Mac? Don’t worry. The Startup Manager only lists drives that include bootable content.

Читайте также:  Bat файл удаляющий windows

Boot from USB: Windows

Starting your PC using USB rescue media is not difficult, although it first requires an adjustment in the BIOS (Basic Input Output System). That’s because the BIOS settings include the boot sequence the machine follows when starting up. The boot order tells the machine which devices to search for the software needed to launch the computer and the priority each device in that search.

If you’re booting from USB media, you must change the BIOS boot order so the USB device is listed first. Otherwise the computer will load from the hard drive as normal.

Start by plugging the thumb drive into a USB port. Then to change the BIOS boot sequence:

  1. Press the Power button for your computer.
  2. During the initial startup screen, press ESC, F1, F2, F8 or F10. (Depending on the company that created your version of BIOS, a menu may appear.)
  3. When you choose to enter BIOS Setup, the setup utility page will appear.
  4. Using the arrow keys on your keyboard, select the BOOT tab. All of the available system devices will be displayed in order of their boot priority. You can reorder the devices here.
  5. Move USB to be first in the boot sequence.

NOTE: If you cannot find USB or Removable Devices among the device options, your BIOS may list it under Hard Drive Devices. In that case, you’ll need to:

  • Move Hard Drive Devices to the top
  • Expand to show all hard drive device options
  • Move USB device to the top of that hard drive list
  • Save the change and then exit the BIOS Setup.
  • The computer will restart using the new settings, booting from your USB drive.
  • Stay alert! Depending on your BIOS, you may be prompted with a message to Press any key to boot from external device and you will only have a few seconds to respond. If you do nothing, your computer will go to the next device in the boot sequence list, which will likely be your hard drive.
  • In the future, your computer will first check the USB port for boot media when starting up. That won’t be a problem, since the BIOS will move to the next device in the boot sequence . unless you keep the boot media in the USB port. Then the system will launch from that device every time.

    Linux USB Boot Process

    To boot Ubuntu from USB media, the process is very similar to the Windows instructions above.

    1. Confirm the BIOS boot sequence lists the USB drive first, or make that change as needed.
    2. After the USB flash drive is inserted into the USB port, press the Power button for your machine (or Restart if the computer is running).
    3. The installer boot menu will load, where you will select Run Ubuntu from this USB.
    4. Ubuntu will launch and you can begin to working in the system – setting preferences, reconfiguring the system as needed, or running any diagnostic tools.

    Creating USB boot media

    Regardless of the operating system you are using, booting your machine from USB media does not need to be difficult. A general understanding how your system loads can provide the basics needed to understand what is going on when you use boot media.

    Creating USB boot media doesn’t need to be difficult either, although there are several options to consider.

    For Mac users, we recommend visiting Apple’s support page on USB boot media. It provides guidance that is specific to the iteration of OS X you are running (i.e. Sierra, High Sierra, Yosemite, etc.) to help you get the boot version you need.

    Windows and Linux users might consider Acronis Disk Director 12, which includes an intuitive Boot Media Builder that streamlines the process and offers tremendous flexibility for the type and kind of boot media you can create, including WinPE media.

    Источник

    Оцените статью