Using an answerfile with setup-alpine
Creating an initial answerfile
To get an quick start with setup-alpine answerfiles, a starter answerfile can be generated with:
setup-alpine -c PATH_TO_FILENAME
At the time of writing this, the previous command will result in output in the specified PATH_TO_FILENAME:
Contents of PATH_TO_FILENAME
When using answerfile, be sure to edit the file's contents to your needs. Comment out variables you wish not to be set. Be sure that the uncommented variables have valid values set to your preference. Once you are satisfied with the answerfile contents, this how is to use it:
setup-alpine -f PATH_TO_FILENAME
Answerfile Variables
The variables in the answerfile alter the arguments passed to the setup-* scripts that are called out to from setup-alpine. These are:
- KEYMAPOPTS="LAYOUT VARIANT"
- HOSTNAMEOPTS="HOSTNAME"
- DEVDOPTS="DEVD"
- The choices are mdev (from busybox), mdevd (standalone), and udev (from eudev).
- DEVDOPTS="DEVD"
- INTERFACEOPTS="file contents to put in /etc/network/interfaces"
- This will be used as input to the setup-interfaces command.
- INTERFACEOPTS="file contents to put in /etc/network/interfaces"
- DNSOPTS="-d DOMAIN IP_ADDR
- Use -d to specify search domain. Use IP_ADDR to specify DNS servers to use (mutliple allowed).
- DNSOPTS="-d DOMAIN IP_ADDR
- TIMEZONEOPTS="ZONE"
- Specify the timezone, based on files relative to /usr/share/zoneinfo.
- TIMEZONEOPTS="ZONE"
- PROXYOPTS="PROXY_URL"
- Specify the URL for proxy to use; eg http://webproxy:8080.
- PROXYOPTS="PROXY_URL"
- NTPOPTS="NTP_DAEMON"
- The choices are busybox, openntpd, chrony, and none.
- NTPOPTS="NTP_DAEMON"
- APKREPOSPTS="setup-apkrepos options"
- Specify command line options for setup-apkrepos:
Contents of setup-apkrepos -h
usage: setup-apkrepos [-ch] [-f|-r|-1|REPO...] setup-apkrepos -o Setup apk repositories options: -c Enable the community repo -f Detect and add fastest mirror -h Show this help -o Only enable a community repo for every defined repo -r Add a random mirror and do not prompt -1 Add first mirror on the list (normally a CDN) Option -o cannot be used with options -c, -f, -r or -1
- APKREPOSPTS="setup-apkrepos options"
- USEROPTS="setup-user options"
- Specify setup-user options:
Contents of setup-user -h
usage: setup-user [-h] [-a] [-u] [-f FULLNAME] [-g GROUPS] [-k SSHKEY] [USERNAME] Create user account options: -a Create admin user. Add to wheel group and set up doas -h Show this help -f Set full name for user -g Comma or space separated list of groups to add user to -k ssh key or URL to ssh key (eg. https://gitlab.alpinelinux.org/user.keys) or 'none' for no key -u Unlock the user automatically (eg. creating the user non-interactively with an ssh key for login) If USERNAME is not specified user will be prompted.
- USERSSHKEY="PUBKEY or URL"
- Specify the contents or url to ssh public key to use as user's login key.
- USEROPTS="setup-user options"
- SSHDOPTS="SSHD
- The choice of ssh daemon; one of openssh, dropbear, or none.
- ROOTSSHKEY="PUBKEY or URL"
- Specify the contents or url to ssh public key to use as root user's login key.
- SSHDOPTS="SSHD
- XENDOM0OPTS="PACKAGES
- Specify additional packages to install along with the xen package.
- XENDOM0OPTS="PACKAGES
- DISKOPTS="etup-disk options"
- Specify setup-disk options:
Contents of setup-disk -h
usage: setup-disk [-hLqrve] [-k kernelflavor] [-m MODE] [-o apkovl] [-s SWAPSIZE] [-w FILE] [MOUNTPOINT | DISKDEV...] Install alpine on harddisk. If MOUNTPOINT is specified, then do a traditional disk install with MOUNTPOINT as root. If DISKDEV is specified, then use the specified disk(s) without asking. If multiple disks are specified then set them up in a RAID array. If there are more than 2 disks, then use raid level 5 instead of raid level 1. options: -h Show this help -e Encrypt disk -m Use disk for MODE without asking, where MODE is either 'data' or 'sys' -o Restore system from given apkovl file -k Use kernelflavor instead of lts -L Use LVM to manage partitions -q Exit quietly if no disks are found -r Enable software raid1 with single disk -s Use SWAPSIZE MB instead of autodetecting swap size (Use 0 to disable swap) -v Be more verbose about what is happening -w Write selected install mode to FILE If BOOTLOADER is specified, the specified bootloader will be used. If no bootloader is specified, the default bootloader is syslinux(extlinux) except when EFI is detected or explicitly set by USE_EFI which will select grub. Supported bootloaders are: grub, syslinux, zipl, raspberrypi-bootloader, u-boot, none If KERNELOPTS is specified, it will be appended to the kernel boot parameters. Default is: quiet If DISKLABEL is specified, the specified partition label will be used. if no partition label is specified, the default label will be dos except when EFI is detected or explicitly set by USE_EFI which will select gpt. Supported partition labels are: dos, gpt If BOOTFS, ROOTFS, VARFS are specified, then format a partition with specified filesystem. If not specified, the default filesystem is ext4. Supported filesystems for boot: ext2, ext3, ext4, btrfs, xfs, vfat(EFI) root: ext2, ext3, ext4, btrfs, xfs var: ext2, ext3, ext4, btrfs, xf
- In addition to the environment variables described above, also relavent are:
- BOOT_SIZE="SIZE_IN_MIB"
- SWAP_SIZE="SIZE_IN_MIB"
- ROOT_SIZE="SIZE_IN_MIB"
- If lvm is used, SWAP_SIZE and ROOT_SIZE may specified as percentage of volume group, for example:
- ROOT_SIZE="50%VG"
- DISKOPTS="etup-disk options"
- LBUOPTS="MEDIA"
- Specify option mountpoint under /media.
- LBUOPTS="MEDIA"
- APKCACHEOPTS="DIR"
- Specify directory to setup for apk caching.
- APKCACHEOPTS="DIR"
Environment variables and setup-alpine
It is not necessary to use an answerfile to get the same functionality. Another way to achieve the same thing is to set these variables in the environment, either exported or on the commandline.
DISKOPTS=-e -L -m sys /dev/sda
ROOT_SIZE=50%VG
setup-alpine
The above command specifies to do a system disk install with lvm on encrypted partition, and that the root logical volume should be 50% of the volume group.
This method is probably not realistic for setting many variables, but for using just a few may be justified.