https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Toogley&feedformat=atomAlpine Linux - User contributions [en]2024-03-29T08:01:05ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Alpine_setup_scripts&diff=18092Alpine setup scripts2020-09-28T15:03:43Z<p>Toogley: remove beta subdomain to avoid SSL warning</p>
<hr />
<div>Feature descriptions for available Alpine Linux setup scripts ({{Path|/sbin/setup-*}}).<br />
<br />
(Some particular example usages can be seen at [[Alpine_newbie_install_manual#Ways_to_install_Alpine_into_machines_or_virtuals|Alpine for new users install manuals]].)<br />
<br />
== setup-alpine ==<br />
<br />
This is the main Alpine configuration and installation script.<br />
<br />
The script interactively walks the user through executing several auxiliary <code>setup-*</code> scripts, in the order shown below.<br />
The bracketed options represent example configuration choices, formatted as they may be supplied when manually calling the auxiliary setup scripts, or with an "answer file" to <code>setup-alpine</code> itself.<br />
<br />
<br />
# <code>setup-keymap</code> [us us]<br />
# [[#setup-hostname|setup-hostname]] [-n alpine-test]<br />
# [[#setup-interfaces|setup-interfaces]] [-i < interfaces-file]<br />
# <code>/etc/init.d/networking --quiet start &</code><br />
# if none of the networking interfaces were configured using dhcp, then: <code>[[#setup-dns|setup-dns]]</code> [-d example.com -n "192.168.0.1 [...]"]<br />
# set the root password<br />
# if not in quick mode, then: <code>[[#setup-timezone|setup-timezone]]</code> [-z UTC | -z America/New_York | -p EST+5]<br />
# enable the new hostname (<code>/etc/init.d/hostname --quiet restart</code>)<br />
# add <code>networking</code> and <code>urandom</code> to the '''boot''' rc level, and <code>acpid</code> and <code>cron</code> to the '''default''' rc level, and start the '''boot''' and '''default''' rc services<br />
# extract the fully-qualified domain name and hostname from {{Path|/etc/resolv.conf}} and <code>hostname</code>, and update {{Path|/etc/hosts}}<br />
# <code>[[#setup-proxy|setup-proxy]]</code> [-q <nowiki>"http://webproxy:8080"</nowiki>], and activate proxy if it was configured<br />
# <code>setup-apkrepos</code> [-r (to select a mirror randomly)]<br />
# if not in quick mode, then: <code>[[#setup-sshd|setup-sshd]]</code> [-c openssh | dropbear | none]<br />
# if not in quick mode, then: <code>setup-ntp</code> [-c chrony | openntpd | busybox | none]<br />
# if not in quick mode, then: <code>DEFAULT_DISK=none</code> <code>[[#setup-disk|setup-disk]]</code> <code>-q</code> [-m data /dev/sda]<br />
# if installation mode selected during setup-disk was "data" instead of "sys", then: <code>setup-lbu</code> [/media/sdb1]<br />
# if installation mode selected during setup-disk was "data" instead of "sys", then: <code>setup-apkcache</code> [/media/sdb1/cache | none]<br />
<br />
<br />
<code>setup-alpine</code> itself accepts the following command-line switches<br />
<br />
{{Define|-h|Shows the up-to-date usage help message.}}<br />
<br />
{{Define|-a|Create an overlay file: this creates a temporary directory and saves its location in ROOT; however, the script doesn't export this variable so I think this feature isn't currently functional.}}<br />
;-c <var>answerfile</var><br />
:Create a new "answerfile", with default choices. You can edit the file and then invoke <code>setup-alpine -f <var>answerfile</var></code>.<br />
;-f <var>answerfile</var><br />
:Use an existing "answerfile", which may override some or all of the interactive prompts.<br />
{{Define|-q|Run in "quick mode".}}<br />
<br />
=== Setup modes ===<br />
<br />
When performs an installation <code>alpine-setup</code> will askfor a disk mode:<br />
<br />
Note that <code>setup-alpine</code> supports to configure the system to boot into one of three general '''Alpinelinux runtime modes''':<br />
<br />
==== diskless mode ====<br />
<br />
This is the default boot mode of the .iso images. <code>[[Alpine_setup_scripts#setup-alpine|setup-alpine]]</code> configures this if selecting to install to "disk=none", and it means that the whole operating system and the applications run extremely fast from within RAM (saving unnecessary disk spin-ups, power and wear). A customized configuration and package selection may still be completely preserved on permanent storage media by using the "local backup utility" <code>[[Alpine_local_backup|lbu]]</code> and a [[Alpine_Linux_package_management#Local_Cache|local package cache]]. [Fixme: <code>setup-alpine</code> still needs [[Alpine_local_backup#Saving_and_loading_ISO_image_customizations| this detour]] to prepare a partition for this:] In setup-alpine, select to store configs and the package cache on a partition. (That mounted partition may later also be used by configuring some important applications to keep their data on it.)<br />
<br />
==== data mode ====<br />
<br />
This mode is still accelerated by running the system from RAM, however swap storage and the whole {{Path|/var}} directory tree gets mounted from a persistent storage device (two newly created partitions). This location holds e.g. all log files, mailspools, databases, etc., as well as <code>[[Alpine_local_backup|lbu]]</code> backup commits and the package cache. The mode is useful for having RAM accelerated servers with amounts of variable user-data that exceed the available RAM size, and to let the entire current system state (not just the boot state) survive a system crash according to the particular filesystem's guarantees. [Fixme: Storing lbu configs to disk is not auto-configured after configuring the data partition, one still has to select saving configs to "none" first (the new data partition is not listed), and to manually set e.g. LBU_MEDIA=sda2 in /etc/lbu/lbu.conf and <code>echo "/dev/sda2 /media/sda2 vfat rw 0 0" >> /etc/fstab</code> afterwards.] The boot device may remain to be the one initially used, and can even be immutable (read-only).<br />
<br />
==== sys mode ====<br />
<br />
This is a traditional hard-disk install. If this mode is selected, the <code>[[setup-alpine]]</code> script defaults to create three partitions on the selected storage device, {{Path|/boot}}, {{Path|swap}} and {{Path|/}} (the filesystem root). This mode may be used for generic [[Desktops|desktop]] and development machines<br />
<br />
== setup-hostname ==<br />
<br />
:<code>setup-hostname</code> [-h] [-n hostname]<br />
<br />
Options:<br />
<br />
'''-h''' <var>Show help</var><br />
<br />
'''-n''' <var>Specify hostname</var><br />
<br />
This script allows quick and easy setup of the system hostname by writing it to {{Path|/etc/hostname}}. The script prevents you from writing an invalid hostname (such as one that used invalid characters or starts with a '-' or is too long).<br />
The script can be invoked manually or is called as part of the <code>setup-alpine</code> script.<br />
<br />
== setup-interfaces ==<br />
{{Cmd|setup-interfaces [-i &lt; <var>interfaces-file</var>]}}<br />
<br />
Note that the contents of <var>interfaces-file</var> has to be supplied as stdin, rather than naming the file as an additional argument. The contents should have the format of {{Path|/etc/network/interfaces}}, such as:<br />
<br />
auto lo<br />
iface lo inet loopback<br />
<br />
auto eth0<br />
iface eth0 inet dhcp<br />
hostname alpine-test<br />
<br />
== setup-dns ==<br />
<br />
:<code>setup-dns</code> [-h] [-d domain name] [-n name server]<br />
<br />
Options:<br />
<br />
'''-h''' <var>Show help</var> <br />
<br />
'''-d''' <var>specify search domain name</var><br />
<br />
'''-n''' <var>name server IP</var> <br />
<br />
The setup-dns script is stored in {{Path|/sbin/setup-dns}} and allows quick and simple setup of DNS servers (and a DNS search domain if required). Simply running <code>setup-dns</code> will allow interactive use of the script, or the options can be specified.<br />
<br />
The information fed to this script is written to {{Path|/etc/resolv.conf}}<br />
<br />
Example usage: {{Cmd|setup-dns -d example.org -n 8.8.8.8}}<br />
<br />
Example {{Path|/etc/resolv.conf}}:<br />
<br />
search example.org<br />
nameserver 8.8.8.8<br />
<br />
It can be run manually but is also invoked in the <code>setup-alpine</code> script unless interfaces are configured for DHCP.<br />
<br />
== setup-timezone ==<br />
:<code>setup-timezone</code> [-z UTC | -z America/New_York | -p EST+5]<br />
<br />
Can pre-select the timezone using either of these switches:<br />
<br />
'''-z''' <var>subfolder of</var> {{Path|/usr/share/zoneinfo}}<br />
<br />
'''-p''' <var>POSIX TZ format</var><br />
<br />
== setup-proxy ==<br />
:<code>setup-proxy</code> [-hq] [PROXYURL]<br />
<br />
Options:<br />
<br />
'''-h''' <var>Show help</var> <br />
<br />
'''-q''' <var>Quiet mode</var> prevents changes from taking effect until after reboot<br />
<br />
This script requests the system proxy to use in the form <code>http://<proxyurl>:<port></code> for example:<br />
<code>http://10.0.0.1:8080</code><br />
<br />
To set no system proxy use <code>none</code>.<br />
This script exports the following environmental variables: <br />
<br />
<code>http_proxy=$proxyurl</code> <br />
<br />
<code>https_proxy=$proxyurl</code><br />
<br />
<code>ftp_proxy=$proxyurl</code><br />
<br />
where <code>$proxyurl</code> is the value input. <br />
If <code>none</code> was chosen then the value it is set to a blank value (and so no proxy is used).<br />
<br />
== setup-sshd ==<br />
<br />
:<code>setup-sshd</code> [-h] [-c choice of SSH daemon]<br />
<br />
Options:<br />
<br />
'''-h''' <var>Show help</var> <br />
<br />
'''-c''' <var>SSH daemon</var> where SSH daemon can be one of the following:<br />
<br />
<code>openssh</code> install the {{Pkg|openSSH}} daemon<br />
<br />
<code>dropbear</code> install the {{Pkg|dropbear}} daemon<br />
<br />
<code>none</code> Do not install an SSH daemon<br />
<br />
Example usage: {{Cmd|setup-sshd -c dropbear}}<br />
<br />
The setup-sshd script is stored in {{Path|/sbin/setup-sshd}} and allows quick and simple setup of either the OpenSSH or Dropbear SSH daemon & client. <br />
It can be run manually but is also invoked in the <code>setup-alpine</code> script.<br />
<br />
== setup-apkrepos ==<br />
:<code>setup-apkrepos</code> [-fhr] [REPO...]<br />
<br />
Setup <code>apk</code> repositories.<br />
<br />
options:<br />
<br />
'''-f''' <var>Detect and add fastest mirror</var><br />
<br />
'''-r''' <var>Add a random mirror and do not prompt</var><br />
<br />
'''-1''' <var>Add first mirror on the list (normally a CDN)</var><br />
<br />
This is run as part of the <code>setup-alpine</code> script.<br />
<br />
== setup-disk ==<br />
<br />
:<code>DEFAULT_DISK=none setup-disk -q</code> [-m data | sys] [<var>mountpoint directory</var> | /dev/sda ...]<br />
<br />
In "sys" mode, it's an installer, it permanently installs Alpine on the disk, in "data" mode, it provides a larger and persistent /var volume.<br />
<br />
This script accepts the following command-line switches:<br />
<br />
;-k <var>kernel flavor</var><br />
;-o <var>apkovl file</var><br />
:Restore system from <var>apkovl file</var><br />
;-m data | sys<br />
:Don't prompt for installation mode. With '''-m data''', the supplied devices are formatted to use as a {{Path|/var}} volume.<br />
{{Define|-r|Use RAID1 with a single disk (degraded mode)}}<br />
{{Define|-L|Create and use volumes in a LVM group}}<br />
;-s <var>swap size in MB</var><br />
:Use 0 to disable swap<br />
{{Define|-q|Exit quietly if no disks are found}}<br />
{{Define|-v|Verbose mode}}<br />
<br />
The script also honors the following environment variables:<br />
<br />
<code>BOOT_SIZE</code><br />
:Size of the boot partition in MB; defaults to 100. Only used if '''-m sys''' is specified or interactively selected.<br />
<br />
<code>SWAP_SIZE</code><br />
:Size of the swap volume in MB; set to 0 to disable swap. If not specified, will default to twice RAM, up to 4096, but won't be more than 1/3 the size of the smallest disk, and if less than 64 will just be 0. Only used if '''-m sys''' is specified or interactively selected.<br />
<br />
<code>ROOTFS</code><br />
:Filesystem to use for the / volume; defaults to ext4. Only used if '''-m sys''' is specified or interactively selected. Supported filesystems are: ext2 ext3 ext4 btrfs xfs.<br />
<br />
<code>BOOTFS</code><br />
:Filesystem to use for the /boot volume; defaults to ext4. Only used if '''-m sys''' is specified or interactively selected. Supported filesystems are: ext2 ext3 ext4 btrfs xfs.<br />
<br />
<code>VARFS</code><br />
:Filesystem to use for the /var volume; defaults to ext4. Only used if '''-m data''' is specified or interactively selected. Supported filesystems are: ext2 ext3 ext4 btrfs xfs.<br />
<br />
<code>SYSROOT</code><br />
:Mountpoint to use when creating volumes and doing traditional disk install ('''-m sys'''). Defaults to {{Path|/mnt}}.<br />
<br />
<code>MBR</code><br />
:Path of MBR binary code, defaults to {{Path|/usr/share/syslinux/mbr.bin}}.<br />
<br />
<code>BOOTLOADER</code><br />
:Bootloader to use, defaults to syslinux. Supported bootloaders are: grub syslinux zipl.<br />
<br />
<code>DISKLABEL</code><br />
:Disklabel to use, defaults to dos. Supported disklabels are: dos gpt eckd.<br />
<br />
<!-- Writes to /tmp/ovlfiles, /tmp/alpine-install-diskmode.out, and /tmp/sfdisk.out but that never seems to be used elsewhere. --><br />
<br />
<br />
=== Partitioning ===<br />
<br />
If you have complex partitioning needs, you can partition, format, and mount your volumes manually, then just supply the root mountpoint to <code>setup-disk</code>. Doing so implicitly behaves as though '''-m sys''' had also been specified.<br />
<br />
See [[Setting up disks manually]] for more information.<br />
<br />
<br />
==== RAID ====<br />
<code>setup-disk</code> will automatically build a RAID array if you supply the '''-r''' switch, or if you specify more than one device. The array will always be [https://en.m.wikipedia.org/wiki/Standard_RAID_levels#RAID_1 RAID1] (and [https://raid.wiki.kernel.org/index.php/RAID_superblock_formats#The_version-0.90_Superblock_Format --metadata=0.90]) for the /boot volumes, but will be [https://en.m.wikipedia.org/wiki/Standard_RAID_levels#RAID_5 RAID5] (and [https://raid.wiki.kernel.org/index.php/RAID_superblock_formats#The_version-1_Superblock_Format --metadata=1.2] for non-boot volumes when 3 or more devices are supplied.<br />
<br />
If you instead want to build your RAID array manually, see [[Setting up a software RAID array]]. Then format and mount the disks, and supply the root mountpoint to <code>setup-disk</code>.<br />
<br />
==== LVM ====<br />
<code>setup-disk</code> will automatically build and use volumes in a LVM group if you supply the '''-L''' switch. The group and volumes created by the script will have the following names:<br />
<br />
* volume group: '''vg0'''<br />
* swap volume: '''lv_swap''' (only created when swap size > 0)<br />
* root volume: '''lv_root''' (only created when '''-m sys''' is specified or interactively selected)<br />
* var volume: '''lv_var''' (only created when '''-m data''' is specified or interactively selected)<br />
<br />
The '''lv_var''' or '''lv_root''' volumes are created to occupy all remaining space in the volume group.<br />
<br />
If you need to change any of these settings, you can use <code>vgrename</code>, <code>lvrename</code>, <code>lvreduce</code> or <code>lvresize</code>.<br />
<br />
If you instead want to build your LVM system manually, see [[Setting up Logical Volumes with LVM]]. Then format and mount the disks, and supply the root mountpoint to <code>setup-disk</code>.<br />
<br />
<!--<br />
=Setup-Disk Usage=<br />
<br />
usage: setup-disk [-hqr] [-k kernelflavor] [-m MODE] [-o apkovl] [-s SWAPSIZE]<br />
[MOUNTPOINT | DISKDEV...]<br />
<br />
Install alpine on harddisk.<br />
<br />
If MOUNTPOINT is specified, then do a traditional disk install with MOUNTPOINT<br />
as root.<br />
<br />
If DISKDEV is specified, then use the specified disk(s) without asking. If<br />
multiple disks are specified then set them up in a RAID array. If there are<br />
mode than 2 disks, then use raid level 5 instead of raid level 1.<br />
<br />
options:<br />
-h Show this help<br />
-m Use disk for MODE without asking, where MODE is either 'data' or 'root'<br />
-o Restore system from given apkovl file<br />
-k Use kernelflavor instead of $KERNEL_FLAVOR<br />
-L Use LVM to manage partitions<br />
-q Exit quietly if no disks are found<br />
-r Enable software RAID1 with single disk<br />
-s Use SWAPSIZE MB instead of $SWAP_SIZE MB for swap (Use 0 to disable swap)<br />
-v Be more verbose about what is happening<br />
<br />
<br />
==Disk Install Styles==<br />
<br />
You can select between 'sys' or 'data'.<br />
<br />
sys:<br />
This mode is a traditional disk install. The following partitions will be<br />
created on the disk: /boot, / (filesystem root) and swap.<br />
<br />
This mode may be used for development boxes, desktops, virtual servers, etc.<br />
<br />
data:<br />
This mode uses your disk(s) for data storage, not for the operating system.<br />
The system itself will run from tmpfs (RAM).<br />
<br />
Use this mode if you only want to use the disk(s) for a mailspool, databases,<br />
logs, etc.<br />
<br />
none:<br />
Run without installing to disk.<br />
<br />
--><br />
== setup-lbu ==<br />
<br />
This script will only be invoked for by <code>setup-alpine</code> when installing <code>data</code> installation types (ramdisk)<br />
<br />
In the previous step, we set up the disk used for the swap partition and for mounting <code>/var</code>. Here we set up where <code>lbu commit</code> will store its backup configuration. See [[Alpine local backup]] for more information.<br />
<br />
When started, <code>setup-lbu</code> will prompt where to store your data. The options it will prompt for will be taken from the directories found in <code>/media</code> (except for <code>cdrom</code>). [not sure how these are mounted: are they automatically mounted by setup-lbu? Does the user have to manually mount using another tty?]<br />
<br />
== setup-apkcache ==<br />
<br />
This script will only be invoked for by <code>setup-alpine</code> when installing <code>data</code> installation types (ramdisk)<br />
<br />
In the previous steps, we setup the disk partitions, and told Alpine where it can save its configuration for ramdisk installations. Here we tell Alpine where to save the apk files that you will want to persist across boots. The apkcache is where apk stores cached packages, such that the system does not need to download them at each boot, and doesn't have to depend on the network. See [[Local APK cache]] for a detailed explanation.<br />
<br />
You should be able to use a partition that you set up in the previous steps.<br />
<br />
== setup-bootable ==<br />
This is a standalone script; it's not invoked by <code>setup-alpine</code> but must be run manually.<br />
<br />
Its purpose is to create media that boots into tmpfs by copying the contents of an ISO onto a USB key, CF, or similar media.<br />
<br />
For a higher-level walkthrough, see [[Create a Bootable USB#Creating_a_bootable_Alpine_Linux_USB_Stick_from_the_command_line|Creating a bootable Alpine Linux USB Stick from the command line]].<br />
<br />
This script accepts the following arguments and command-line switches (you can run <code>setup-bootable -h</code> to see a usage message).<br />
<br />
{{Cmd|setup-bootable <var>source</var> [<var>dest</var>]}}<br />
<br />
The argument <var>source</var> can be a directory or an ISO (will be mounted to <code>MNT</code> or {{Path|/mnt}}) or a URL (will be downloaded with <code>WGET</code> or <code>wget</code>). The argument <var>dest</var> can be a directory mountpoint, or will default to {{Path|/media/usb}} if not supplied.<br />
<br />
{{Define|-k|Keep alpine_dev in {{Path|syslinux.cfg}}; otherwise, replace with UUID.}}<br />
{{Define|-u|Upgrade mode: keep existing {{Path|syslinux.cfg}} and don't run <code>syslinux</code>}}<br />
{{Define|-f|Overwrite {{Path|syslinux.cfg}} even if '''-u''' was specified.}}<br />
{{Define|-s|Force the running of <code>syslinux</code> even if '''-u''' was specified.}}<br />
{{Define|-v|Verbose mode}}<br />
<br />
The script will ensure that <var>source</var> and <var>dest</var> are available; will copy the contents of <var>source</var> to <var>dest</var>, ensuring first that there's enough space; and unless '''-u''' was specified, will make <var>dest</var> bootable.<br />
<br />
<!--<br />
== setup-cryptswap ==<br />
This is a standalone script; it's not invoked by <code>setup-alpine</code> but must be run manually.<br />
<br />
:<code>setup-cryptswap</code> [<var>partition</var> | none]<br />
<br />
{{Todo|Does this script still work? At what stage can it be run: only after setup-alpine?}}<br />
--><br />
<br />
== setup-xorg-base ==<br />
This is a standalone script; it's not invoked by <code>setup-alpine</code> but must be run manually.<br />
<br />
Installs a basic xorg configuration, e.g. among other packages: <code>xorg-server xf86-video-vesa xf86-input-evdev xf86-input-mouse xf86-input-keyboard udev</code>.<br />
<br />
Additional packages may be supplied as arguments to <code>setup-xorg-base</code>. You might need, for example, some of: <code>xf86-input-synaptics xf86-video-<var>something</var> xinit</code>. For Qemu, see [[Qemu#Using_Xorg_inside_Qemu|Qemu]]. For Intel GPUs, see [[Intel Video]].<br />
<br />
== Documentation needed ==<br />
<br />
=== setup-xen-dom0 ===<br />
<br />
=== setup-gparted-desktop ===<br />
Uses openbox.<br />
<br />
This is a standalone script; it's not invoked by <code>setup-alpine</code> but must be run manually.<br />
<br />
=== setup-mta ===<br />
Uses ssmtp.<br />
<br />
This is a standalone script; it's not invoked by <code>setup-alpine</code> but must be run manually.<br />
<br />
=== setup-acf ===<br />
This is a standalone script; it's not invoked by <code>setup-alpine</code> but must be run manually.<br />
<br />
This script was named <code>setup-webconf</code> before Alpine 1.9 beta 4.<br />
<br />
See [[:Category:ACF|ACF pages]] for more information.<br />
<br />
=== setup-ntp ===<br />
<br />
<br />
= =<br />
* [https://docs.alpinelinux.org/ beta.docs.alpinelinux.org]<br />
<br />
[[Category:Installation]]</div>Toogley