Install to disk: Difference between revisions
Dubiousjim (talk | contribs) (→If using Alpine Linux 2.2.2 or earlier: formatting, remarks) |
Dubiousjim (talk | contribs) |
||
Line 24: | Line 24: | ||
{{Cmd|mount -t ext4 /dev/sda1 /mnt}} | {{Cmd|mount -t ext4 /dev/sda1 /mnt}} | ||
Clone the current running config created by setup-alpine (hostname, networking root password) | Clone the current running config created by setup-alpine (hostname, networking root password): | ||
{{Cmd|<nowiki>lbu package - | tar -C /mnt -zx</nowiki>}} | {{Cmd|<nowiki>lbu package - | tar -C /mnt -zx</nowiki>}} | ||
Install base packages on harddisk | Install base packages on harddisk: | ||
{{Cmd|<nowiki>apk add --root=/mnt --initdb $(cat /etc/apk/world)</nowiki>}} | {{Cmd|<nowiki>apk add --root=/mnt --initdb $(cat /etc/apk/world)</nowiki>}} | ||
Revision as of 02:46, 5 March 2012
If using Alpine Linux 2.2.3 or later
This page exists to provide a basic overview to get started. Before actually installing, it can help to skim through the Frequently Asked Questions (FAQ), as well as to refer to the official installation guide at docs.alpinelinux.org.
If something isn't correct, or is incomplete, you will have to figure it out, or ask for the correct solution in the community.
And then carefully edit the wiki page.
Just as those before who did it for you.Minimal Hardware Requirements
- At least 128 MB of RAM. [A graphical desktop system may require up to 512 minimum.]. Note that an installation itself (from ISO) generally requires at least 320 MB during installation.
- At least 0-700 MB space on a writable storage device. [Only required in "sys" or "data" mode installations. It is optional in "diskless" mode, where it may be used to save newer data and configurations states of a running system.]
- A working internet connection is required to complete "sys" mode installation.
Installation Overview
Alpine Linux can be installed and run in three modes i.e Diskless Mode, Data Disk Mode and System Disk Mode. The installation procedure for Alpine Linux requires basic understanding of the three modes explained in brief below:
Diskless Mode
In Diskless mode the entire operating system with all applications are first loaded into RAM and then only run from there. This mode is extremely fast and can save on unnecessary disk spin-ups, power, and wear. Alpine Linux uses this method to boot the .iso installation images. The setup-alpine
script configures the installed system to continue to boot like this if "disk=none" is specified.
Data Disk Mode
In Data Disk mode also the operating system runs from system RAM, thus it enjoys the same accelerated operation speed as "diskless" mode. However, swap storage and the entire /var directory tree get mounted from a persistent storage device. This mode is useful for having RAM accelerated servers with variable amounts of user-data that exceed the available RAM size.
System Disk Mode
System or sys Disk Mode is the traditional hard-disk install. Alpine Linux can be installed to an entire hard disk using setup-alpine
script or to custom partitions using setup-disk
. For further info, refer System Disk Mode.
General course of action
It is really helpful for many use cases to prepare and complete the Installation until the base configuration step, then proceed with installation of the target system with any one of the various alternate courses of action.
Alternate courses of action
Examples of preparation options:
- Download some specific driver to configure the hardware, and/or install some software tool that may be missing in the live system by using the alpine package manager
apk
. - Do a Manual partitioning of the harddisk that avoids overwrite of an entire disk.
Examples of proceeding options:
- To install Alpine Linux on an entire hard disk with optional environment variables, proceed to setup-alpine based System Disk Install.
- Use
setup-lbu
to configure a "local backup" location andsetup-apkcache
to configure a local package cache storage location for the diskless system and finally uselbu commit
to then save the local configuration state. - Use
setup-bootable
to create a customizable boot media for diskless or data disk-mode i.e a boot device with a writable filesystem. - Use
setup-disk
to complete a traditional hard-disk installation on a partition or to Dualboot or to configure RAID, encryption or LVM for both "data" disk and "system" disk mode or to add a "data" mode partition.
There are many more setup-scripts available. All these tools may also be run later to adjust specific configurations. For example, to set up a graphical environment as covered under Post-Installation below.
Preparing for the installation
Downloading installation image
Download the stable-release installation image-file for the target computer's architecture with their corresponding sha256
(checksum) and GPG
(signature) files.
sha256
(checksum) and GPG
(signature) files only from official site and not from mirrors.Now you have three files of the following format..
alpine-standard-*.iso alpine-standard-*.iso.sha256 alpine-standard-*.iso.asc
alpine-standard-3.20.3-x86_64.iso is the 3.20.3 version Standard image file in iso format for x86_64 architecture. Image file can also be gz for certain cases.
Verifying downloaded image
From Security point of view, verify the downloaded image file for both checksum and GPG signature before proceeding further. The three required utilities i.e sha256
, curl
and gpg
or their equivalents are available in every operating system including Linux, windows, Mac and BSD derivaties.
The sha256
checksum verifies the integrity of the downloaded image i.e no modifications occurred during download.
sha256sum -c alpine-*.iso.sha256
The GPG
signature verifies the link between the downloaded image to the individual who signed it. Signature verification involves two steps:
Step 1. Download and import the gpg signature from official website
curl https://alpinelinux.org/keys/ncopa.asc | gpg --import ;
Step 2. Verify that the image signature matches with the one downloded in Step 1.
gpg --verify alpine-*.iso.asc alpine-*.iso
Preparing installation media
All data currently on the installation media will be lost, when Alpine Linux installation image is written on it. Be extremely careful to correctly identify the device name for the installation media using the commands lsblk
and blkid
.
In Linux, dd
command can write the downloaded image file to the installation media i.e target device.
# dd if=alpine-standard-3.20.3-x86_64.iso of=/dev/sdX bs=4M status=progress; eject /dev/sdX
If your version of dd
does not support the option "status=progress", remove it. The eject
command removes the target device from the system and ensures the write cache is completely flushed.
In Windows, Rufus has been tested to create bootable USB flash drives and worked for 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)
Verifying Installation media
After detaching and re-attaching the device, a bit-wise comparison can verify the data written to the device (instead of just data buffered in RAM). If the comparison terminates with an end-of-file error on the .iso file side, all the contents from the image have been written (and re-read) successfully:
# cmp ~/Downloads/alpine-standard-3.20.3-x86_64.iso /dev/sdX cmp: EOF on alpine-standard-3.20.3-x86_64.iso
Booting Installation Media
Insert the Installation media to a proper drive or port of the computer and turn the machine on, or restart it, if already running.
If the computer does not automatically boot from the desired device, one needs to bring up the boot menu and choose the media to boot from. Depending on the computer, the menu may be accessed by repeatedly pressing a key quickly when booting starts. Some computers require that you press the button before starting the computer and hold it down while the computer boots. Typical keys are: F9-F12, sometimes F7 or F8. If these don't bring up the boot menu, it may be necessary to enter the BIOS configuration and adjust the boot settings, for which typical keys are: Del F1 F2 F6 or Esc.
Installation Step Details
Boot Process
The boot process of the alpine installation image first copies the entire operating system into the RAM memory, and then already starts a complete Alpine Linux system from there. It will initially only provide a basic command line environment that does not depend on reading from any (possibly slow) initial boot media, anymore.
Local log-in is possible as the user root
. Initially, the root user has no password.
At the command prompt, an interactive script named setup-alpine
is available to configure and install Alpine Linux. The script can be customized by the optional environment variables, in case of "data" or "sys" mode. For e.g USE_EFI=1 BOOTSIZE=512 setup-alpine
, sets the disklabel type to gpt, creates 512MB /boot partition with vfat filesystem and uses grub
as bootloader.
Base configuration
Launch the Alpine Linux Installation by running the setup-alpine
script :
# setup-alpine
The question-and-answer dialog of setup-alpine
takes care of the base configuration. It sets up a network connection to access Internet to configure the system to boot into one of three different Alpine Linux "disk" modes: "diskless"(none), "data" or "sys". If you choose to edit any option, the relevant file is opened in vi for editing.
The setup-alpine
script offers the following configuration options:
- Keyboard Layout (Local keyboard language and usage mode, e.g. us and variant of us-nodeadkeys.)
- Hostname (The name for the computer.)
- Network (Setup network connection to access Internet.)
- Available interfaces are: eth0 wlan0.(List depends on your hardware.)
- Which one do you want to initialize? (or '?' or 'done') [eth0] (Enter 'done' after configuring atleast one interface for Internet access.)
- Do you want to do any manual network configuration? (y/n) [n] (Default uses "DHCP".)
- DNS Servers (If none of the interfaces configured in previous step uses dhcp, set DNS server. If unsure, leave DNS domain name blank and using
9.9.9.9 2620:fe::fe
for DNS is typically adequate.) - Root password (the password used to login to the root account)
- Timezone (Optionally display times/dates in your local time zone)
- HTTP/FTP Proxy (Proxy server to use for accessing the web/ftp. Use "none" for direct connections to websites and FTP servers.)
- Mirror (From where to download packages. Choose the organization you trust giving your usage patterns to.)
- Setup a user (Setting up a regular user account)
- NTP (Network Time Protocol client used for keeping the system clock in sync with a time server. Package "chrony" is part of the default install image.)
- SSH (Secure SHell remote access server. "OpenSSH" is part of the default install image. Use "none" to disable remote login, e.g. on laptops.)
- In most cases, either one of following line(s) is displayed as follows:
- No disks found. or Available disks are: sda (128.0 GB JMicron Tech )
- Disk Mode ( A pre-setup of the "diskless" system or base configuration is completed by answering "none" when asked for the following questions.)
- Which disk(s) would you like to use? (or '?' for help or 'none') none
- Enter where to store configs (/media/ or 'none') none
- The location of the package cache none
Base configuration is complete with the above step. Refer to the alternate courses of action to proceed further.
setup-alpine based System Disk Install
setup-alpine
script based installation, needs an entire hard disk(s) for Alpine Linux and uses a partitioning layout with (/)root partition, /boot partition and a swap partition, where environment variables determine filesystem, size of the boot partition and the bootloader used. If your use case matches the above, at the final step of base configuration, type the appropriate hard disk device name instead of none. If multiple disks are chosen, RAID is used.
- At the Disk Mode stage, sda or relevant disk(s) must be chosen in the below screen:
- Which disk(s) would you like to use? (or '?' for help or 'none') sda
- Confirmation for the chosen disk(s) appears. The following disk is selected: sda (128.0 GB JMicron Tech ).
- How would you like to use it? ('sys', 'data', 'lvm' or '?' for help) sys
If sys is chosen, the setup-alpine
script will complete the traditional hard-disk installation of Alpine Linux on the chosen disk(s) without further questions. Once the installation is complete, you can skip the next steps and proceed to reboot the system to boot into the newly installed Alpine Linux and configure further.
Custom partitioning
Manual partitioning of the harddisk may be needed to prepare the harddisk for "sys" mode install using setup-disk
and for storing the config file using lbu commit
and package cache for Diskless and for /var mount for Data disk mode installs. Refer Setting up disks manually page for specific configurations related to RAID, encryption, LVM, etc...
Preparing for the first boot
If System Disk Mode of installation was performed, ignore this section and proceed to reboot.
If the new local system was configured to run in "diskless" or "data" mode, and you do not want keep booting from the initial (and possibly read-only) installation media, create a customizable boot device. Once everything is in place, save your customized configuration with lbu commit
before rebooting.
Reboot
First, remove the initial installation media from the boot drive, or detach it from the port it's connected to. The system may now be power-cycled or rebooted to confirm everything is working correctly. The relevant commands for this are poweroff
or reboot
. Login into the new system with the root account.
Completing the installation
The installation script installs only the base operating system. No applications e.g. web server, mail server, desktop environment, or web browsers are installed.
Please look at Post-Installation, for some common things to do after installation.
Custom Installation Instructions
Custom-made headless apkovl can be done by first booting the install media on some computer with a display and keyboard attached, or in a virtual machine, and doing an intermediate "diskless" setup of just the boot media (more details below), i.e. using the offical setup-alpine
to configure the system's network, possibly for dhcp if needed, a ssh server, and a login user. Choosing "disks=none" for now, yet, configure to store configs on the boot media (if it is writable, otherwise on a separate storage media). And afterwards calling lbu commit
to store the configs as local backup. Then your completed setup, including its securely created own private keys, will readily get (re)loaded on every subsequent (headless) boot from your custom-build <hostname>.apkovl.tar.gz
stored on the boot media (or on an auxilary media or server location, in case the boot media is read-only).
- Bootstrap Alpine Linux on a headless system using pre-built
apkovl
overlay file. - Kernels (kernel selection, e.g. for VMs or RPi)
- How to make a custom ISO image with mkimage (installation media with its own configuration)
- Directly booting an ISO file (without flashing it to a disk or device)
- Netboot Alpine Linux using iPXE
- Virtualization
Also see other Installation Category pages.
Post-Installation
Daily driver guide
Alpine Linux is built to be small and resource efficient. It is still a general purpose Linux distribution designed for power users. If you feel the defaults are too lightweight for desktop use, it is easy to get most of the regular stuff working and use it as a daily driver.
- Create a non-privileged user account for security reasons.
- Ensure that
community
repository is enabled - Install graphics driver for your video hardware.
- Install a desktop using Setup-desktop script or manually install any desktop of your choice.
Basics
- Learn the alpine package keeper basics or refer wiki for more details.
- Install some fonts to make your desktop look better.
- Setup PipeWire to manage your audio, if setup-desktop did not install it for your already or you installed your desktop environment manually.
- Configure your Bluetooth, if you have one.
- Configure your printer.
- Enable documentation, so man pages are available.
- Secure your system by installing firewall software like awall or UFW.
- To keep your system secure, regularly check and apply updates with the package manager.
Advanced
- Use Flatpak to add packages that are not in the repositories.
- Install gcompat package to add a glibc compatability layer which lets you run glibc binaries as normal.
- Install a sandboxing application like AppArmor or Bubblewrap.
- Learn basics of openrc, the alpine Linux init system or refer Open rc wiki.
- If you want the rolling release version of Alpine Linux, enable the Edge repository.
- You may want to explore the testing repository, as it provides a lot more applications.
Other topics
Topics not strictly related to using Alpine Linux as desktop are listed below:
- Upgrade your OS, when a new version is released.
- Setting up Networking (including non-standard configurations)
- Init System (OpenRC) (configure a service to automatically boot at next reboot)
- Hosting services on Alpine (links to several mail/web/ssh server setup pages)
See also
- Tutorials and Howtos
- FAQs
- Comparison with other distros (how common things are done on Alpine)
- Wiki etiquette (to collaborate on this documentation)
If using Alpine Linux 2.2.2 or earlier
A number of steps are nowadays included in the setup-disk and setup-lbu scripts, which are invoked by setup-alpine. But in these older systems, these steps have to be performed manually.
Run setup-alpine to configure the keyboard, hostname and networking.
setup-alpine
Now for the manual steps. Create partitions with fdisk.
fdisk /dev/sda
You should have 2 partitions: /dev/sda1 as "Linux" (type 83) and /dev/sda2 as "linux swap" (type 82). The /dev/sda1 must be bootable (command "a" within fdisk).
Install needed programs for the setup:
apk add e2fsprogs syslinux mkinitfs
Create filesystem and swap:
mkfs.ext4 /dev/sda1 mkswap /dev/sda2
Mount file-system:
mount -t ext4 /dev/sda1 /mnt
Clone the current running config created by setup-alpine (hostname, networking root password):
lbu package - | tar -C /mnt -zx
Install base packages on harddisk:
apk add --root=/mnt --initdb $(cat /etc/apk/world)
Append the / and swap to /etc/fstab:
echo -e "/dev/sda1 / ext4 defaults 1 1" >> /mnt/etc/fstab echo -e "/dev/sda2 none swap sw 0 0" >> /mnt/etc/fstab
Configure the boot loader, extlinux
. We use the provided syslinux.cf as base.
cp /media/cdrom/syslinux.cf /mnt/boot/extlinux.conf vi /mnt/boot/extlinux.conf
It should contain something like:
timeout 20 prompt 1 default grsec label grsec kernel /boot/grsec append initrd=/boot/grsec.gz root=/dev/sda1 modules=ext4 quiet
Install the bootloader:
extlinux -i /mnt/boot
Install syslinux bootloader at the beginning of the MBR so its bootable (note that its sda and not sda1)
dd if=/usr/share/syslinux/mbr.bin of=/dev/sda
Unmount, remove cdrom, and reboot. (If you can't eject, just remove it manually as the machine reboots)
umount /mnt umount /.modloop eject reboot
After reboot, you should be able to log in as root with the password you created in setup-alpine.