mkinitcpio, mkinitramfs, initrd rebuild
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import piksemel
|
||||
import os
|
||||
|
||||
def updateInitrd(filepath):
|
||||
patterns = ("/lib/modules", "/lib/initrd", "/boot/kernel", "/bin/busybox")
|
||||
parse = piksemel.parse(filepath)
|
||||
for xmlfile in parse.tags("File"):
|
||||
path = xmlfile.getTagData("Path")
|
||||
if not path.startswith("/"):
|
||||
path = "/%s" % path # Just in case
|
||||
if path.startswith(patterns):
|
||||
# Handle the proper case of modules
|
||||
version = path.split("/")[3]
|
||||
os.environ['PATH'] = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin'
|
||||
cmd = "update-initrd KERNELVER=%s MODDIR=/lib/modules/%s OUTPUT=/boot/initramfs-%s" % (version, version, version)
|
||||
os.system(cmd)
|
||||
if os.path.exists("/proc/cmdline"):
|
||||
os.system("/usr/bin/update-grub")
|
||||
break
|
||||
|
||||
def setupPackage(metapath, filepath):
|
||||
updateInitrd(filepath)
|
||||
|
||||
def cleanupPackage(metapath, filepath):
|
||||
pass
|
||||
|
||||
def postCleanupPackage(metapath, filepath):
|
||||
# TODO: Remove old initramfs!
|
||||
pass
|
||||
@@ -25,13 +25,27 @@
|
||||
<RuntimeDependencies>
|
||||
<Dependency>btrfs-progs</Dependency>
|
||||
</RuntimeDependencies>
|
||||
<Conflicts>
|
||||
<Package>mkinitramfs</Package>
|
||||
<Package>mkinitcpio</Package>
|
||||
</Conflicts>
|
||||
<Files>
|
||||
<Path fileType="executable">/bin/update-initrd</Path>
|
||||
<Path fileType="library">/lib/initrd</Path>
|
||||
</Files>
|
||||
<Provides>
|
||||
<COMAR script="pakhandler.py">System.PackageHandler</COMAR>
|
||||
</Provides>
|
||||
</Package>
|
||||
|
||||
<History>
|
||||
<Update release="6">
|
||||
<Date>2020-09-11</Date>
|
||||
<Version>1.1.4</Version>
|
||||
<Comment>Rebuild</Comment>
|
||||
<Name>Berk Çakar</Name>
|
||||
<Email>berk2238@hotmail.com</Email>
|
||||
</Update>
|
||||
<Update release="5">
|
||||
<Date>2020-09-09</Date>
|
||||
<Version>1.1.4</Version>
|
||||
|
||||
@@ -8,10 +8,15 @@ from pisi.actionsapi import autotools
|
||||
from pisi.actionsapi import get
|
||||
from pisi.actionsapi import pisitools
|
||||
|
||||
|
||||
def build():
|
||||
autotools.make()
|
||||
|
||||
def install():
|
||||
autotools.rawInstall("DESTDIR=%s" % get.installDIR())
|
||||
|
||||
pisitools.removeDir("/usr/lib/kernel")
|
||||
pisitools.removeDir("/usr/lib/tmpfiles.d")
|
||||
pisitools.remove("/usr/lib/initcpio/install/sd-*")
|
||||
pisitools.removeDir("/usr/share/libalpm")
|
||||
|
||||
pisitools.dodoc("LICENSE", "README")
|
||||
|
||||
@@ -3,25 +3,29 @@
|
||||
import os
|
||||
import piksemel
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
|
||||
def generateinitrd(filepath):
|
||||
doc = piksemel.parse(filepath)
|
||||
for item in doc.tags("File"):
|
||||
path = item.getTagData("Path")
|
||||
if path.startswith("lib/modules/"):
|
||||
kver = path.split("/")[2]
|
||||
subprocess.call(["/usr/bin/mkinitcpio","-k","%s"% kver ,"-g","/boot/initramfs-%s-fallback.img"% kver,"-S","autodetect"])
|
||||
subprocess.call(["/usr/bin/mkinitcpio","-k","%s"% kver ,"-c","/etc/mkinitcpio.conf","-g","/boot/initramfs-%s.img"% kver])
|
||||
return
|
||||
def updateInitrd(filepath):
|
||||
patterns = ("/lib/modules", "/usr/lib/initcpio", "/boot/kernel", "/bin/busybox")
|
||||
parse = piksemel.parse(filepath)
|
||||
for xmlfile in parse.tags("File"):
|
||||
path = xmlfile.getTagData("Path")
|
||||
if not path.startswith("/"):
|
||||
path = "/%s" % path
|
||||
if path.startswith(patterns):
|
||||
version = path.split("/")[3]
|
||||
os.environ['PATH'] = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin'
|
||||
subprocess.call(["mkinitcpio","-k","%s"% version ,"-g","/boot/initramfs-%s-fallback.img"% version,"-S","autodetect"])
|
||||
subprocess.call(["mkinitcpio","-k","%s"% version ,"-c","/etc/mkinitcpio.conf","-g","/boot/initramfs-%s.img"% version])
|
||||
if os.path.exists("/proc/cmdline"):
|
||||
os.system("/usr/bin/update-grub")
|
||||
break
|
||||
|
||||
def setupPackage(metapath, filepath):
|
||||
generateinitrd(filepath)
|
||||
updateInitrd(filepath)
|
||||
|
||||
def cleanupPackage(metapath, filepath):
|
||||
pass
|
||||
|
||||
def postCleanupPackage(metapath, filepath):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# needed with new udev/mkinitcpio and as implemented in dracut:
|
||||
# <http://git.kernel.org/?p=boot/dracut/dracut.git;a=commitdiff;h=12b9736228f2b34c15a9cb63be79cf7b6e865b54>
|
||||
SUBSYSTEM=="block", KERNEL=="dm-[0-9]*", ACTION=="add|change", OPTIONS="db_persist"
|
||||
@@ -0,0 +1,93 @@
|
||||
# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
|
||||
# Udev rules for LVM.
|
||||
#
|
||||
# Scan all block devices having a PV label for LVM metadata.
|
||||
# Store this information in LVMetaD (the LVM metadata daemon) and maintain LVM
|
||||
# metadata state for improved performance by avoiding further scans while
|
||||
# running subsequent LVM commands or while using lvm2app library.
|
||||
# Also, notify LVMetaD about any relevant block device removal.
|
||||
#
|
||||
# This rule is essential for having the information in LVMetaD up-to-date.
|
||||
# It also requires blkid to be called on block devices before so only devices
|
||||
# used as LVM PVs are processed (ID_FS_TYPE="LVM2_member" or "LVM1_member").
|
||||
|
||||
SUBSYSTEM!="block", GOTO="lvm_end"
|
||||
|
||||
|
||||
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="lvm_end"
|
||||
|
||||
# If the PV label got lost, inform lvmetad immediately.
|
||||
# Detect the lost PV label by comparing previous ID_FS_TYPE value with current one.
|
||||
ENV{.ID_FS_TYPE_NEW}="$env{ID_FS_TYPE}"
|
||||
IMPORT{db}="ID_FS_TYPE"
|
||||
ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", ENV{.ID_FS_TYPE_NEW}!="LVM2_member|LVM1_member", ENV{LVM_PV_GONE}="1"
|
||||
ENV{ID_FS_TYPE}="$env{.ID_FS_TYPE_NEW}"
|
||||
ENV{LVM_PV_GONE}=="1", GOTO="lvm_scan"
|
||||
|
||||
# Only process devices already marked as a PV - this requires blkid to be called before.
|
||||
ENV{ID_FS_TYPE}!="LVM2_member|LVM1_member", GOTO="lvm_end"
|
||||
ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="lvm_end"
|
||||
|
||||
# Inform lvmetad about any PV that is gone.
|
||||
ACTION=="remove", GOTO="lvm_scan"
|
||||
|
||||
# Create /dev/disk/by-id/lvm-pv-uuid-<PV_UUID> symlink for each PV
|
||||
ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-id/lvm-pv-uuid-$env{ID_FS_UUID_ENC}"
|
||||
|
||||
# If the PV is a special device listed below, scan only if the device is
|
||||
# properly activated. These devices are not usable after an ADD event,
|
||||
# but they require an extra setup and they are ready after a CHANGE event.
|
||||
# Also support coldplugging with ADD event but only if the device is already
|
||||
# properly activated.
|
||||
# This logic should be eventually moved to rules where those particular
|
||||
# devices are processed primarily (MD and loop).
|
||||
|
||||
# DM device:
|
||||
KERNEL!="dm-[0-9]*", GOTO="next"
|
||||
ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}=="1", ENV{DM_ACTIVATION}=="1", GOTO="lvm_scan"
|
||||
GOTO="lvm_end"
|
||||
|
||||
# MD device:
|
||||
LABEL="next"
|
||||
KERNEL!="md[0-9]*", GOTO="next"
|
||||
IMPORT{db}="LVM_MD_PV_ACTIVATED"
|
||||
ACTION=="add", ENV{LVM_MD_PV_ACTIVATED}=="1", GOTO="lvm_scan"
|
||||
ACTION=="change", ENV{LVM_MD_PV_ACTIVATED}!="1", TEST=="md/array_state", ENV{LVM_MD_PV_ACTIVATED}="1", GOTO="lvm_scan"
|
||||
ACTION=="add", KERNEL=="md[0-9]*p[0-9]*", GOTO="lvm_scan"
|
||||
ENV{LVM_MD_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0"
|
||||
GOTO="lvm_end"
|
||||
|
||||
# Loop device:
|
||||
LABEL="next"
|
||||
KERNEL!="loop[0-9]*", GOTO="next"
|
||||
ACTION=="add", ENV{LVM_LOOP_PV_ACTIVATED}=="1", GOTO="lvm_scan"
|
||||
ACTION=="change", ENV{LVM_LOOP_PV_ACTIVATED}!="1", TEST=="loop/backing_file", ENV{LVM_LOOP_PV_ACTIVATED}="1", GOTO="lvm_scan"
|
||||
ENV{LVM_LOOP_PV_ACTIVATED}!="1", ENV{SYSTEMD_READY}="0"
|
||||
GOTO="lvm_end"
|
||||
|
||||
# If the PV is not a special device listed above, scan only after device addition (ADD event)
|
||||
LABEL="next"
|
||||
ACTION!="add", GOTO="lvm_end"
|
||||
|
||||
LABEL="lvm_scan"
|
||||
|
||||
# The table below summarises the situations in which we reach the LABEL="lvm_scan".
|
||||
# Marked by X, X* means only if the special dev is properly set up.
|
||||
# The artificial ADD is supported for coldplugging. We avoid running the pvscan
|
||||
# on artificial CHANGE so there's no unexpected autoactivation when WATCH rule fires.
|
||||
# N.B. MD and loop never actually reaches lvm_scan on REMOVE as the PV label is gone
|
||||
# within a CHANGE event (these are caught by the "LVM_PV_GONE" rule at the beginning).
|
||||
#
|
||||
# | real ADD | real CHANGE | artificial ADD | artificial CHANGE | REMOVE
|
||||
# =============================================================================
|
||||
# DM | | X | X* | | X
|
||||
# MD | | X | X* | |
|
||||
# loop | | X | X* | |
|
||||
# other | X | | X | | X
|
||||
ENV{SYSTEMD_READY}="1"
|
||||
RUN+="/usr/bin/lvm pvscan --background --cache --activate ay --major $major --minor $minor", ENV{LVM_SCANNED}="1"
|
||||
|
||||
LABEL="lvm_end"
|
||||
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/ash
|
||||
|
||||
run_hook() {
|
||||
modprobe -a -q dm-crypt >/dev/null 2>&1
|
||||
[ "${quiet}" = "y" ] && CSQUIET=">/dev/null"
|
||||
|
||||
# Get keyfile if specified
|
||||
ckeyfile="/crypto_keyfile.bin"
|
||||
if [ -n "$cryptkey" ]; then
|
||||
IFS=: read ckdev ckarg1 ckarg2 <<EOF
|
||||
$cryptkey
|
||||
EOF
|
||||
|
||||
if [ "$ckdev" = "rootfs" ]; then
|
||||
ckeyfile=$ckarg1
|
||||
elif resolved=$(resolve_device "${ckdev}" ${rootdelay}); then
|
||||
case ${ckarg1} in
|
||||
*[!0-9]*)
|
||||
# Use a file on the device
|
||||
# ckarg1 is not numeric: ckarg1=filesystem, ckarg2=path
|
||||
mkdir /ckey
|
||||
mount -r -t "$ckarg1" "$resolved" /ckey
|
||||
dd if="/ckey/$ckarg2" of="$ckeyfile" >/dev/null 2>&1
|
||||
umount /ckey
|
||||
;;
|
||||
*)
|
||||
# Read raw data from the block device
|
||||
# ckarg1 is numeric: ckarg1=offset, ckarg2=length
|
||||
dd if="$resolved" of="$ckeyfile" bs=1 skip="$ckarg1" count="$ckarg2" >/dev/null 2>&1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
[ ! -f ${ckeyfile} ] && echo "Keyfile could not be opened. Reverting to passphrase."
|
||||
fi
|
||||
|
||||
if [ -n "${cryptdevice}" ]; then
|
||||
DEPRECATED_CRYPT=0
|
||||
IFS=: read cryptdev cryptname cryptoptions <<EOF
|
||||
$cryptdevice
|
||||
EOF
|
||||
else
|
||||
DEPRECATED_CRYPT=1
|
||||
cryptdev="${root}"
|
||||
cryptname="root"
|
||||
fi
|
||||
|
||||
# This may happen if third party hooks do the crypt setup
|
||||
if [ -b "/dev/mapper/${cryptname}" ]; then
|
||||
echo "Device ${cryptname} already exists, not doing any crypt setup."
|
||||
return 0
|
||||
fi
|
||||
|
||||
warn_deprecated() {
|
||||
echo "The syntax 'root=${root}' where '${root}' is an encrypted volume is deprecated"
|
||||
echo "Use 'cryptdevice=${root}:root root=/dev/mapper/root' instead."
|
||||
}
|
||||
|
||||
for cryptopt in ${cryptoptions//,/ }; do
|
||||
case ${cryptopt} in
|
||||
allow-discards)
|
||||
cryptargs="${cryptargs} --allow-discards"
|
||||
;;
|
||||
*)
|
||||
echo "Encryption option '${cryptopt}' not known, ignoring." >&2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if resolved=$(resolve_device "${cryptdev}" ${rootdelay}); then
|
||||
if cryptsetup isLuks ${resolved} >/dev/null 2>&1; then
|
||||
[ ${DEPRECATED_CRYPT} -eq 1 ] && warn_deprecated
|
||||
dopassphrase=1
|
||||
# If keyfile exists, try to use that
|
||||
if [ -f ${ckeyfile} ]; then
|
||||
if eval cryptsetup --key-file ${ckeyfile} open --type luks ${resolved} ${cryptname} ${cryptargs} ${CSQUIET}; then
|
||||
dopassphrase=0
|
||||
else
|
||||
echo "Invalid keyfile. Reverting to passphrase."
|
||||
fi
|
||||
fi
|
||||
# Ask for a passphrase
|
||||
if [ ${dopassphrase} -gt 0 ]; then
|
||||
echo ""
|
||||
echo "A password is required to access the ${cryptname} volume:"
|
||||
|
||||
#loop until we get a real password
|
||||
while ! eval cryptsetup open --type luks ${resolved} ${cryptname} ${cryptargs} ${CSQUIET}; do
|
||||
sleep 2;
|
||||
done
|
||||
fi
|
||||
if [ -e "/dev/mapper/${cryptname}" ]; then
|
||||
if [ ${DEPRECATED_CRYPT} -eq 1 ]; then
|
||||
export root="/dev/mapper/root"
|
||||
fi
|
||||
else
|
||||
err "Password succeeded, but ${cryptname} creation failed, aborting..."
|
||||
return 1
|
||||
fi
|
||||
elif [ -n "${crypto}" ]; then
|
||||
[ ${DEPRECATED_CRYPT} -eq 1 ] && warn_deprecated
|
||||
msg "Non-LUKS encrypted device found..."
|
||||
if echo "$crypto" | awk -F: '{ exit(NF == 5) }'; then
|
||||
err "Verify parameter format: crypto=hash:cipher:keysize:offset:skip"
|
||||
err "Non-LUKS decryption not attempted..."
|
||||
return 1
|
||||
fi
|
||||
exe="cryptsetup open --type plain $resolved $cryptname $cryptargs"
|
||||
IFS=: read c_hash c_cipher c_keysize c_offset c_skip <<EOF
|
||||
$crypto
|
||||
EOF
|
||||
[ -n "$c_hash" ] && exe="$exe --hash '$c_hash'"
|
||||
[ -n "$c_cipher" ] && exe="$exe --cipher '$c_cipher'"
|
||||
[ -n "$c_keysize" ] && exe="$exe --key-size '$c_keysize'"
|
||||
[ -n "$c_offset" ] && exe="$exe --offset '$c_offset'"
|
||||
[ -n "$c_skip" ] && exe="$exe --skip '$c_skip'"
|
||||
if [ -f "$ckeyfile" ]; then
|
||||
exe="$exe --key-file $ckeyfile"
|
||||
else
|
||||
echo ""
|
||||
echo "A password is required to access the ${cryptname} volume:"
|
||||
fi
|
||||
eval "$exe $CSQUIET"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
err "Non-LUKS device decryption failed. verify format: "
|
||||
err " crypto=hash:cipher:keysize:offset:skip"
|
||||
return 1
|
||||
fi
|
||||
if [ -e "/dev/mapper/${cryptname}" ]; then
|
||||
if [ ${DEPRECATED_CRYPT} -eq 1 ]; then
|
||||
export root="/dev/mapper/root"
|
||||
fi
|
||||
else
|
||||
err "Password succeeded, but ${cryptname} creation failed, aborting..."
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
err "Failed to open encryption mapping: The device ${cryptdev} is not a LUKS volume and the crypto= paramater was not specified."
|
||||
fi
|
||||
fi
|
||||
rm -f ${ckeyfile}
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
build() {
|
||||
local mod
|
||||
|
||||
add_module "dm-crypt"
|
||||
add_module "dm-integrity"
|
||||
if [[ $CRYPTO_MODULES ]]; then
|
||||
for mod in $CRYPTO_MODULES; do
|
||||
add_module "$mod"
|
||||
done
|
||||
else
|
||||
add_all_modules "/crypto/"
|
||||
fi
|
||||
|
||||
add_binary "cryptsetup"
|
||||
add_binary "dmsetup"
|
||||
add_file "/usr/lib/udev/rules.d/10-dm.rules"
|
||||
add_file "/usr/lib/udev/rules.d/13-dm-disk.rules"
|
||||
add_file "/usr/lib/udev/rules.d/95-dm-notify.rules"
|
||||
add_file "/usr/lib/initcpio/udev/11-dm-initramfs.rules" "/usr/lib/udev/rules.d/11-dm-initramfs.rules"
|
||||
|
||||
# cryptsetup calls pthread_create(), which dlopen()s libgcc_s.so.1
|
||||
add_binary "/usr/lib/libgcc_s.so.1"
|
||||
|
||||
add_runscript
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<HELPEOF
|
||||
This hook allows for an encrypted root device. Users should specify the device
|
||||
to be unlocked using 'cryptdevice=device:dmname' on the kernel command line,
|
||||
where 'device' is the path to the raw device, and 'dmname' is the name given to
|
||||
the device after unlocking, and will be available as /dev/mapper/dmname.
|
||||
|
||||
For unlocking via keyfile, 'cryptkey=device:fstype:path' should be specified on
|
||||
the kernel cmdline, where 'device' represents the raw block device where the key
|
||||
exists, 'fstype' is the filesystem type of 'device' (or auto), and 'path' is
|
||||
the absolute path of the keyfile within the device.
|
||||
|
||||
Without specifying a keyfile, you will be prompted for the password at runtime.
|
||||
This means you must have a keyboard available to input it, and you may need
|
||||
the keymap hook as well to ensure that the keyboard is using the layout you
|
||||
expect.
|
||||
HELPEOF
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
@@ -0,0 +1,40 @@
|
||||
Because not all Void kernels may support zstd, change the default initramfs
|
||||
compression to gzip.
|
||||
|
||||
diff -ur a/man/mkinitcpio.conf.5.txt b/man/mkinitcpio.conf.5.txt
|
||||
--- a/man/mkinitcpio.conf.5.txt 2021-02-16 21:37:31.000000000 -0500
|
||||
+++ b/man/mkinitcpio.conf.5.txt 2021-05-17 09:33:32.418504652 -0400
|
||||
@@ -55,7 +55,7 @@
|
||||
Defines a program to filter the generated image through. The kernel
|
||||
understands the compression formats yielded by the *zstd*, *gzip*, *bzip2*,
|
||||
*lz4*, *lzop*, *lzma*, and *xz* compressors. If unspecified, this setting
|
||||
- defaults to *zstd* compression. In order to create an uncompressed image,
|
||||
+ defaults to *gzip* compression. In order to create an uncompressed image,
|
||||
define this variable as *cat*.
|
||||
+
|
||||
It's not hard to realize that a filter such as a *tac* or *rev* will cause
|
||||
diff -ur a/mkinitcpio b/mkinitcpio
|
||||
--- a/mkinitcpio 2021-02-16 21:37:31.000000000 -0500
|
||||
+++ b/mkinitcpio 2021-05-17 09:34:15.970588222 -0400
|
||||
@@ -508,7 +508,7 @@
|
||||
die 'Unable to write to %s' "$_optgenimg"
|
||||
fi
|
||||
|
||||
- _optcompress=${_optcompress:-${COMPRESSION:-zstd}}
|
||||
+ _optcompress=${_optcompress:-${COMPRESSION:-gzip}}
|
||||
if ! type -P "$_optcompress" >/dev/null; then
|
||||
warning "Unable to locate compression method: %s" "$_optcompress"
|
||||
_optcompress=cat
|
||||
diff -ur a/mkinitcpio.conf b/mkinitcpio.conf
|
||||
--- a/mkinitcpio.conf 2021-02-16 21:37:31.000000000 -0500
|
||||
+++ b/mkinitcpio.conf 2021-05-17 09:34:24.752605714 -0400
|
||||
@@ -52,7 +52,7 @@
|
||||
HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)
|
||||
|
||||
# COMPRESSION
|
||||
-# Use this to compress the initramfs image. By default, zstd compression
|
||||
+# Use this to compress the initramfs image. By default, gzip compression
|
||||
# is used. Use 'cat' to create an uncompressed image.
|
||||
#COMPRESSION="zstd"
|
||||
#COMPRESSION="gzip"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/bash
|
||||
# See: https://gitlab.com/tearch-linux/applications-and-tools/mkinitcpio-teaiso
|
||||
|
||||
live_mount(){
|
||||
mkdir -p /pisi/a # upper
|
||||
mkdir -p /pisi/b # workdir
|
||||
mkdir -p /live_root/
|
||||
mkdir -p /new_root/
|
||||
mkdir -p /source/ # lower
|
||||
mount $root /new_root/ 2> /dev/null
|
||||
mount /new_root/live/pisi.sfs /source/ 2> /dev/null
|
||||
mount -t overlay -o lowerdir=/source/,upperdir=/pisi/a/,workdir=/pisi/b overlay /live_root
|
||||
mount -t tmpfs -o size=100% none /pisi/a
|
||||
mount -t tmpfs -o size=100% none /pisi/b
|
||||
[ -d /source/merge/ ] && cp -prfv /source/merge/* /live_root/
|
||||
mount --bind /live_root /new_root/
|
||||
mkdir /new_root/cdrom/ 2> /dev/null
|
||||
mkdir /new_root/source/ 2> /dev/null
|
||||
mount $root /new_root/cdrom/ 2> /dev/null
|
||||
mount /new_root/cdrom/live/pisi.sfs /new_root/source/ 2> /dev/null
|
||||
[ "$home" != "" ] && mount $home /new_root/home 2>/dev/null
|
||||
}
|
||||
|
||||
is_file_avaiable(){
|
||||
disktmp=$(mktemp)
|
||||
rm -f $disktmp
|
||||
mkdir -p $disktmp || true
|
||||
timeout 10 mount -t auto "$1" $disktmp &>/dev/null
|
||||
[ -f "$disktmp/$2" ] && [ -b "$1" ]
|
||||
status=$?
|
||||
umount -lf $disktmp 2>/dev/null
|
||||
return $status
|
||||
}
|
||||
|
||||
run_hook() {
|
||||
# live-boot
|
||||
if cat /proc/cmdline | grep "boot=live" >/dev/null ; then
|
||||
while [ "$root" == "" ] ; do
|
||||
list=$(ls /sys/class/block/ | grep ".*[0-9]$" | grep -v loop | grep -v ram | grep -v nbd | grep -v fd | sed "s|^|/dev/|g")
|
||||
for part in $list
|
||||
do
|
||||
sleep 0.1
|
||||
echo "Looking for: $part"
|
||||
if is_file_avaiable "$part" "/live/pisi.sfs"
|
||||
then
|
||||
export root=$part
|
||||
elif is_file_avaiable "$part" "/mount-me"
|
||||
then
|
||||
export home=$part
|
||||
fi
|
||||
done
|
||||
done
|
||||
export mount_handler="live_mount"
|
||||
fi
|
||||
}
|
||||
|
||||
run_latehook(){
|
||||
if ! cat /proc/cmdline | grep "init=" ; then
|
||||
export init=/sbin/init
|
||||
fi
|
||||
sleep 0.3
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
# See: https://gitlab.com/tearch-linux/applications-and-tools/mkinitcpio-teaiso
|
||||
|
||||
build() {
|
||||
add_module "cdrom"
|
||||
add_module "loop"
|
||||
add_module "dm-snapshot"
|
||||
add_module "overlay"
|
||||
add_module "isofs"
|
||||
add_module "squashfs"
|
||||
add_module "hfsplus"
|
||||
add_module "sr_mod"
|
||||
add_module "dm_mod"
|
||||
|
||||
add_runscript
|
||||
|
||||
add_all_modules -f 'nls' '/kernel/fs'
|
||||
add_all_modules -f 'overlayfs' '/kernel/fs'
|
||||
add_all_modules -f 'squashfs' '/kernel/fs'
|
||||
add_all_modules -f 'udf' '/kernel/fs'
|
||||
add_all_modules -f 'ext4' '/kernel/fs'
|
||||
add_all_modules -f 'hfsplus' '/kernel/fs'
|
||||
add_all_modules -f 'usb-storage' '/kernel/drivers/usb'
|
||||
|
||||
add_binary "timeout"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/ash
|
||||
|
||||
run_earlyhook() {
|
||||
mkdir /run/lvm
|
||||
lvmetad
|
||||
}
|
||||
|
||||
# We are suffering a race condition in non-systemd initramfs: If lvmetad is
|
||||
# killed before pvscan processes finish we have stale processes and
|
||||
# uninitialized physical volumes. So wait for pvscan processes to finish.
|
||||
# Break after 10 seconds (50*0.2s) to avaid infinite loop.
|
||||
run_latehook() {
|
||||
local i=50
|
||||
|
||||
while pgrep -f pvscan >/dev/null 2>/dev/null && [ $i -gt 0 ]; do
|
||||
sleep 0.2
|
||||
i=$((i - 1))
|
||||
done
|
||||
}
|
||||
|
||||
run_cleanuphook() {
|
||||
kill $(cat /run/lvmetad.pid)
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
build() {
|
||||
local mod
|
||||
local symlink
|
||||
|
||||
# device mapper modules
|
||||
for mod in dm-mod dm-snapshot dm-mirror dm-cache dm-cache-smq dm-thin-pool; do
|
||||
add_module "$mod"
|
||||
done
|
||||
|
||||
# binaries from lvm2
|
||||
add_binary "lvm"
|
||||
add_binary "lvmetad"
|
||||
|
||||
# beinaries from device-mapper
|
||||
add_binary "dmsetup"
|
||||
|
||||
# from thin-provisioning-tools
|
||||
add_binary "pdata_tools"
|
||||
for symlink in cache_{check,dump,metadata_size,repair,restore} thin_{check,delta,dump,ls,metadata_size,repair,restore,rmap,trim}; do
|
||||
add_symlink "/usr/bin/${symlink}" "pdata_tools"
|
||||
done
|
||||
|
||||
# udev rules and lvm configuration
|
||||
add_file "/usr/lib/udev/rules.d/10-dm.rules"
|
||||
add_file "/usr/lib/udev/rules.d/11-dm-lvm.rules"
|
||||
add_file "/usr/lib/udev/rules.d/13-dm-disk.rules"
|
||||
add_file "/usr/lib/udev/rules.d/95-dm-notify.rules"
|
||||
add_file "/usr/lib/initcpio/udev/11-dm-initramfs.rules" "/usr/lib/udev/rules.d/11-dm-initramfs.rules"
|
||||
add_file "/usr/lib/initcpio/udev/69-dm-lvm-metad.rules" "/usr/lib/udev/rules.d/69-dm-lvm-metad.rules"
|
||||
add_file "/etc/lvm/lvm.conf"
|
||||
|
||||
add_runscript
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<HELPEOF
|
||||
This hook enables LVM2 volumes in initramfs.
|
||||
HELPEOF
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/ash
|
||||
|
||||
run_hook() {
|
||||
local i= mdconfig=/etc/mdadm.conf
|
||||
|
||||
# for partitionable raid, we need to load md_mod first!
|
||||
modprobe md_mod 2>/dev/null
|
||||
|
||||
if [ -n "$md" ]; then
|
||||
echo 'DEVICE partitions' >"$mdconfig"
|
||||
for i in $(cat /proc/cmdline); do
|
||||
case $i in
|
||||
# raid
|
||||
md=[0-9]*,/*)
|
||||
device=${i%%,*}
|
||||
device=${device/=/}
|
||||
array=${i#*,}
|
||||
echo "ARRAY /dev/$device devices=$array"
|
||||
;;
|
||||
# partitionable raid
|
||||
md=d[0-9]*,/*)
|
||||
device=${i%%,*}
|
||||
device=${device/=/_}
|
||||
array=${i#*,}
|
||||
echo "ARRAY /dev/$device devices=$array"
|
||||
;;
|
||||
# raid UUID
|
||||
md=[0-9]*,[0-9,a-fA-F]*)
|
||||
device=${i%%,*}
|
||||
device=${device/=/}
|
||||
array=${i#*,}
|
||||
echo "ARRAY /dev/$device UUID=$array"
|
||||
;;
|
||||
# partitionable raid UUID
|
||||
md=d[0-9]*,[0-9,a-fA-F]*)
|
||||
device=${i%%,*}
|
||||
device=${device/=/_}
|
||||
array=${i#*,}
|
||||
echo "ARRAY /dev/$device UUID=$array"
|
||||
;;
|
||||
esac
|
||||
done >>"$mdconfig"
|
||||
fi
|
||||
|
||||
# assemble everything
|
||||
[ -s "$mdconfig" ] && /usr/bin/mdassemble
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
build() {
|
||||
add_checked_modules -f 'dm-' 'drivers/md/*'
|
||||
|
||||
# check if a custom mdadm.conf exists
|
||||
if grep -q ^ARRAY /etc/mdadm.conf; then
|
||||
echo "Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays."
|
||||
add_file "/etc/mdadm.conf"
|
||||
fi
|
||||
add_binary "/usr/bin/mdassemble"
|
||||
add_file "/usr/lib/udev/rules.d/63-md-raid-arrays.rules"
|
||||
|
||||
add_runscript
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<HELPEOF
|
||||
This hook loads the necessary modules for any raid root device,
|
||||
and assembles the raid device when run.
|
||||
|
||||
If arrays are defined in /etc/mdadm.conf, the file will be used instead
|
||||
of command line assembling.
|
||||
|
||||
Command Line Setup:
|
||||
- for raid arrays with persistent superblocks:
|
||||
md=<md device no.>,dev0,dev1,...,devn
|
||||
md=<md device no.>,uuid
|
||||
- for partitionable raid arrays with persistent superblocks:
|
||||
md=d<md device no.>,dev0,dev1,...,devn
|
||||
md=d<md device no.>,uuid
|
||||
|
||||
Parameters:
|
||||
- <md device no.> = the number of the md device:
|
||||
0 means md0, 1 means md1, ...
|
||||
- <dev0-devn>: e.g. /dev/hda1,/dev/hdc1,/dev/sda1,/dev/sdb1
|
||||
or 0900878d:f95f6057:c39a36e9:55efa60a
|
||||
Examples:
|
||||
- md=d0,/dev/sda3,/dev/sda4 md=d1,/dev/hda1,/dev/hdb1
|
||||
This will setup 2 md partitionable arrays.
|
||||
- md=0,/dev/sda3,/dev/sda4 md=1,/dev/hda1,/dev/hdb1
|
||||
This will setup 2 md arrays with persistent superblocks.
|
||||
HELPEOF
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
build() {
|
||||
add_checked_modules -f 'dm-' 'drivers/md/*'
|
||||
|
||||
# check if a custom mdadm.conf exists
|
||||
if grep -qw ^ARRAY "$BASEDIR/etc/mdadm.conf"; then
|
||||
echo "Custom /etc/mdadm.conf file will be used in initramfs for assembling arrays."
|
||||
add_file "/etc/mdadm.conf"
|
||||
fi
|
||||
|
||||
add_binary "/usr/bin/mdadm"
|
||||
add_file "/usr/lib/udev/rules.d/63-md-raid-arrays.rules"
|
||||
add_file "/usr/lib/udev/rules.d/64-md-raid-assembly.rules"
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<HELPEOF
|
||||
This hook loads the necessary modules for a RAID array and uses incremental
|
||||
assembly via udev at runtime to create the devices. This hook will NOT work
|
||||
without the udev hook included on the image.
|
||||
HELPEOF
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
@@ -0,0 +1,49 @@
|
||||
Makefile | 6 +-----
|
||||
init_functions | 11 -----------
|
||||
2 files changed, 1 insertion(+), 16 deletions(-)
|
||||
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 9ef0f6a..f6e322e 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -17,7 +17,6 @@ DIRS = \
|
||||
/usr/share/man/man5 \
|
||||
/usr/share/man/man1 \
|
||||
/usr/share/mkinitcpio \
|
||||
- /usr/lib/systemd/system/shutdown.target.wants \
|
||||
/usr/lib/tmpfiles.d \
|
||||
/usr/share/libalpm/hooks \
|
||||
/usr/share/libalpm/scripts
|
||||
@@ -57,10 +56,7 @@ install: all
|
||||
|
||||
cp -at $(DESTDIR)/usr/lib/initcpio hooks install
|
||||
install -m644 -t $(DESTDIR)/usr/share/mkinitcpio mkinitcpio.d/*
|
||||
- install -m644 systemd/mkinitcpio-generate-shutdown-ramfs.service \
|
||||
- $(DESTDIR)/usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service
|
||||
- ln -s ../mkinitcpio-generate-shutdown-ramfs.service \
|
||||
- $(DESTDIR)/usr/lib/systemd/system/shutdown.target.wants/mkinitcpio-generate-shutdown-ramfs.service
|
||||
+
|
||||
install -m644 tmpfiles/mkinitcpio.conf $(DESTDIR)/usr/lib/tmpfiles.d/mkinitcpio.conf
|
||||
|
||||
install -m755 50-mkinitcpio.install $(DESTDIR)/usr/lib/kernel/install.d/50-mkinitcpio.install
|
||||
diff --git a/init_functions b/init_functions
|
||||
index 8ad10c7..5579a49 100644
|
||||
--- a/init_functions
|
||||
+++ b/init_functions
|
||||
@@ -298,17 +298,6 @@ fsck_root() {
|
||||
elif bitfield_has_bit "$fsckret" 128; then
|
||||
err "fatal error invoking fsck"
|
||||
fi
|
||||
-
|
||||
- # ensure that root is going to be mounted rw. Otherwise, systemd
|
||||
- # might fsck the device again. Annoy the user so that they fix this.
|
||||
- if [ "${rwopt:-ro}" != 'rw' ]; then
|
||||
- echo "********************** WARNING **********************"
|
||||
- echo "* *"
|
||||
- echo "* The root device is not configured to be mounted *"
|
||||
- echo "* read-write! It may be fsck'd again later. *"
|
||||
- echo "* *"
|
||||
- echo "*****************************************************"
|
||||
- fi
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/ash
|
||||
|
||||
run_earlyhook() {
|
||||
udevd --daemon --resolve-names=never
|
||||
udevd_running=1
|
||||
}
|
||||
|
||||
run_hook() {
|
||||
msg ":: Triggering uevents..."
|
||||
udevadm trigger --action=add --type=subsystems
|
||||
udevadm trigger --action=add --type=devices
|
||||
udevadm settle
|
||||
}
|
||||
|
||||
run_cleanuphook() {
|
||||
udevadm control --exit
|
||||
udevadm info --cleanup-db
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
build() {
|
||||
add_file "/etc/udev/udev.conf"
|
||||
add_binary /sbin/udevd
|
||||
add_binary /bin/udevadm
|
||||
|
||||
for rule in 50-udev-default.rules 60-persistent-storage.rules 64-btrfs.rules 80-drivers.rules; do
|
||||
add_file "/lib/udev/rules.d/$rule"
|
||||
done
|
||||
|
||||
for tool in ata_id scsi_id; do
|
||||
add_file "/lib/udev/$tool"
|
||||
done
|
||||
|
||||
add_runscript
|
||||
}
|
||||
|
||||
help() {
|
||||
cat <<HELPEOF
|
||||
This hook will use udev to create your root device node and detect the needed
|
||||
modules for your root device. It is also required for firmware loading in
|
||||
initramfs. It is recommended to use this hook.
|
||||
HELPEOF
|
||||
}
|
||||
|
||||
# vim: set ft=sh ts=4 sw=4 et:
|
||||
@@ -0,0 +1,218 @@
|
||||
#
|
||||
# WARNING: This script is parsed by ash in busybox at boot time, not bash!
|
||||
# http://linux.die.net/man/1/ash
|
||||
# https://wiki.ubuntu.com/DashAsBinSh
|
||||
# http://www.jpsdomain.org/public/2008-JP_bash_vs_dash.pdf
|
||||
#
|
||||
ZPOOL_FORCE=""
|
||||
ZPOOL_IMPORT_FLAGS=""
|
||||
ZFS_BOOT_ONLY=""
|
||||
|
||||
zfs_get_bootfs () {
|
||||
for zfs_dataset in $(zpool list -H -o bootfs); do
|
||||
case ${zfs_dataset} in
|
||||
"" | "-")
|
||||
# skip this line/dataset
|
||||
;;
|
||||
"no pools available")
|
||||
return 1
|
||||
;;
|
||||
*)
|
||||
ZFS_DATASET=${zfs_dataset}
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
zfs_decrypt_fs() {
|
||||
dataset=$1
|
||||
|
||||
# Make sure dataset is encrypted; get fails if ZFS does not support encryption
|
||||
encryption="$(zfs get -H -o value encryption "${dataset}" 2>/dev/null)" || return 0
|
||||
[ "${encryption}" != "off" ] || return 0
|
||||
|
||||
# Make sure the dataset is locked
|
||||
keystatus="$(zfs get -H -o value keystatus "${dataset}")" || return 0
|
||||
[ "${keystatus}" != "available" ] || return 0
|
||||
|
||||
# Make sure the encryptionroot is sensible
|
||||
encryptionroot="$(zfs get -H -o value encryptionroot "${dataset}")" || return 0
|
||||
[ "${encryptionroot}" != "-" ] || return 0
|
||||
|
||||
# Export encryption root to be used by other hooks (SSH)
|
||||
echo "${encryptionroot}" > /.encryptionroot
|
||||
|
||||
# If key location is a file, determine if it can by overridden by prompt
|
||||
prompt_override=""
|
||||
if keylocation="$(zfs get -H -o value keylocation "${dataset}")"; then
|
||||
if [ "${keylocation}" != "prompt" ]; then
|
||||
if keyformat="$(zfs get -H -o value keyformat "${dataset}")"; then
|
||||
[ "${keyformat}" = "passphrase" ] && prompt_override="yes"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Loop until key is loaded here or by another vector (SSH, for instance)
|
||||
while [ "$(zfs get -H -o value keystatus "${encryptionroot}")" != "available" ]; do
|
||||
# Try the default loading mechanism
|
||||
zfs load-key "${encryptionroot}" && break
|
||||
|
||||
# Load failed, try a prompt if the failure was not a prompt
|
||||
if [ -n "${prompt_override}" ]; then
|
||||
echo "Unable to load key ${keylocation}; please type the passphrase"
|
||||
echo "To retry the file, interrupt now or repeatedly input a wrong passphrase"
|
||||
zfs load-key -L prompt "${encryptionroot}" && break
|
||||
fi
|
||||
|
||||
# Throttle retry attempts
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if [ -f /.encryptionroot ]; then
|
||||
rm /.encryptionroot
|
||||
fi
|
||||
}
|
||||
|
||||
zfs_mount_handler () {
|
||||
if [ "${ZFS_DATASET}" = "bootfs" ] ; then
|
||||
if ! zfs_get_bootfs ; then
|
||||
# Lets import everything and try again
|
||||
zpool import ${ZPOOL_IMPORT_FLAGS} -N -a ${ZPOOL_FORCE}
|
||||
if ! zfs_get_bootfs ; then
|
||||
err "ZFS: Cannot find bootfs."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
local pool="${ZFS_DATASET%%/*}"
|
||||
local rwopt_exp="${rwopt:-rw}"
|
||||
|
||||
if ! zpool list -H "${pool}" > /dev/null 2>&1; then
|
||||
if [ ! "${rwopt_exp}" = "rw" ]; then
|
||||
msg "ZFS: Importing pool ${pool} readonly."
|
||||
ZPOOL_IMPORT_FLAGS="${ZPOOL_IMPORT_FLAGS} -o readonly=on"
|
||||
else
|
||||
msg "ZFS: Importing pool ${pool}."
|
||||
fi
|
||||
|
||||
if ! zpool import ${ZPOOL_IMPORT_FLAGS} -N "${pool}" ${ZPOOL_FORCE} ; then
|
||||
err "ZFS: Unable to import pool ${pool}."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
local node="$1"
|
||||
local rootmnt=$(zfs get -H -o value mountpoint "${ZFS_DATASET}")
|
||||
local tab_file="${node}/etc/fstab"
|
||||
local zfs_datasets="$(zfs list -H -o name -t filesystem -r ${ZFS_DATASET})"
|
||||
|
||||
# Mount the root, and any child datasets
|
||||
for dataset in ${zfs_datasets}; do
|
||||
mountpoint=$(zfs get -H -o value mountpoint "${dataset}")
|
||||
canmount=$(zfs get -H -o value canmount "${dataset}")
|
||||
# skip dataset
|
||||
[ ${dataset} != "${ZFS_DATASET}" -a \( ${canmount} = "off" -o ${canmount} = "noauto" -o ${mountpoint} = "none" \) ] && continue
|
||||
if [ ${mountpoint} = "legacy" ]; then
|
||||
if [ -f "${tab_file}" ]; then
|
||||
if findmnt -snero source -F "${tab_file}" -S "${dataset}" > /dev/null 2>&1; then
|
||||
opt=$(findmnt -snero options -F "${tab_file}" -S "${dataset}")
|
||||
mnt=$(findmnt -snero target -F "${tab_file}" -S "${dataset}")
|
||||
zfs_decrypt_fs "${dataset}"
|
||||
mount -t zfs -o "${opt}" "${dataset}" "${node}${mnt}"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
zfs_decrypt_fs "${dataset}"
|
||||
mount -t zfs -o "zfsutil,${rwopt_exp}" "${dataset}" "${node}/${mountpoint##${rootmnt}}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
set_flags() {
|
||||
# Force import the pools, useful if the pool has not properly been exported using 'zpool export <pool>'
|
||||
[ ! "${zfs_force}" = "" ] && ZPOOL_FORCE="-f"
|
||||
|
||||
# Disable late hook, useful if we want to use zfs-import-cache.service instead
|
||||
[ ! "${zfs_boot_only}" = "" ] && ZFS_BOOT_ONLY="1"
|
||||
|
||||
# Add import directory to import command flags
|
||||
[ ! "${zfs_import_dir}" = "" ] && ZPOOL_IMPORT_FLAGS="${ZPOOL_IMPORT_FLAGS} -d ${zfs_import_dir}"
|
||||
[ "${zfs_import_dir}" = "" ] && [ -f /etc/zfs/zpool.cache.org ] && ZPOOL_IMPORT_FLAGS="${ZPOOL_IMPORT_FLAGS} -c /etc/zfs/zpool.cache.org"
|
||||
}
|
||||
|
||||
run_hook() {
|
||||
set_flags
|
||||
|
||||
# Wait 15 seconds for ZFS devices to show up
|
||||
[ "${zfs_wait}" = "" ] && ZFS_WAIT="15" || ZFS_WAIT="${zfs_wait}"
|
||||
|
||||
case ${root} in
|
||||
# root=zfs
|
||||
"zfs")
|
||||
mount_handler="zfs_mount_handler"
|
||||
;;
|
||||
# root=ZFS=... syntax (grub)
|
||||
"ZFS="*)
|
||||
mount_handler="zfs_mount_handler"
|
||||
ZFS_DATASET="${root#*[=]}"
|
||||
;;
|
||||
# root=zfs:... syntax (dracut)
|
||||
"zfs:"*)
|
||||
mount_handler="zfs_mount_handler"
|
||||
ZFS_DATASET="${root#*[:]}"
|
||||
;;
|
||||
esac
|
||||
|
||||
case ${zfs} in
|
||||
"")
|
||||
# skip this line/dataset
|
||||
;;
|
||||
auto|bootfs)
|
||||
ZFS_DATASET="bootfs"
|
||||
mount_handler="zfs_mount_handler"
|
||||
local pool="[a-zA-Z][^ ]*"
|
||||
;;
|
||||
*)
|
||||
ZFS_DATASET="${zfs}"
|
||||
mount_handler="zfs_mount_handler"
|
||||
local pool="${ZFS_DATASET%%/*}"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Allow at least n seconds for zfs device to show up. Especially
|
||||
# when using zfs_import_dir instead of zpool.cache, the listing of
|
||||
# available pools can be slow, so this loop must be top-tested to
|
||||
# ensure we do one 'zpool import' pass after the timer has expired.
|
||||
sleep ${ZFS_WAIT} & pid=$!
|
||||
local break_after=0
|
||||
while :; do
|
||||
kill -0 $pid > /dev/null 2>&1 || break_after=1
|
||||
if [ -c "/dev/zfs" ]; then
|
||||
zpool import ${ZPOOL_IMPORT_FLAGS} | awk "
|
||||
BEGIN { pool_found=0; online=0; unavail=0 }
|
||||
/^ ${pool} .*/ { pool_found=1 }
|
||||
/^\$/ { pool_found=0 }
|
||||
/UNAVAIL/ { if (pool_found == 1) { unavail=1 } }
|
||||
/ONLINE/ { if (pool_found == 1) { online=1 } }
|
||||
END { if (online == 1 && unavail != 1)
|
||||
{ exit 0 }
|
||||
else
|
||||
{ exit 1 }
|
||||
}" && break
|
||||
fi
|
||||
[ $break_after == 1 ] && break
|
||||
sleep 1
|
||||
done
|
||||
kill $pid > /dev/null 2>&1
|
||||
}
|
||||
|
||||
run_latehook () {
|
||||
set_flags
|
||||
# only run zpool import, if flags were set (cache file found / zfs_import_dir specified) and zfs_boot_only is not set
|
||||
[ ! "${ZPOOL_IMPORT_FLAGS}" = "" ] && [ "${ZFS_BOOT_ONLY}" = "" ] && zpool import ${ZPOOL_IMPORT_FLAGS} -N -a ${ZPOOL_FORCE}
|
||||
}
|
||||
|
||||
# vim:set ts=4 sw=4 ft=sh et:
|
||||
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
build() {
|
||||
map add_module \
|
||||
zavl \
|
||||
znvpair \
|
||||
zunicode \
|
||||
zcommon \
|
||||
zfs \
|
||||
spl
|
||||
|
||||
map add_binary \
|
||||
fsck.zfs \
|
||||
mount.zfs \
|
||||
seq \
|
||||
zdb \
|
||||
zed \
|
||||
zfs \
|
||||
zhack \
|
||||
zinject \
|
||||
zpool \
|
||||
zstreamdump \
|
||||
/usr/lib/udev/vdev_id \
|
||||
/usr/lib/udev/zvol_id \
|
||||
findmnt
|
||||
|
||||
map add_file \
|
||||
/usr/lib/udev/rules.d/60-zvol.rules \
|
||||
/usr/lib/udev/rules.d/69-vdev.rules \
|
||||
/usr/lib/udev/rules.d/90-zfs.rules \
|
||||
/usr/lib/libgcc_s.so.1
|
||||
|
||||
map add_dir \
|
||||
/etc/zfs/zed.d
|
||||
|
||||
add_runscript
|
||||
|
||||
# allow mount(8) to "autodetect" ZFS
|
||||
echo 'zfs' >>"${BUILDROOT}/etc/filesystems"
|
||||
|
||||
[[ -f /etc/hostid ]] && add_file "/etc/hostid"
|
||||
[[ -f /etc/zfs/zpool.cache ]] && cp "/etc/zfs/zpool.cache" "${BUILDROOT}/etc/zfs/zpool.cache.org"
|
||||
[[ -f /etc/modprobe.d/zfs.conf ]] && add_file "/etc/modprobe.d/zfs.conf"
|
||||
}
|
||||
|
||||
help() {
|
||||
cat<<HELPEOF
|
||||
This hook allows you to use ZFS as your root filesystem.
|
||||
|
||||
Command Line Setup:
|
||||
|
||||
You can append the following arguments to your kernel parameters list. See
|
||||
https://wiki.archlinux.org/index.php/Kernel_parameters for more information.
|
||||
|
||||
To use ZFS as your boot filesystem:
|
||||
|
||||
zfs=bootfs or zfs=auto or root=zfs
|
||||
|
||||
To use a pool or dataset:
|
||||
|
||||
zfs=<pool/dataset>
|
||||
|
||||
To force importing of a ZFS pool:
|
||||
|
||||
zfs_force=1
|
||||
|
||||
If set to 1, this will use "zpool import -f" when attempting to import
|
||||
pools.
|
||||
|
||||
To change the seconds of time to wait for ZFS devices to show up at boot:
|
||||
|
||||
zfs_wait=30
|
||||
|
||||
To search for devices in a directory other than "/dev":
|
||||
|
||||
zfs_import_dir=/dev/disk/by-uuid
|
||||
or
|
||||
zfs_import_dir=/dev/disk/by-partuuid
|
||||
or
|
||||
zfs_import_dir=/dev/disk/by-path
|
||||
etc.
|
||||
|
||||
Following initcpio convention, the 'rw' option must be specified to load the
|
||||
pool as read/write. Pools are loaded as read only by default.
|
||||
|
||||
Examples:
|
||||
|
||||
To use bootfs on your pool, use
|
||||
|
||||
zfs=bootfs rw
|
||||
|
||||
This will setup your root using tank/root zfs pool.
|
||||
|
||||
zfs=tank/root rw
|
||||
|
||||
If you want to set properties for zfs-on-linux module, you should add them to
|
||||
/etc/modprobe.d/zfs.conf and then rebuild initcpio.
|
||||
|
||||
HELPEOF
|
||||
}
|
||||
|
||||
# vim: set ts=4 sw=4 ft=sh et:
|
||||
@@ -3,69 +3,91 @@
|
||||
<PISI>
|
||||
<Source>
|
||||
<Name>mkinitcpio</Name>
|
||||
<Homepage>https://projects.archlinux.org/mkinitcpio.git/</Homepage>
|
||||
<Homepage>https://github.com/archlinux/mkinitcpio</Homepage>
|
||||
<Packager>
|
||||
<Name>Pisi Linux Admins</Name>
|
||||
<Email>admin@pisilinux.org</Email>
|
||||
</Packager>
|
||||
<License>GPL</License>
|
||||
<License>GPLv2</License>
|
||||
<Summary>Modular initramfs image creation utility</Summary>
|
||||
<Description>mkinitcpio is a generic, modular, cross-distribution initramfs generation tool.</Description>
|
||||
<Archive sha1sum="678efaad52901aeb66f84e99f2ea86b24d2eea22" type="targz">https://github.com/bferturk/mkinitcpio/archive/19.1.tar.gz</Archive>
|
||||
<Archive sha1sum="a1c8794c29b1da0811b5038dbcdb4a0b5d1e05cd" type="targz">https://github.com/archlinux/mkinitcpio/archive/refs/tags/v30.tar.gz</Archive>
|
||||
<BuildDependencies>
|
||||
<Dependency>libkmod-devel</Dependency>
|
||||
<Dependency>kmod</Dependency>
|
||||
<Dependency>asciidoc</Dependency>
|
||||
<Dependency>libxslt-devel</Dependency>
|
||||
<Dependency>man-pages</Dependency>
|
||||
<Dependency>man-db</Dependency>
|
||||
</BuildDependencies>
|
||||
<Patches>
|
||||
<Patch level="1">nosystemd.patch</Patch>
|
||||
<Patch level="1">gzip-default.patch</Patch>
|
||||
</Patches>
|
||||
</Source>
|
||||
|
||||
|
||||
<Package>
|
||||
<Name>mkinitcpio</Name>
|
||||
<RuntimeDependencies>
|
||||
<Dependency>xz</Dependency>
|
||||
<Dependency>bzip2</Dependency>
|
||||
<Dependency>libarchive</Dependency>
|
||||
<Dependency>kmod</Dependency>
|
||||
<Dependency>libkmod</Dependency>
|
||||
<Dependency>busybox-mkinitcpio</Dependency>
|
||||
</RuntimeDependencies>
|
||||
<!--Replaces>
|
||||
<Package>mkinitramfs</Package>
|
||||
</Replaces-->
|
||||
<Conflicts>
|
||||
<Package>mkinitramfs</Package>
|
||||
</Conflicts>
|
||||
<Package>mkinitramfs</Package>
|
||||
<Package>initrd</Package>
|
||||
</Conflicts>
|
||||
<Files>
|
||||
<Path fileType="data">/etc/initcpio</Path>
|
||||
<Path fileType="config">/etc/mkinitcpio.conf</Path>
|
||||
<Path fileType="config">/etc/mkinitcpio.d</Path>
|
||||
<Path fileType="executable">/usr/bin</Path>
|
||||
<Path fileType="library">/usr/lib</Path>
|
||||
<Path fileType="data">/usr/share</Path>
|
||||
<Path fileType="library">/usr/lib/initcpio</Path>
|
||||
<Path fileType="data">/usr/share/bash-completion</Path>
|
||||
<Path fileType="doc">/usr/share/doc</Path>
|
||||
<Path fileType="data">/etc</Path>
|
||||
<Path fileType="man">/usr/share/man</Path>
|
||||
<Path fileType="data">/usr/share/mkinitcpio</Path>
|
||||
<Path fileType="data">/usr/share/zsh</Path>
|
||||
</Files>
|
||||
<AdditionalFiles>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/hooks/udev">udev_hook</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/install/udev">udev_install</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/hooks/lvm2">lvm2_hook</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/install/lvm2">lvm2_install</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/hooks/encrypt">encrypt_hook</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/install/encrypt">encrypt_install</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/hooks/mdadm">mdadm_hook</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/install/mdadm">mdadm_install</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/install/mdadm_udev">mdadm_udev_install</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/hooks/zfs">zfs_hook</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/install/zfs">zfs_install</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/hooks/live">live_hook</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/install/live">live_install</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/udev/10-dm-initramfs.rules">10-dm-initramfs.rules</AdditionalFile>
|
||||
<AdditionalFile owner="root" permission="0644" target="/usr/lib/initcpio/udev/70-dm-lvm-metad.rules">70-dm-lvm-metad.rules</AdditionalFile>
|
||||
</AdditionalFiles>
|
||||
<Provides>
|
||||
<COMAR script="pakhandler.py">System.PackageHandler</COMAR>
|
||||
</Provides>
|
||||
</Package>
|
||||
|
||||
|
||||
<History>
|
||||
<Update release="9">
|
||||
<Update release="10">
|
||||
<Date>2021-09-13</Date>
|
||||
<Version>30</Version>
|
||||
<Comment>Version bump</Comment>
|
||||
<Name>Berk Çakar</Name>
|
||||
<Email>berk2238@hotmail.com</Email>
|
||||
</Update>
|
||||
<Update release="9">
|
||||
<Date>2021-06-09</Date>
|
||||
<Version>19.1</Version>
|
||||
<Comment>Rebuild</Comment>
|
||||
<Name>Mustafa Cinasal</Name>
|
||||
<Email>muscnslp@gmail.com</Email>
|
||||
</Update>
|
||||
<Update release="8">
|
||||
<Update release="8">
|
||||
<Date>2020-12-26</Date>
|
||||
<Version>19.1</Version>
|
||||
<Comment>Rebuild</Comment>
|
||||
<Name>Mustafa Cinasal</Name>
|
||||
<Email>muscnslp@gmail.com</Email>
|
||||
</Update>
|
||||
<Update release="7">
|
||||
<Update release="7">
|
||||
<Date>2019-12-27</Date>
|
||||
<Version>19.1</Version>
|
||||
<Comment>Rebuild</Comment>
|
||||
|
||||
@@ -21,4 +21,4 @@ def cleanupPackage(metapath, filepath):
|
||||
pass
|
||||
|
||||
def postCleanupPackage(metapath, filepath):
|
||||
generate_initramfs(filepath)
|
||||
pass
|
||||
|
||||
@@ -48,6 +48,13 @@
|
||||
</Package>
|
||||
|
||||
<History>
|
||||
<Update release="9">
|
||||
<Date>2020-09-11</Date>
|
||||
<Version>1.0.7</Version>
|
||||
<Comment>Rebuild</Comment>
|
||||
<Name>Berk Çakar</Name>
|
||||
<Email>berk2238@hotmail.com</Email>
|
||||
</Update>
|
||||
<Update release="8">
|
||||
<Date>2020-01-18</Date>
|
||||
<Version>1.0.7</Version>
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
|
||||
from pisi.actionsapi import autotools
|
||||
from pisi.actionsapi import pisitools
|
||||
from pisi.actionsapi import shelltools
|
||||
|
||||
def build():
|
||||
shelltools.export("KCONFIG_NOTIMESTAMP", "1")
|
||||
autotools.make()
|
||||
|
||||
|
||||
def install():
|
||||
pisitools.insinto("/usr/lib/initcpio", "busybox")
|
||||
|
||||
@@ -49,7 +49,7 @@ CONFIG_PIE=y
|
||||
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
|
||||
CONFIG_CROSS_COMPILER_PREFIX=""
|
||||
CONFIG_SYSROOT=""
|
||||
CONFIG_EXTRA_CFLAGS=""
|
||||
CONFIG_EXTRA_CFLAGS="-march=x86-64 -mtune=generic -Os -pipe -fno-strict-aliasing"
|
||||
CONFIG_EXTRA_LDFLAGS=""
|
||||
CONFIG_EXTRA_LDLIBS=""
|
||||
# CONFIG_USE_PORTABLE_CODE is not set
|
||||
|
||||
@@ -18,19 +18,30 @@
|
||||
<AdditionalFile target=".config">config</AdditionalFile>
|
||||
</AdditionalFiles>
|
||||
<Patches>
|
||||
<!-- <Patch level="1">fix-include.patch</Patch> -->
|
||||
<!--Patch level="1">fix-include.patch</Patch-->
|
||||
</Patches>
|
||||
</Source>
|
||||
|
||||
<Package>
|
||||
<Name>busybox-mkinitcpio</Name>
|
||||
<RuntimeDependencies>
|
||||
<Dependency>glibc</Dependency>
|
||||
<Dependency>libxcrypt</Dependency>
|
||||
</RuntimeDependencies>
|
||||
<Files>
|
||||
<Path fileType="executable">/usr/lib/initcpio/busybox</Path>
|
||||
</Files>
|
||||
</Package>
|
||||
|
||||
<History>
|
||||
<Update release="8">
|
||||
<Update release="9">
|
||||
<Date>2021-09-13</Date>
|
||||
<Version>1.33.0</Version>
|
||||
<Comment>Rebuild.</Comment>
|
||||
<Name>Berk Çakar</Name>
|
||||
<Email>berk2238@hotmail.com</Email>
|
||||
</Update>
|
||||
<Update release="8">
|
||||
<Date>2021-06-09</Date>
|
||||
<Version>1.33.0</Version>
|
||||
<Comment>Rebuild.</Comment>
|
||||
|
||||
Reference in New Issue
Block a user