Create a Bootable Device: Difference between revisions

From Alpine Linux
(Added manual steps to create bootable USB)
m (Changed some phrasings in dd instructions)
(27 intermediate revisions by 13 users not shown)
Line 1: Line 1:
= Alpine on USB =
== Manual Process ==
=== What you will need ===
* USB memory stick
* Computer
* Alpine Linux CD
CD images can be downloaded from the Alpine Linux Web site (http://wiki.alpinelinux.org).
=== Prepare to modify USB Stick ===
* Insert the Alpine Linux CD into a computer.
* Boot the computer from the Alpine Linux CD.
This step may require changes to the BIOS settings to select booting from CD.
* Login with the username '''root'''. No password is needed.
* Insert the USB stick into the computer.
* Determine the name Alpine Linux uses for your USB stick. The following step is one way to do this.


After inserting the USB stick, run the command: '''dmesg'''. At the end of this command you should see the name of your USB stick, likely starting with '''sd'''.
== Creating a bootable Alpine Linux USB Stick from the command line ==


The remainder of these instructions will assume that your USB device is called '''/dev/sda'''
This process applies to Alpine Linux 1.9.0 or later, and results in a '''run-from-ram''' style installation.
=== Modify partitions ===
'''fdisk /dev/sda'''
* '''p''' Print list of partitions
* '''d''' Delete all partitions (this may take a few steps)
* '''n''' Create a new partition
* '''p''' A primary partition
* '''1''' Partition number 1
* Use defaults for first and last cylinder (just press [Enter]).
* '''t''' Change partition type
* '''c''' Type: Win95 FAT32 (LBA)
* '''a''' Make the partition bootable (set boot flag)
* '''1''' Partition number 1
* '''w''' Write your changes to the device


* Remove and reinsert your USB stick
{{Warning|This process can potentially totally or partly erase the contents of your hard drive. For this reason, it is recommended to do this procedure using VirtualBox rather than your own computer.}}


=== Install Syslinux on device ===
=== Requirements ===
'''apk add syslinux dosfstools'''
In order to follow this document, you will need:
'''dd if=/usr/share/syslinux/mbr.bin of=/dev/sda'''
* Alpine Linux CD-ROM ([[Downloads|Download]] a .iso file containing an Alpine release.)
'''mkdosfs -F32 /dev/sda1'''
* A USB drive (flash, external HD, card reader, etc.)
'''syslinux /dev/sda1'''
=== Copy Alpine Linux to device ===
'''mount -t vfat /dev/sda1 /media/usb'''
'''cd /media/cdrom
'''cp -a * .alpine-release /media/usb'''
'''sync'''
=== Modify the syslinux.cfg file ===
* Change the line "default generic-hd" to say "default generic-usb".


== Automated Process ==
=== Alpine Linux from 3.3.0 and later ===
Starting (and apparently ending) with Alpine 1.9 alpha 13 we distribute both a .img file and a exe file containing USB images.


Please note that writing the Alpine 1.9 image to your USB stick will overwrite all its existing content.
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.


The images are premade the same size as the .iso image + 8MB for an apk overlay. This means that no matter wither you have an 8GB memory stick or a 512MB memory stick, you will only have 8MB free when booting from it.
The following '''dd''' instructions follow helpful guidance from https://wiki.voidlinux.eu/Live_Images wholly or in part.


Download the latest Alpine 1.9:
If the USB stick is in a Unix/Linux/OSX system, you will need to find out what the USB device isThere are various utilities to determine the device name (e.g. {{Path|/dev/sdx}}) for your USB deviceOne way is:
* Linux users: [[Downloads|download]] .img file containing Alpine ''(e.g. {{Latest_1.9_alpine_gz-mirror}}{{Latest_1.9_alpine_img-filename}})''
* Windows users: [[Downloads|download]] .img file containing Alpine ''(e.g. {{Latest_1.9_alpine_gz-mirror}}{{Latest_1.9_alpine_exe-filename}})''
* Get a USB-mem with at least 400MB of free space


=== Installing to media ===
$ sudo fdisk -l
==== Linux users ====
* Run the following command:
  dd if=/path/to/img/file of=/dev/sdX
* Where sdX is your USB devive. You can find your USB device by inserting it into your computer and run the following command:
  dmesg
* This command will tell you the device name of your newly inserted USB device.
* Please note that most desktop environments automatically mounts inserted USB devices. You should unmount it before running the "dd" command above


==== Windows users ====
If it is still unclear which is your USB's device name, in Linux you could try <code>sudo lsblk -a</code> ;  or use {{Pkg|parted}} (<code>sudo parted -l</code>).
[[{{ns:image}}:USB-extract.png]]
* Download the self extracting exe file (packaged with 7zip), and run it as administrator
* It will self exctract to a temporary location and launch an image writing program
[[{{ns:image}}:USB-write.png]]
* Select the removable drive letter you want to use, and click the "Write" button
* Wait until its finished, and you will have your usb drive ready to use.


== Boot Alpine ==
Then, in order to dd the iso, ensure that your usb drive is '''not''' mounted, as various desktop environments automatically mount usb pen drives:
Put your AlpineLinux-USB in a computer that can boot from USB.<BR>
'''''Note:''' You might need to change boot-order in your BIOS-settings in order to boot from USB.''


When your computer has booted you will get prompted for a username.<BR>
$ sudo umount /dev/sdx
On a clean AlpineLinux you just enter ''root'' and no password and you will get logged on to your Alpine linux.


{{Installing_Alpine_see_also}}
Next, change to the directory where your Alpine .iso file is located, for example:
 
$ cd ~/Downloads
 
{{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 <code>alpine.iso</code> in the following command to the name of your '''.iso''' file; and change <code>/dev/sdx</code> 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
 
{{:Include:Copying Alpine to Flash|USB stick}}
 
=== 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'''
 
== See Also ==
{{:Include:Installing_Alpine_see_also}}
 
[[Category:Installation]]

Revision as of 20:55, 15 October 2017

Creating a bootable Alpine Linux USB Stick from the command line

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

Warning: This process can potentially totally or partly erase the contents of your hard drive. For this reason, it is recommended to do this procedure using VirtualBox rather than your own computer.


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.)

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.

The following dd instructions follow helpful guidance from https://wiki.voidlinux.eu/Live_Images wholly or in part.

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
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
This material is proposed for deletion ...

This include has become obsolete. It is completely unused on the wiki (Discuss)
Make sure no other pages link here and check the page's history before deleting.

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

See Also

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