Difference between revisions of "Create a Bootable USB"

From Alpine Linux
Jump to: navigation, search
(Requirements: mention that the USB drive needs to be partitioned and formatted)
(Remove redundant steps now included in 'Copying Alpine to Flash', added syslinux waitusb option)
Line 1: Line 1:
== Installing Alpine on a USB Stick - Automatical Process ==
+
== Installing Alpine on a USB Stick - Automated Process ==
 
 
  
 
=== Requirements ===
 
=== Requirements ===
Line 27: Line 26:
 
* A USB drive (flash, external HD, card reader, etc.)
 
* A USB drive (flash, external HD, card reader, etc.)
  
If you already have a running Linux system (Alpine Linux 2.1.x, Debian, Gentoo, Fedora, etc.), log in as root, insert the Alpine Linux CD-ROM into the running Linux computer, and skip the next section.
+
{{Copying Alpine to Flash|USB stick}}
 
+
=== Slow USB Devices ===
=== Boot Alpine Linux CD-ROM ===
+
Specifying the 'waitusb=X' option at the end of the syslinux.cfg line might help with certain USB devices that take a bit longer to register. X stands for the amount of seconds kernel will wait before looking for the installation media.
# Insert the Alpine Linux CD into a computer.
+
append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet '''waitusb=3'''
# Boot the computer from the Alpine Linux CD-ROM.
 
#* This step may require changes to the BIOS settings to select booting from CD.  
 
# Login with the username ''root''. No password is needed.
 
  
=== Setup bootable media ===
+
{{Installing_Alpine_see_also}}
{{Tip|If using Alpine 1.10.4 or newer, you can use this section to complete all setup, then skip to the See Also section to continue with your setup.  If not, please proceed to the next section now.}}
 
# Insert the removable USB stick into the computer.
 
# Determine the name your computer uses for your USB stick. The following step is one way to do this.
 
#* After inserting the USB stick, run the command:
 
#* {{Cmd|dmesg}}
 
#* At the end of this command you should see the name of your USB stick, likely starting with "sd". (For example: "sda").
 
#* The remainder of this document will assume that your USB stick is called /dev/sda
 
 
 
# Mount the Alpine Linux CD-ROM
 
#* {{Cmd|mount /media/cdrom}}
 
 
 
# Run the setup-bootable script to install Alpine
 
#* {{Cmd|setup-bootable /media/cdrom /dev/sda1}}
 
 
 
{{Tip|You can now skip to the See Also section.}}
 
{{Copying Alpine to Flash|USB stick}}
 

Revision as of 09:46, 16 November 2011

Installing Alpine on a USB Stick - Automated Process

Requirements

To put Alpine on a USB drive, you will need:

  • An Alpine Linux ISO image file (Download)
  • A partitioned and formatted USB drive
  • UNetbootin
Note: UNetbootin is available for many distributions and Windows.

Process

After the launch of UNetbootin, click the Diskimage radio button, and then the ... button to select the Alpine ISO image.

size=400

When you selected your USB device under Device and press OK' to proceed. When UNetbootin is done, your USB drive is ready to use.

Installing Alpine on a USB Stick - Manual Process

This process applies to Alpine Linux 1.9.0 or later, and results in a run-from-ram style installation.

Requirements

In order to follow this document, you will need:

  • Alpine Linux CD-ROM (Download a .iso file containing an Alpine release.)
  • A USB drive (flash, external HD, card reader, etc.)

The following part describes various ways how to create bootable USB stick with Alpine Linux.

Clone ISO image content to USB stick (Alpine Linux from 3.3.0 and later)

From Alpine Linux 3.3.0, the generated ISO's are a hybridISO, which means they contain a valid MBR and can be raw copied directly to the USB stick, Hard Drive (If you really know what you're doing), or burnt to a CD/DVD.

If the USB stick is in a Unix/Linux/OSX system, you will need to find out what the USB device is. There are various utilities to determine the device name (e.g. /dev/sdx) for your USB device. One way is:

$ sudo fdisk -l

If it is still unclear which is your USB's device name, in Linux you could try sudo lsblk -a ; or use parted (sudo parted -l).

Then, in order to dd the iso, ensure that your usb drive is not mounted, as various desktop environments automatically mount usb pen drives:

$ sudo umount /dev/sdx

Next, change to the directory where your Alpine .iso file is located, for example:

$ cd ~/Downloads
Tango-dialog-warning.png
Warning: The following instruction will destroy data on the device being written to - be sure that you have identified your USB device name correctly first!


Then you can use dd to copy the iso to it. Change alpine.iso in the following command to the name of your .iso file; and change /dev/sdx to the name of your pen drive's device name. The following command may take a few minutes to execute:

 $ sudo dd if=alpine.iso of=/dev/sdx && sync

Copy ISO content to USB stick as individual files

Tango-dialog-warning.png
Warning: We assume here sda is your USB stick which would hold bootable Alpine Linux files.


The following procesure is for Alpine Linux distribution itself, if you are using other Linux distro or other operating system you should know the best how to install syslinux and where mbr.bin file is located on your filesystem.

  1. If you created a new partition above, format the USB stick with a FAT32 filesystem (replacing sda with your USB stick name):

    apk add dosfstools
    mkdosfs -F32 /dev/sda1

  2. Install syslinux and MBR (replacing sda with your USB stick name):

    apk add syslinux
    dd if=/usr/share/syslinux/mbr.bin of=/dev/sda
    syslinux /dev/sda1

  3. Copy the files to the USB stick (replacing sda with your USB stick name):

    mkdir -p /media/sda1 mount -t vfat /dev/sda1 /media/sda1 cd /media/cdrom cp -a .alpine-release * /media/sda1/ umount /media/sda1

  4. (Optional) Remove any apkovl files that were transfered as part of the copy process. This should be done if you wish to have a fresh install. Replace sda with your USB stick name)

    mount -t vfat /dev/sda1 /media/sda1 rm /media/sda1/*.apkovl.tar.gz umount /media/sda1

Create bootable USB stick from ISO on Windows

Additionally to the method above for Linux systems, there is also the Rufus program available, which allows writing such bootable USB flash drives under Windows.

Note: Rufus has been tested and works on Alpine Linux 3.12.x with the following settings
  • Partition scheme: MBR
  • Target system: BIOS or UEFI
  • File system: FAT32
  • Cluster size: 4096 bytes (default)

Troubleshooting

Wrong Device Name

If you cannot boot from the USB stick and you see something like:

Mounting boot media failed.
initramfs emergency recovery shell launched. Type 'exit' to continue boot

then it is likely that the device name in syslinux.cfg is wrong. You should replace the device name in this line:

append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet

with the proper device name.

  • For boot from USB, the device name should be 'usbdisk' (as shown above)
  • For other options, you can run cat /proc/partitions to see the available disks (i.e. 'sda' or 'sdb')

Non-FAT32 Filesystems

When your USB stick is formatted with a filesystem other than FAT32, you might have to specify the necessary filesystem modules in the boot parameters.

To do so, mount the USB stick and change the syslinux.cfg file line from

append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet

to

append initrd=/boot/grsec.gz alpine_dev=usbdisk:ext3 modules=loop,cramfs,sd-mod,usb-storage,ext3 quiet

in the case of an ext3 formatted partition. A similar procedure might apply to other filesystems (if they are supported by syslinux and the Alpine Linux kernel).

Slow USB Devices

Specifying the 'waitusb=X' option at the end of the syslinux.cfg line might help with certain USB devices that take a bit longer to register. X stands for the amount of seconds kernel will wait before looking for the installation media.

append initrd=/boot/grsec.gz alpine_dev=usbdisk:vfat modules=loop,cramfs,sd-mod,usb-storage quiet waitusb=3

Alpine Linux has some special applications that helps you to use it in the way you want.
Some of the first scripts you are suggested to use is:

  • setup-alpine (Configures all basic things on your Alpine Linux)
  • setup-acf (was named setup-webconf before Alpine 1.9 beta 4) (Configures ACF (webconfiguration) so you can manage your box through https)
Note: Just type any of the above commands on your console and hit Enter to execute the script.

Other useful pages