Create a Bootable Device: Difference between revisions

From Alpine Linux
m (Changed some phrasings in dd instructions)
(details about whole diskless mode)
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Generally there's no difference between Alpine Linux USB bootable installation medium and installed system in ''diskless'' or ''run-from-ram'' installation mode. The only difference is that after finished installation modified files have to be saved somewhere, hence [[Alpine_local_backup|Alpine Local Backup]]. Thus this document describes how to proceed to end with an installation of a system in ''diskless'' or ''run-from-ram'' installation mode with locally saved modifications.


== Creating a bootable Alpine Linux USB Stick from the command line ==
This process applies to Alpine Linux 1.9.0 or later.
== Requirements ==


This process applies to Alpine Linux 1.9.0 or later, and results in a '''run-from-ram''' style installation.
In order to follow this document, you will need:
 
{{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 ([[Downloads|Download]] a .iso file containing an Alpine release.)
* Alpine Linux CD-ROM ([[Downloads|Download]] a .iso file containing an Alpine release.)
* A USB drive (flash, external HD, card reader, etc.)
* A USB drive (flash, external HD, card reader, etc.)


=== Alpine Linux from 3.3.0 and later ===
== Copy Alpine to USB stick ==


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.
{{:Include:Copying Alpine to Flash|USB stick}}


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


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. {{Path|/dev/sdx}}) for your USB device. One way is:
After one has booted previously created Alpine Linux bootable USB medium, to finish the installation one has to prepare USB stick to hold local customization and run ''setup-alpine''.


$ sudo fdisk -l
First let's find out where is our just booted USB media mounted, the location could vary.


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>).
# mount | grep /media
  /dev/sda1 on /media/sda1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)


Then, in order to dd the iso, ensure that your usb drive is '''not''' mounted, as various desktop environments automatically mount usb pen drives:
Create local directory on USB media to hold local APK cache (see [[Alpine_Linux_package_management#Local_Cache|APK Local Cache]] for details).


  $ sudo umount /dev/sdx
  # mount -o remount,rw /media/sda1
# mkdir /media/sda1/cache
# setup-apkcache /media/sda1/cache
# ls -l /etc/apk/cache
lrwxrwxrwx    1 root    root            17 Oct 19 13:16 /etc/apk/cache -> /media/sda1/cache


Next, change to the directory where your Alpine .iso file is located, for example:
Now run ''setup-aplpine'' and proceed till a question about local disk selection - in ''diskless'' mode we won't use any disk (ie. our bootable media files is basically untouched) and we are going to use ''sda1'' to hold our system customization.


  $ cd ~/Downloads
  # setup-alpine
...
Which disk(s) would you like to use? (or '?' for help or 'none') [none]
Enter where to store configs ('floppy', 'sda1', 'usb' or 'none') [sda1]:
Enter apk cache directory (or '?' or 'none') [/media/sda1/cache]:


{{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!}}
After the installer finished you can see how many files are created/modified by the installer and which need to be preserved:
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}}
# lbu status | wc -l
59
# lbu commit
# ls -l /media/sda1/*apkovl.tar.gz
-rwxr-xr-x    1 root    root          9591 Oct 19 15:23 /media/sda1/foo.apkovl.tar.gz
 
Thus all our customization is saved into ''foo.apkovl.tar.gz'' compressed tarball on the USB stick itself.
 
== Troubleshooting ==


=== Slow USB Devices ===
=== Slow USB Devices ===

Revision as of 13:40, 19 October 2020

Generally there's no difference between Alpine Linux USB bootable installation medium and installed system in diskless or run-from-ram installation mode. The only difference is that after finished installation modified files have to be saved somewhere, hence Alpine Local Backup. Thus this document describes how to proceed to end with an installation of a system in diskless or run-from-ram installation mode with locally saved modifications.

This process applies to Alpine Linux 1.9.0 or later.

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

Copy Alpine to USB stick

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.

Finishing installation

After one has booted previously created Alpine Linux bootable USB medium, to finish the installation one has to prepare USB stick to hold local customization and run setup-alpine.

First let's find out where is our just booted USB media mounted, the location could vary.

# mount | grep /media
/dev/sda1 on /media/sda1 type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)

Create local directory on USB media to hold local APK cache (see APK Local Cache for details).

# mount -o remount,rw /media/sda1
# mkdir /media/sda1/cache
# setup-apkcache /media/sda1/cache
# ls -l /etc/apk/cache
lrwxrwxrwx    1 root     root            17 Oct 19 13:16 /etc/apk/cache -> /media/sda1/cache

Now run setup-aplpine and proceed till a question about local disk selection - in diskless mode we won't use any disk (ie. our bootable media files is basically untouched) and we are going to use sda1 to hold our system customization.

# setup-alpine
...
Which disk(s) would you like to use? (or '?' for help or 'none') [none] 
Enter where to store configs ('floppy', 'sda1', 'usb' or 'none') [sda1]: 
Enter apk cache directory (or '?' or 'none') [/media/sda1/cache]:

After the installer finished you can see how many files are created/modified by the installer and which need to be preserved:

# lbu status | wc -l
59
# lbu commit
# ls -l /media/sda1/*apkovl.tar.gz
-rwxr-xr-x    1 root     root          9591 Oct 19 15:23 /media/sda1/foo.apkovl.tar.gz

Thus all our customization is saved into foo.apkovl.tar.gz compressed tarball on the USB stick itself.

Troubleshooting

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