diff --git a/90metalmdsquash/metal-lib.sh b/90metalmdsquash/metal-lib.sh index e759e7e..56bd031 100644 --- a/90metalmdsquash/metal-lib.sh +++ b/90metalmdsquash/metal-lib.sh @@ -69,6 +69,13 @@ fi } _load_dracut_dep +############################################################################## +# constant: METAL_DONE_FILE_PAVED +# +# Log directory. +export METAL_LOG_DIR='/var/log/metal' +mkdir -p $METAL_LOG_DIR + ############################################################################## # constant: METAL_DONE_FILE_PAVED # @@ -79,12 +86,21 @@ _load_dracut_dep export METAL_DONE_FILE_PAVED='/tmp/metalpave.done' ############################################################################## -# constant: metal_transports +# constant: metal_subsystems # -# PIPE-DELIMITED-LIST of Transports to acknowledge from `lsblk` queries; these transports are -# exclusively cleaned and partitioned, all others on the node are left alone. +# PIPE-DELIMITED-LIST of SUBSYSTEMS to acknowledge from `lsblk` queries; anything listed here is in +# the cross-hairs for wiping and formatting. +# NOTE: To find values for this, run `lsblk -b -l -d -o SIZE,NAME,TYPE,SUBSYSTEMS` # MAINTAINER NOTE: DO NOT ADD USB or ANY REMOVABLE MEDIA TRANSPORT in order to mitigate accidents. -export metal_transports="sata|nvme|sas" +export metal_subsystems='scsi|nvme' + +############################################################################## +# constant: metal_subsystems_ignore +# +# PIPE-DELIMITED-LIST of Transports to acknowledge from `lsblk` queries; these subsystems are +# excluded from any operations performed by this dracut module. +# NOTE: To find values for this, run `lsblk -b -l -d -o SIZE,NAME,TYPE,SUBSYSTEMS` +export metal_subsystems_ignore='usb' ############################################################################## # costant: metal_fstab @@ -103,7 +119,7 @@ export metal_fsopts_xfs=noatime,largeio,inode64,swalloc,allocsize=131072k # # Define the size that is considered to fit the "small" disk form factor. These # usually serve critical functions. -export metal_disk_small=524288000000 +export metal_disk_small=375809638400 ############################################################################## # constant: metal_disk_large @@ -175,68 +191,58 @@ metal_die() { fi } - ############################################################################## -# function: metal_resolve_disk +# function: metal_scand # -# Function returns a space delemited list of tuples, each tuple contains the -# size (in bytes) of a disk, and the disk handle itself. This output is -# compatible with metal_resolve_disk. +# Returns a sorted, space delimited list of disks. Each element in the list is +# a tuple representing a disk; the size of the disk (in bytes), and +# device-mapper name. # # usage: # -# Return disks except, ignoring the first two used by the OS: -# -# metal_scand $((metal_disks + 1)) -# -# Return the OS disks: +# metal_scand # -# md_disks=();for disk in seq 1 $metal_disks; do md_disk=$(metal_scand $disk | cut -d ' ' -f1) ; echo $md_disk; md_disks+=( $md_disk ); done; echo ${md_disks[@]} +# output: +# +# 10737418240,sdd 549755813888,sda 549755813888,sdb 1099511627776,sdc # metal_scand() { - local disk_offset=${1:-$metal_disks} - local disks - disks="$(lsblk -b -l -d -o SIZE,NAME,TYPE,TRAN |\ - grep -E '('"$metal_transports"')' |\ + echo -n "$(lsblk -b -l -d -o SIZE,NAME,TYPE,SUBSYSTEMS |\ + grep -E '('"$metal_subsystems"')' |\ + grep -v -E '('"$metal_subsystems_ignore"')' |\ sort -h |\ grep -vE 'p[0-9]+$' |\ - awk '{print $1 "," $2}' |\ - tail -n +${disk_offset} |\ + awk '{print ($1 > '$metal_ignore_threshold') ? $1 "," $2 : ""}' |\ tr '\n' ' ' |\ sed 's/ *$//')" - echo $disks } ############################################################################## # function: metal_resolve_disk # -# Sorts a list of disks, returning the first disk that's larger than the -# given constraint. -# -# The output of this lsblk command is ideal for this function: +# Given a disk tuple from metal_scand and a minimum size, print the disk if it's +# larger than the given size otherwise print nothing. +# Also verified whether the disk has children or not, if it does then it's not +# eligible. Since all disks are wiped to start with, if a disk has children when +# this function would be called then it's already spoken for. # -# lsblk -b -l -o SIZE,NAME,TYPE,TRAN | grep -E '(sata|nvme|sas)' | sort -h | awk '{print $1 "," $2}' +# This is useful for iterating through a list of devices and ignoring ones that +# are insufficient. # # usage: # -# metal_resolve_disk "size,name [size,name]" floor/minimum_size +# metal_resolve_disk size,name floor/minimum_size # -# example(s): -# -# metal_resolve_disk "480103981056,sdc 1920383410176,sdb" 1048576000000 metal_resolve_disk() { - local disks=$1 + local disk=$1 local minimum_size=$(echo $2 | sed 's/,.*//') - local found=0 - for disk in $disks; do - name="$(echo $disk | sed 's/,/ /g' | awk '{print $2}')" - size="$(echo $disk | sed 's/,/ /g' | awk '{print $1}')" - if [ "${size}" -gt $minimum_size ]; then - found=1 - fi - done - printf $name - [ $found = 1 ] && return 0 || return 1 + name="$(echo $disk | sed 's/,/ /g' | awk '{print $2}')" + size="$(echo $disk | sed 's/,/ /g' | awk '{print $1}')" + if ! lsblk --fs --json "/dev/${name}" | grep -q children ; then + if [ "${size}" -gt "${minimum_size}" ]; then + echo -n "$name" + fi + fi } ############################################################################## @@ -257,12 +263,10 @@ metal_paved() { case "$rc" in 1) # 1 indicates the pave function ran and the disks were wiped. - echo >&2 'Disks have been wiped.' return 0 ;; 0) # 0 indicates the pave function was cleanly bypassed. - echo >&2 'Wipe was skipped.' return 0 ;; *) diff --git a/90metalmdsquash/metal-log.sh b/90metalmdsquash/metal-log.sh new file mode 100755 index 0000000..c757bb8 --- /dev/null +++ b/90metalmdsquash/metal-log.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# MIT License +# +# (C) Copyright 2023 Hewlett Packard Enterprise Development LP +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# metal-log.sh +[ "${metal_debug:-0}" = 0 ] || set -x + +command -v disks_exist > /dev/null 2>&1 || . /lib/metal-lib.sh + +mkdir -p "/sysroot${METAL_LOG_DIR}/bootstrap" +cp -p "${METAL_LOG_DIR}/"* "/sysroot${METAL_LOG_DIR}/bootstrap/" 2>/dev/null diff --git a/90metalmdsquash/metal-md-disks.sh b/90metalmdsquash/metal-md-disks.sh index b951890..86386a2 100755 --- a/90metalmdsquash/metal-md-disks.sh +++ b/90metalmdsquash/metal-md-disks.sh @@ -47,14 +47,22 @@ pave # At this point this module is required; a disk must be created or the system has nothing to boot. # Die if no viable disks are found; otherwise continue to disk creation functions. -if [ ! -f /tmp/metalsqfsdisk.done ]; then +if [ ! -f /tmp/metalsqfsdisk.done ] && [ "${metal_nowipe}" -eq 0 ]; then md_disks=() - for disk in $(seq 1 $metal_disks); do - md_disk=$(metal_resolve_disk $(metal_scand $disk) $metal_disk_small) - md_disks+=( $md_disk ) + disks="$(metal_scand)" + IFS=" " read -r -a pool <<< "$disks" + for disk in "${pool[@]}"; do + if [ "${#md_disks[@]}" -eq "${metal_disks}" ]; then + break + fi + md_disk=$(metal_resolve_disk "$disk" "$metal_disk_small") + if [ -n "${md_disk}" ]; then + md_disks+=("$md_disk") + fi done - if [ ${#md_disks[@]} = 0 ]; then - metal_die "No disks were found for the OS that were [$metal_disk_small] (in bytes) or smaller!" + + if [ "${#md_disks[@]}" -lt "$metal_disks" ]; then + metal_die "No disks were found for the OS that were [$metal_disk_small] (in bytes) or larger, all were too small or had filesystems present!" exit 1 else echo >&2 "Found the following disks for the main RAID array (qty. [$metal_disks]): [${md_disks[*]}]" @@ -62,7 +70,8 @@ if [ ! -f /tmp/metalsqfsdisk.done ]; then fi # Create disks. -[ ! -f /tmp/metalsqfsdisk.done ] && make_raid_store +[ ! -f /tmp/metalsqfsdisk.done ] && make_raid_store "${md_disks[@]}" +[ ! -f /tmp/metalovaldisk.done ] && make_raid_overlay "${md_disks[@]}" [ ! -f /tmp/metalovalimg.done ] && add_overlayfs [ ! -f /tmp/metalsqfsimg.done ] && add_sqfs diff --git a/90metalmdsquash/metal-md-lib.sh b/90metalmdsquash/metal-md-lib.sh index fc1a32a..eb17633 100755 --- a/90metalmdsquash/metal-md-lib.sh +++ b/90metalmdsquash/metal-md-lib.sh @@ -27,24 +27,21 @@ command -v getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh command -v metal_die > /dev/null 2>&1 || . /lib/metal-lib.sh -# Honor and obey dmsquash parameters, if a user sets a different rd.live.dir on the cmdline then it -# should be reflected here as well. - # these use getargnum from /lib/dracut-lib.sh; metal_sqfs_size_end=$(getargnum 25 25 100 metal.sqfs-md-size) overlay_size_end=$(getargnum 150 25 200 metal.oval-md-size) -auxillary_size_end=$(getargnum 150 0 200 metal.aux-md-size) +aux_size_end=$(getargnum 150 0 200 metal.aux-md-size) # The time (in seconds) for delaying the wipe once the wipe has been invoked. metal_wipe_delay=$(getargnum 5 2 60 metal.wipe-delay) # this is passed to mdadm during creation; default is redundant mirrors -metal_mdlevel=$(getarg metal.md-level=) -[ -z "${metal_mdlevel}" ] && metal_mdlevel=mirror +metal_md_level=$(getarg metal.md-level=) +[ -z "${metal_md_level}" ] && metal_md_level=mirror # Handle single-disk situations. mdadm_raid_devices="--raid-devices=$metal_disks" -[ $metal_disks = 1 ] && mdadm_raid_devices="$mdadm_raid_devices --force" +[ "$metal_disks" -eq 1 ] && mdadm_raid_devices="$mdadm_raid_devices --force" # directory to download new artifacts to, and look for old artifacts in. live_dir=$(getarg rd.live.dir -d live_dir) @@ -85,29 +82,6 @@ case $boot_drive_scheme in ;; esac -# root must never be empty; if it is then nothing will boot - dracut will never find anything todo. -root=$(getarg root) -case "$root" in - live:/dev/*) - sqfs_drive_url=${root///dev\/disk\/by-} - sqfs_drive_spec=${sqfs_drive_url#*:} - export sqfs_drive_scheme=${sqfs_drive_spec%%/*} - export sqfs_drive_authority=${sqfs_drive_spec#*/} - ;; - live:*) - sqfs_drive_url=${root#live:} - sqfs_drive_spec=${sqfs_drive_url#*:} - export sqfs_drive_scheme=${sqfs_drive_spec%%=*} - export sqfs_drive_authority=${sqfs_drive_spec#*=} - ;; - '') - warn "No root; root needed - the system will likely fail to boot." - # do not fail, allow dracut to handle everything in case an operator/admin is doing something. - ;; - *) - warn "alien root! unrecognized root= parameter: root=${root}" - ;; -esac # support CDLABEL by overriding it to LABEL, CDLABEL only means anything in other dracut modules # and those modules will parse it out of root= (not our variable) - normalize it in our context. [ "${sqfs_drive_scheme}" = 'CDLABEL' ] || sqfs_drive_scheme=LABEL @@ -153,31 +127,37 @@ make_raid_store() { echo 0 > /tmp/metalsqfsdisk.done && return fi + local disks + IFS=" " read -r -a disks <<< "$@" + + if [ "${#disks[@]}" -lt "${metal_disks}" ]; then + metal_die "${FUNCNAME[0]} was called with ${#disks[@]} disks but it requires [$metal_disks]! Can not continue." + fi + # Loop through our disks and make our partitions needed for a squashFS storage: # - BOOTRAID : For fallback booting. # - SQFSRAID : For stowing squashFS images. - local boot_raid_parts='' - local sqfs_raid_parts='' - for disk in "${md_disks[@]}"; do + local boot_raid_parts=() + local sqfs_raid_parts=() + for disk in "${disks[@]}"; do parted --wipesignatures -m --align=opt --ignore-busy -s "/dev/$disk" -- mklabel gpt \ mkpart esp fat32 2048s 500MB set 1 esp on \ mkpart primary xfs 500MB "${metal_sqfs_size_end}GB" _trip_udev - # NVME partitions have a "p" to delimit the partition number. + # NVME partitions have a "p" to delimit the partition number, add this in order to reference properly in the RAID creation. if [[ "$disk" =~ "nvme" ]]; then disk="${disk}p" fi - boot_raid_parts="$(trim $boot_raid_parts) /dev/${disk}1" - sqfs_raid_parts="$(trim $sqfs_raid_parts) /dev/${disk}2" + boot_raid_parts+=( "/dev/${disk}1" ) + sqfs_raid_parts+=( "/dev/${disk}2" ) done # metadata=0.9 for boot files. - mdadm --create /dev/md/BOOT --run --verbose --assume-clean --metadata=0.9 --level="$metal_mdlevel" $mdadm_raid_devices ${boot_raid_parts} || metal_die -b "Failed to make filesystem on /dev/md/BOOT" - - mdadm --create /dev/md/SQFS --run --verbose --assume-clean --metadata=1.2 --level="$metal_mdlevel" $mdadm_raid_devices ${sqfs_raid_parts} || metal_die -b "Failed to make filesystem on /dev/md/SQFS" + mdadm --create /dev/md/BOOT --run --verbose --assume-clean --metadata=0.9 --level="$metal_md_level" "$mdadm_raid_devices" "${boot_raid_parts[@]}" || metal_die -b "Failed to make filesystem on /dev/md/BOOT" + mdadm --create /dev/md/SQFS --run --verbose --assume-clean --metadata=1.2 --level="$metal_md_level" "$mdadm_raid_devices" "${sqfs_raid_parts[@]}" || metal_die -b "Failed to make filesystem on /dev/md/SQFS" _trip_udev mkfs.vfat -F32 -n "${boot_drive_authority}" /dev/md/BOOT || metal_die 'Failed to format bootraid.' @@ -199,25 +179,32 @@ make_raid_overlay() { echo 0 > /tmp/metalovaldisk.done && return fi - local oval_raid_parts='' - local aux_raid_parts='' + local disks + IFS=" " read -r -a disks <<< "$@" + + if [ "${#disks[@]}" -lt "${metal_disks}" ]; then + metal_die "${FUNCNAME[0]} was called with ${#disks[@]} disks but it requires [$metal_disks]! Can not continue." + fi + + local oval_raid_parts=() + local aux_raid_parts=() local oval_end="$((overlay_size_end + metal_sqfs_size_end))" - local aux_end="$((auxillary_size_end + oval_end))" - for disk in "${md_disks[@]}"; do + local aux_end="$((aux_size_end + oval_end))" + for disk in "${disks[@]}"; do parted --wipesignatures --align=opt -m --ignore-busy -s "/dev/$disk" mkpart primary xfs "${metal_sqfs_size_end}GB" "${oval_end}GB" parted --wipesignatures --align=opt -m --ignore-busy -s "/dev/$disk" mkpart primary "${oval_end}GB" "${aux_end}GB" - # NVME partitions have a "p" to delimit the partition number. + # NVME partitions have a "p" to delimit the partition number, add this in order to reference properly in the RAID creation. if [[ "$disk" =~ "nvme" ]]; then disk="${disk}p" fi - oval_raid_parts="$(trim $oval_raid_parts) /dev/${disk}3" - aux_raid_parts="$(trim $aux_raid_parts) /dev/${disk}4" + oval_raid_parts+=( "/dev/${disk}3" ) + aux_raid_parts+=( "/dev/${disk}4" ) done - mdadm --create /dev/md/ROOT --assume-clean --run --verbose --metadata=1.2 --level="$metal_mdlevel" $mdadm_raid_devices ${oval_raid_parts} || metal_die -b "Failed to make filesystem on /dev/md/ROOT" - mdadm --create /dev/md/AUX --assume-clean --run --verbose --metadata=1.2 --level='stripe' $mdadm_raid_devices ${aux_raid_parts} || metal_die -b "Failed to make filesystem on /dev/md/AUX" + mdadm --create /dev/md/ROOT --assume-clean --run --verbose --metadata=1.2 --level="$metal_md_level" "$mdadm_raid_devices" "${oval_raid_parts[@]}" || metal_die -b "Failed to make filesystem on /dev/md/ROOT" + mdadm --create /dev/md/AUX --assume-clean --run --verbose --metadata=1.2 --level='stripe' "$mdadm_raid_devices" "${aux_raid_parts[@]}" || metal_die -b "Failed to make filesystem on /dev/md/AUX" _trip_udev mkfs.xfs -f -L "${oval_drive_authority}" /dev/md/ROOT || metal_die 'Failed to format overlayFS storage.' @@ -229,7 +216,6 @@ make_raid_overlay() { # Make our dmsquash-live-root overlayFS. add_overlayfs() { [ -f /tmp/metalovalimg.done ] && return - [ -f /tmp/metalovaldisk.done ] || make_raid_overlay local mpoint=/metal/ovaldisk mkdir -pv ${mpoint} if ! mount -v -n -t xfs /dev/md/ROOT "$mpoint"; then @@ -250,7 +236,7 @@ add_overlayfs() { umount -v ${mpoint} } -############################################```################################## +############################################################################### ## SquashFS # Gets the squashFS file from a URL endpoint or a local endpoint. fetch_sqfs() { @@ -350,24 +336,31 @@ add_sqfs() { # MAINTAINER NOTE DO NOT VOID THE AFOREMENTIONED STATEMENT! # (these are the busses this scans for from `lsblk`). pave() { - local log="$METAL_DONE_FILE_PAVED.log" - echo '${FUNCNAME[0]} called' >$log + local log="${METAL_LOG_DIR}/${FUNCNAME[0]}.log" + local doomed_disks + local doomed_raids + local doomed_volume_groups=( 'vg_name=~ceph*' 'vg_name=~metal*' ) + local vgfailure + echo "${FUNCNAME[0]} called" >>"$log" # If the done file already exists, do not modify it and do not touch anything. # Return 0 because the work was already done and we don't want to layer more runs of this atop # the original run. if [ -f "$METAL_DONE_FILE_PAVED" ]; then - echo "${FUNCNAME[0]} already done" >>$log - echo "wipe done file already exists ("$METAL_DONE_FILE_PAVED"); not wiping disks" + echo "${FUNCNAME[0]} already done" >>"$log" + echo "wipe done file already exists ($METAL_DONE_FILE_PAVED); not wiping disks" return 0 fi - mount -v >>$log 2>&1 - lsblk >>$log 2>&1 - ls -l /dev/md* >>$log 2>&1 - ls -l /dev/sd* >>$log 2>&1 - ls -l /dev/nvme* >>$log 2>&1 - cat /proc/mdstat >>$log 2>&1 - if [ "$metal_nowipe" != 0 ]; then + { + mount -v + lsblk + ls -l /dev/md* + ls -l /dev/sd* + ls -l /dev/nvme* + cat /proc/mdstat + } >>"$log" 2>&1 + + if [ "$metal_nowipe" -ne 0 ]; then echo "${FUNCNAME[0]} skipped: metal.no-wipe=${metal_nowipe}" >>$log warn 'local storage device wipe [ safeguard: ENABLED ]' warn 'local storage devices will not be wiped.' @@ -377,14 +370,6 @@ pave() { fi warn 'local storage device wipe commencing (USB devices are ignored) ...' - local doomed_disks - local doomed_ceph_vgs='vg_name=~ceph*' - local doomed_metal_vgs='vg_name=~metal*' - local vgfailure - - # Select the span of devices we care about; RAID, and all compatible transports. - doomed_disks="$(lsblk -l -o SIZE,NAME,TYPE,TRAN | grep -E '(raid|'"$metal_transports"')' | sort -u | awk '{print "/dev/"$2}' | tr '\n' ' ' | sed 's/ *$//')" - warn 'nothing can be done to stop this except one one thing ...' warn "... power this node off within the next [$metal_wipe_delay] seconds to prevent any and all operations ..." while [ "${metal_wipe_delay}" -ge 0 ]; do @@ -392,47 +377,74 @@ pave() { sleep 1 && local metal_wipe_delay=$((${metal_wipe_delay} - 1)) && echo "${metal_wipe_delay} $unit" done - # - # NUKES: these go in order from logical (e.g. LVM) -> block (e.g. block devices from lsblk) -> physical (e.g. RAID and other controller tertiary to their members). - # - - # NUKE LVMs + # 1. NUKE LVMs + # Update/scan for any vgs and then erase all of them. None should be mounted let alone even active at this point because we're in the initramFS. vgscan >&2 && vgs >&2 vgfailure=0 - for volume_group in $doomed_ceph_vgs $doomed_metal_vgs; do - warn "removing all volume groups of name [${volume_group}]" && vgremove -f --select ${volume_group} -y >&2 || warn "no ${volume_group} volumes found" - if [ "$(vgs --select $volume_group)" != '' ]; then + for volume_group in "${doomed_volume_groups[@]}"; do + warn "removing all volume groups of name [${volume_group}]" + vgremove -f --select "${volume_group}" -y >&2 || warn "no ${volume_group} volumes found" + if [ "$(vgs --select "$volume_group")" != '' ]; then warn "${volume_group} still exists, this is unexpected. Printing vgs table:" - vgs >&2 vgfailure=1 + vgs >&2 fi done if [ ${vgfailure} -ne 0 ]; then warn 'Failed to remove all volume groups! Try rebooting this node again.' - warn "If this persists, try running the manual wipe in the emergency shell and reboot again." - warn "After trying the manual wipe, run 'echo b >/proc/sysrq-trigger' to reboot" - metal_die "https://github.com/Cray-HPE/docs-csm/blob/main/operations/node_management/Wipe_NCN_Disks.md#basic-wipe" + warn 'If this persists, try running the manual wipe in the emergency shell and reboot again.' + warn 'After trying the manual wipe, run 'echo b >/proc/sysrq-trigger' to reboot' + metal_die 'https://github.com/Cray-HPE/docs-csm/blob/main/operations/node_management/Wipe_NCN_Disks.md#basic-wipe' fi - # NUKE BLOCKs - warn "local storage device wipe targeted devices: [$doomed_disks]" + # 2. NUKE RAIDs + # Use mdraid-cleanup, and then for good measure run wipefs against the raid to erase any signatures left behind. + doomed_raids="$(lsblk -l -o NAME,TYPE | grep raid | sort -u | awk '{print "/dev/"$1}' | tr '\n' ' ' | sed 's/ *$//')" + warn "local storage device wipe is targeting the following RAID(s): [$doomed_raids]" + for doomed_raid in $doomed_raids; do + wipefs --all --force "$doomed_raid" >>"$log" 2>&1 + done + + # 3. NUKE BLOCKs + # Wipe each selected disk and its partitions. + doomed_disks="$(lsblk -b -d -l -o NAME,SUBSYSTEMS,SIZE | grep -E '('"$metal_subsystems"')' | grep -v -E '('"$metal_subsystems_ignore"')' | sort -u | awk '{print ($3 > '$metal_ignore_threshold') ? "/dev/"$1 : ""}' | tr '\n' ' ' | sed 's/ *$//')" + warn "local storage device wipe is targeting the following block devices: [$doomed_disks]" for doomed_disk in $doomed_disks; do - wipefs --all --force $doomed_disk* 2> /dev/null + wipefs --all --force "$doomed_disk"* done - # NUKE RAIDs - mdraid-cleanup >/dev/null 2>&1 # this is very noisy and useless to see but this call is needed. + # 4. Cleanup mdadm + # Now that the signatures and volume groups are wiped/gone, mdraid-cleanup can mop up and left + # over /dev/md handles. + { + lsblk + mdraid-cleanup + lsblk + } >>"$log" 2>&1 + + # 5. Notify the kernel of the partition changes + # NOTE: This could be done in the same loop that we wipe devices, however mileage has varied. + # Running this as a standalone step has had better results. + for doomed_disk in $doomed_disks; do + { + lsblk "$doomed_disk" + partprobe "$doomed_disk" + lsblk "$doomed_disk" + } >>"$log" 2>&1 + done _trip_udev warn 'local storage disk wipe complete' && echo 1 > "$METAL_DONE_FILE_PAVED" - echo "${FUNCNAME[0]} done" >>$log - mount -v >>$log 2>&1 - lsblk >>$log 2>&1 - ls -l /dev/md* >>$log 2>&1 - ls -l /dev/sd* >>$log 2>&1 - ls -l /dev/nvme* >>$log 2>&1 - cat /proc/mdstat >>$log 2>&1 + { + mount -v + lsblk + ls -l /dev/md* + ls -l /dev/sd* + ls -l /dev/nvme* + cat /proc/mdstat + echo "${FUNCNAME[0]} done" >>$log + } >>"$log" 2>&1 } ############################################################################## @@ -440,7 +452,12 @@ pave() { # Conclude and exit the dracut init loop. # Provide the expected devices to dmsquash-live metal_md_exit() { - [ ! -b /dev/md/SQFS ] && return 1 - xfs_admin -L "${sqfs_drive_authority}" /dev/md/SQFS - ln -s null /dev/metal + local log="${METAL_LOG_DIR}/${FUNCNAME[0]}.log" + { + [ ! -b /dev/md/SQFS ] && return 1 + xfs_admin -L "${sqfs_drive_authority}" /dev/md/SQFS + mdraid_start + _trip_udev + ln -sf null /dev/metal + } >>"$log" 2>&1 } diff --git a/90metalmdsquash/module-setup.sh b/90metalmdsquash/module-setup.sh index d8b5658..c29ed77 100755 --- a/90metalmdsquash/module-setup.sh +++ b/90metalmdsquash/module-setup.sh @@ -25,7 +25,7 @@ # called by dracut cmd check() { - require_binaries mdadm xfs_admin || return 1 + require_binaries blkid cut curl efibootmgr head lsblk mdadm mkfs.ext4 mkfs.vfat mkfs.xfs mount parted partprobe sort tail vgs vgscan xfs_admin || return 1 return 0 } @@ -44,7 +44,7 @@ installkernel() { # called by dracut install() { - inst_multiple cut curl diff efibootmgr head lsblk mkfs.ext4 mkfs.vfat mkfs.xfs parted seq sort tail wc vgs vgscan xfs_admin + inst_multiple blkid cut curl diff efibootmgr head lsblk mkfs.ext4 mkfs.vfat mkfs.xfs mount parted partprobe sort tail wc vgs vgscan xfs_admin # install our callables inst_simple "$moddir/mdadm.conf" "/etc/mdadm.conf" inst_simple "$moddir/metal-md-lib.sh" "/lib/metal-md-lib.sh" @@ -60,6 +60,7 @@ install() { inst_hook pre-mount 10 "$moddir/metal-kdump.sh" inst_hook pre-pivot 10 "$moddir/metal-update-fstab.sh" inst_hook pre-pivot 11 "$moddir/metal-udev.sh" + inst_hook pre-pivot 12 "$moddir/metal-log.sh" # dracut needs to know we must have the initqueue, we have no initqueue hooks to inherit the call. dracut_need_initqueue diff --git a/90metalmdsquash/parse-metal.sh b/90metalmdsquash/parse-metal.sh index 9c7dd32..48f3031 100755 --- a/90metalmdsquash/parse-metal.sh +++ b/90metalmdsquash/parse-metal.sh @@ -44,3 +44,38 @@ export metal_nowipe export metal_overlay export metal_server export metal_ipv4 + +metal_minimum_disk_size=$(getargnum 16 0 1000000000 metal.min-disk-size) +# convert Gigabytes to bytes +metal_ignore_threshold=$((metal_minimum_disk_size*1024**3)) +export metal_ignore_threshold + +# root must never be empty; if it is then nothing will boot - dracut will never find anything todo. +root=$(getarg root) +case "$root" in + live:/dev/*) + sqfs_drive_url=${root///dev\/disk\/by-} + sqfs_drive_spec=${sqfs_drive_url#*:} + sqfs_drive_scheme=${sqfs_drive_spec%%/*} + sqfs_drive_authority=${sqfs_drive_spec#*/} + ;; + live:*) + sqfs_drive_url=${root#live:} + sqfs_drive_spec=${sqfs_drive_url#*:} + sqfs_drive_scheme=${sqfs_drive_spec%%=*} + sqfs_drive_authority=${sqfs_drive_spec#*=} + ;; + '') + warn "No root; root needed - the system will likely fail to boot." + # do not fail, allow dracut to handle everything in case an operator/admin is doing something. + ;; + kdump) + : + ;; + *) + warn "alien root! unrecognized root= parameter: root=${root}" + ;; +esac + +export sqfs_drive_scheme +export sqfs_drive_authority diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..9516489 --- /dev/null +++ b/README.adoc @@ -0,0 +1,247 @@ += METAL 90mdsquash - redundant squashFS and overlayFS storage +:toc: +:toclevels: 3 + +This repository hosts a dracut module for creating a local overlayFS that provides persistent storage for a Live image. + +The created overlayFS is customizable, by default the overlayFS is built on a mirrored MD RAID. + +This module assumes authority and will wipe and partition a server from within the initramFS. + +Additionally, the partitioned RAID array will contain an empty LVM, this LVM is useful for allowing processes such as cloud-init to further +customize once the server boots. + +For more information on Dracut, the initramFS creation tool, see here: https://github.com/dracutdevs/dracut + +== Requirements + +In order to use this dracut module, you need: + +. A local-attached-usb or remote server with a squashFS image. +. Physical block devices must be installed in your blade(s). +. Two physical disk of 0.5TiB or less (or the RAID must be overridden, see <> + +== Usage + +Specify a local disk device for storing images, and the URL/endpoint to fetch images from on the kernel commandline (e.g. via `grub.cfg`, or an iPXE script). + +---- +metal.server= root=live:LABEL=SQFSRAID +---- + +The above snippet is the minimal cmdline necessary for this module to function. Additional options +are denoted throughout the <> section. + +== URI Drivers + +The URI scheme, authority, and +path values will tell the module where to look for SquashFS. Only those parts of a URI are supported. + +* file driver ++ +[source,bash] +---- +# Example: Load from another USB stick on the node. +file://mydir?LABEL=MYUSB +# Example: load a file from the root of an attached disk with the label SQFSRAID +file://?LABEL=SQFSRAID +# Example: load a file from a PIT recovery USB. +file://ephemeral/data/ceph/?LABEL=PITDATA +---- + +* http or https driver ++ +[source,bash] +---- +http://api-gw-service/path/to/service/endpoint +http://pit/ +http://10.100.101.111/some/local/server +---- + +Other drivers, such as native `s3`, `scp`, and `ftp` could be added but are not currently implemented. + +These drivers schemes are all defined by the rule generator, link:./90metalmdsquash/metal-genrules.sh[`metal-genrules.sh`]. + +== Kernel Parameters + +=== metal-mdsquash customizations + +==== `metal.debug` + +Set `metal.debug=1` to enable debug output from only metal modules. This will verbosely print the creation of the RAIDs and fetching of the squashFS image. *This effectively runs all dracut-metal code with `set -x`*, while leaving the rest of dracut to its own debug level. + +- `Default: 0` + +==== `metal.disks` + +Specify the number of disks to use in the local RAID (see link:README.md#metalmd-level[`metal.md-level`] for changing the RAID type). + +- `Default: 2` + +==== `metal.md-level` + +Change the level passed to mdadm for RAID creation, possible values are any value it takes. +Milaege varies, buyer beware this could dig a hole deeper. +- `Default: mirror` + +NOTE: When `metal.disks=1` is set, a RAID array is still created but with only one member. +In this case, only mirror and stripe will produce + +==== `metal.no-wipe` + +If this is set to `metal.no-wipe=1`, then all destructive behavior is disabled. The metal modules will either use what they find or make 0 changes during boots. This is insurance, it should not be required. This is helpful for development, or for admins tracking old and new nodes. +- `Default: 0` + +==== `metal.wipe-delay` + +The number of seconds that the wipe function will wait to allow an administrator to cancel it (by powering the node off). See the source code in link:./90metalmdsquash/metal-md-lib.sh[`metal-md-lib.sh`] for minimum and maximum values. + +- `Default: 5` +- `Unit: Seconds` + +==== `metal.ipv4` + +By default, metal-dracut will use IPv4 to resolve the deployment server for the initial call-to-home and when downloading artifacts regardless if IPv6 networking is present in the environment. To disable this constraint, simply set `metal.ipv4=0` in the cmdline. Setting this to `0` will enable all `ping` and `curl` calls for calling-home and downloading artifacts to use *either* IPv6 or IPv4 on their own accord (e.g. if IPv6 exists, then `ping` and `curl` will prefer to use it by default). Presumably if IPv6 is desired and exists, then IPv6 DHCP/DNS and general TCP/IP connectivity is working. +Lastly, if IPv6 does not exist then toggling this value to `0` has no effect. +- `Default: 1` + +==== `metal.sqfs-md-size` + +Set the size for the new SQFS partition. +Buyer beware this does not resize, this applies for new partitions. + +- `Default: 25` +- `Unit: Gigabytes` + +==== `metal.oval-md-size` + +Set the size for the new SQFS partition. +Buyer beware this does not resize, this applies for new partitions. + +- `Default: 150` +- `Unit: Gigabytes` + +==== `metal.aux-md-size` + +Set the size for the new SQFS partition. +Buyer beware this does not resize, this applies for new partitions. + +- `Default: 150` +- `Unit: Gigabytes` + +==== `metal.min-disk-size` + +Sets the minimum size threshold when wiping and partitioning disks, anything `<` this left untouched. + +- `Default: 16` +- `Unit: Gigabytes` + +=== dmsquashlive customizations + +reference: https://github.com/dracutdevs/dracut/blob/master/dracut.cmdline.7.asc#booting-live-images[dracut dmsquashlive cmdline] + +==== `rd.live.dir` + +Name of the directory store and load the artifacts from. Changing this value will affect metal and native-dracut. + +- `Default: LiveOS` + +==== `root` + +Specify the FSlabel of the block device to use for the SQFS storage. This could be an existing RAID or non-RAIDed device. +If a label is not found in `/dev/disk/by-label/*`, then the os-disks are paved with a new mirror array. +Can also be of UUID or + +- `Default: live:LABEL=SQFSRAID` + +==== `rd.live.overlay` + +Specify the FSlabel of the block device to use for persistent storage. +If a label is not found in `/dev/disk/by-label/*`, then the os-disks are paved. +If this is specified, then rd.live.overlay=$newlabel must also be specified. + +- `Default: LABEL=ROOTRAID` + +==== `rd.live.overlay.readonly` + +Make the persistent overlayFS read-only. + +- `Default: 0` + +==== `rd.live.overlay.reset` + +Reset the persistent overlayFS, regardless if it is read-only. +On the *next* boot the overlayFS will clear itself, it will continue to clear itself every +reboot until this is unset. This does not remake the RAID, this remakes the OverlayFS. Metal only +provides the underlying array, and the parent directory structure necessary for an OverlayFS to detect the array as compatible. + +- `Default: 0` + +==== `rd.live.overlay.size` + +Specify the size of the overlay in MB. + +- `Default: 204800` + +==== `rd.live.squashimg` + +Specify the filename to refer to download. + +- `Default: rootfs` + +=== dracut : standard customizations + +reference: https://github.com/dracutdevs/dracut/blob/master/dracut.cmdline.7.asc#standard[dracut standard cmdline] + +==== `rootfallback` + +This the label for the partition to be used for a fallback bootloader. + +- `Default: LABEL=BOOTRAID` + +== RootFS and the Persistent OverlayFS + +=== What is a Persistent Overlay? + +The idea of persistence is that changes _persist_ across reboots, when the state of the machine +changes it preserves information. For servers that boot images into memory (also known as live images), +an overlayFS is a common method for providing persistent storage. + +=== Feature Toggles + +Metal squashFS URL Dracut module has a few feature toggles, by default it is recommended to leave +them alone unless you must change them for your environment. + +==== Toggling Persistence + +Disable the overlayFS entirely by setting `rd.live.overlay=0`, this will cause a temporary overlay +to be created that exists in memory. A prompt may appear during boot to acknowledge the RAM overlayFS. + +To disable it entirely, delete all `rd.live.overlay.*` options. + +==== Toggling Read-Only OverlayFS + +Setting `rd.live.readonly=1` will cause the next boot's persistent overlayFS to be mounted +as read-only. This has a different convention in overlayFS and will look differently on your +system pending certain toggles: + +* either an + additional, non-persistent, writable snapshot overlay will be + stacked over a read-only snapshot, /dev/mapper/live-ro, of the + base filesystem with the persistent overlay, +* or a read-only loop + device, in the case of a writable rootfs.img, +* *(default)* or an OverlayFS + mount will use the persistent overlay directory linked at + /run/overlayfs-r as an additional lower layer along with the base + root filesystem and apply a transient, writable upper directory + overlay, in order to complete the booted root filesystem. + +==== Toggling Resetting the Persistent OverlayFS on Boot + +To cleanly reset the overlayFS, reboot the node with this kernel option: +`rd.live.overlay.reset=1`. + +The OverlayFS is reset by recreating the image file if it doesn't exist, and then by wiping the image +file if it does exist. The wipe is controlled by dracut-native (dmsquash-live), the creation of +the image file is handled by this dracut module (metal-squashfs-url-dracut). diff --git a/README.md b/README.md deleted file mode 100644 index f9c7dc8..0000000 --- a/README.md +++ /dev/null @@ -1,274 +0,0 @@ -# METAL 90mdsquash - redundant squashFS and overlayFS storage - -The Metal MDSquash dracut module lives in the initramFS, used during a server's boot. Within the initramFS, `metalmdsquash` does three things: -- It creates an mdraid array and sets up three partition -- It fetches a squashFS file from a given endpoint -- It creates a persistent overlayFS for the squashFS image -- Lastly, an LVM is created on the final partition for cloud-init and other high-level hand-off - -> For more information on Dracut, the initramFS creation tool, see here: https://github.com/dracutdevs/dracut - -Variable by customization arguments, the redundant storage will provision mirrored array across two "small" disks. This array -will contain 3 partitions; a partition for storing the fallback bootloader, another for storing squashFS images, and a final one for -storing persistent overlays. - -> For information on partitioning and disks in Shasta, see [NCN Partitioning](https://github.com/Cray-HPE/docs-csm/blob/main/background/ncn_mounts_and_file_systems.md). - -## Table of Contents - -- [Requirements](README.md#requirements) -- [Usage](README.md#usage) -- [URI Drivers](README.md#uri-drivers) -- [Parameters](README.md#parameters) - - [Kernel Parameters](README.md#kernel-parameters) - - [metal-mdsquash customizations](README.md#metal-mdsquash-customizations) - - [`metal.debug`](README.md#metaldebug) - - [`metal.disks`](README.md#metaldisks) - - [`metal.md-level`](README.md#metalmd-level) - - [`metal.no-wipe`](README.md#metalno-wipe) - - [`metal.wipe-delay`](README.md#metalwipe-delay) - - [`metal.ipv4`](README.md#metalipv4) - - [`metal.sqfs-md-size`](README.md#metalsqfs-md-size) - - [`metal.oval-md-size`](README.md#metaloval-md-size) - - [`metal.aux-md-size`](README.md#metalaux-md-size) - - [dmsquashlive customizations](README.md#dmsquashlive-customizations) - - [`rd.live.dir`](README.md#rdlivedir) - - [`root`](README.md#root) - - [`rd.live.overlay`](README.md#rdliveoverlay) - - [`rd.live.overlay.readonly`](README.md#rdliveoverlayreadonly) - - [`rd.live.overlay.reset`](README.md#rdliveoverlayreset) - - [`rd.live.overlay.size`](README.md#rdliveoverlaysize) - - [`rd.live.squashimg`](README.md#rdlivesquashimg) - - [dracut : standard customizations](README.md#dracut--standard-customizations) - - [`rootfallback`](README.md#`rootfallback`) -- [RootFS and the Persistent OverlayFS](README.md#rootfs-and-the-persistent-overlayfs) - - [What is a Persistent Overlay?](README.md#what-is-a-persistent-overlay) - - [Feature Toggles](README.md#feature-toggles) - - [Toggling Persistence](README.md#toggling-persistence) - - [Toggling Read-Only OverlayFS](README.md#toggling-read-only-overlayfs) - - [Toggling Resetting the Persistent OverlayFS on Boot](README.md#toggling-resetting-the-persistent-overlayfs-on-boot) - -## Requirements - -In order to use this dracut module, you need: - -1. A local-attached-usb or remote server with a squashFS image. -2. Physical block devices must be installed in your blade(s). -3. Two physical disk of 0.5TiB or less (or the RAID must be overridden, see [metal mdsquash customization](#metal-mdsquash-customizations) - -## Usage - -Specify a local disk device for storing images, and the URL/endpoint to fetch images from on the kernel commandline (e.g. via `grub.cfg`, or an iPXE script). - -``` -metal.server= root=live:LABEL=SQFSRAID rd.live.squashimg=filesystem.squashfs -``` - -The above snippet is the minimal cmdline necessary for this module to function. Additional options -are denoted throughout the [module customization](#parameters) section. - -## URI Drivers - -The URI scheme, authority, and -path values will tell the module where to look for SquashFS. Only those parts of a URI are supported. - -- file driver - - ```bash - # Example: Load from another USB stick on the node. - file://mydir?LABEL=MYUSB - # Example: load a file from the root of an attached disk with the label SQFSRAID - file://?LABEL=SQFSRAID - # Example: load a file from a PIT recovery USB. - file://ephemeral/data/ceph/?LABEL=PITDATA - ``` - -- http or https driver - - ```bash - http://api-gw-service/path/to/service/endpoint - http://pit/ - http://10.100.101.111/some/local/server - ``` - -Other drivers, such as native `s3`, `scp`, and `ftp` could be *added*. - -These drivers schemes are all defined by the rule generator, [`metal-genrules.sh`](./90metalmdsquash/metal-genrules.sh). - -## Parameters - -**The assigned value denotes the default value when the option is omitted on the cmdline.** - -### Kernel Parameters - -#### metal-mdsquash customizations - -##### `metal.debug` - -> Set `metal.debug=1` to enable debug output from only metal modules. This will verbosely print the creation of the RAIDs and fetching of the squashFS image. **This effectively runs all dracut-metal code with `set -x`**, while leaving the rest of dracut to its own debug level. -> - `Default: 0` - -##### `metal.disks` - -> Specify the number of disks to use in the local RAID (see [`metal.md-level`](README.md#metalmd-level) for changing the RAID type). -> - `Default: 2` - -##### `metal.md-level` - -> Change the level passed to mdadm for RAID creation, possible values are any value it takes. -> Milaege varies, buyer beware this could dig a hole deeper. -> - `Default: mirror` -> -> ***NOTE***: When `metal.disks=1` is set, only mirror and stripe will work. - - -##### `metal.no-wipe` - -> If this is set to `metal.no-wipe=1`, then all destructive behavior is disabled. The metal modules will either use what they find or make 0 changes during boots. This is insurance, it should not be required. This is helpful for development, or for admins tracking old and new nodes. -> - `Default: 0` - - -##### `metal.wipe-delay` - -> The number of seconds that the wipe function will wait to allow an administrator to cancel it (by powering the node off). See the source code in [`metal-md-lib.sh`](./90metalmdsquash/metal-md-lib.sh) for minimum and maximum values. -> - `Default: 5` -> - `Unit: Seconds` - - -##### `metal.ipv4` - -> By default, metal-dracut will use IPv4 to resolve the deployment server for the initial call-to-home and when downloading artifacts regardless if IPv6 networking is present in the environment. To disable this constraint, simply set `metal.ipv4=0` in the cmdline. Setting this to `0` will enable all `ping` and `curl` calls for calling-home and downloading artifacts to use **either** IPv6 or IPv4 on their own accord (e.g. if IPv6 exists, then `ping` and `curl` will prefer to use it by default). Presumably if IPv6 is desired and exists, then IPv6 DHCP/DNS and general TCP/IP connectivity is working. -> Lastly, if IPv6 does not exist then toggling this value to `0` has no effect. -> - `Default: 1` - - -##### `metal.sqfs-md-size` - -> Set the size for the new SQFS partition. -> Buyer beware this does not resize, this applies for new partitions. -> - `Default: 25` -> - `Unit: Gigabytes` - - -##### `metal.oval-md-size` - -> Set the size for the new SQFS partition. -> Buyer beware this does not resize, this applies for new partitions. -> - `Default: 150` -> - `Unit: Gigabytes` - - -##### `metal.aux-md-size` - -> Set the size for the new SQFS partition. -> Buyer beware this does not resize, this applies for new partitions. -> - `Default: 150` -> - `Unit: Gigabytes` - -#### dmsquashlive customizations - -reference: [dracut dmsquashlive cmdline][1] - -##### `rd.live.dir` - -> Name of the directory store and load the artifacts from. Changing this value will affect metal and native-dracut. -> - `Default: LiveOS` - -##### `root` - -> Specify the FSlabel of the block device to use for the SQFS storage. This could be an existing RAID or non-RAIDed device. -> If a label is not found in `/dev/disk/by-label/*`, then the os-disks are paved with a new mirror array. -> Can also be of UUID or -> - `Default: live:LABEL=SQFSRAID` - -##### `rd.live.overlay` - -> Specify the FSlabel of the block device to use for persistent storage. -> If a label is not found in `/dev/disk/by-label/*`, then the os-disks are paved. -> If this is specified, then rd.live.overlay=$newlabel must also be specified. -> - `Default: LABEL=ROOTRAID` - -##### `rd.live.overlay.readonly` - -> Make the persistent overlayFS read-only. -> - `Default: 0` - -##### `rd.live.overlay.reset` - -> Reset the persistent overlayFS, regardless if it is read-only. -> On the **next** boot the overlayFS will clear itself, it will continue to clear itself every -> reboot until this is unset. This does not remake the RAID, this remakes the OverlayFS. Metal only -> provides the underlying array, and the parent directory structure necessary for an OverlayFS to detect the array as compatible. -> - `Default: 0` - -##### `rd.live.overlay.size` - -> Specify the size of the overlay in MB. -> - `Default: 204800` - -##### `rd.live.squashimg` - -> Specify the filename to refer to download. -> - `Default: filesystem.squashfs` - -#### dracut : standard customizations - -notereference: [dracut standard cmdline][2] - -##### `rootfallback` - -> This the label for the partition to be used for a fallback bootloader. -> - `Default: LABEL=BOOTRAID` - -## RootFS and the Persistent OverlayFS - - -### What is a Persistent Overlay? - -The idea of persistence is that changes _persist_ across reboots, when the state of the machine -changes it preserves information. - - -### Feature Toggles - -Metal squashFS URL Dracut module has a few feature toggles, by default it is recommended to leave -them alone unless you must change them for your environment. - - -#### Toggling Persistence - -Disable the overlayFS entirely by setting `rd.live.overlay=0`, this will cause a temporary overlay -to be created that exists in memory. A prompt may appear during boot to acknowledge the RAM overlayFS. - -To disable it entirely, delete all `rd.live.overlay.*` options. - -#### Toggling Read-Only OverlayFS - -Setting `rd.live.readonly=1` will cause the next boot's persistent overlayFS to be mounted -as read-only. This has a different convention in overlayFS and will look differently on your -system pending certain toggles: - -- either an - additional, non-persistent, writable snapshot overlay will be - stacked over a read-only snapshot, /dev/mapper/live-ro, of the - base filesystem with the persistent overlay, -- or a read-only loop - device, in the case of a writable rootfs.img, -- **(default)** or an OverlayFS - mount will use the persistent overlay directory linked at - /run/overlayfs-r as an additional lower layer along with the base - root filesystem and apply a transient, writable upper directory - overlay, in order to complete the booted root filesystem. - - -#### Toggling Resetting the Persistent OverlayFS on Boot - -To cleanly reset the overlayFS, reboot the node with this kernel option: -`rd.live.overlay.reset=1`. - -The OverlayFS is reset by recreating the image file if it doesn't exist, and then by wiping the image -file if it does exist. The wipe is controlled by dracut-native (dmsquash-live), the creation of -the image file is handled by this dracut module (metal-squashfs-url-dracut). - -[1]: https://github.com/dracutdevs/dracut/blob/master/dracut.cmdline.7.asc#booting-live-images -[2]: https://github.com/dracutdevs/dracut/blob/master/dracut.cmdline.7.asc#standard diff --git a/dracut-metal-mdsquash.spec b/dracut-metal-mdsquash.spec index 23dcdbe..09cc35f 100644 --- a/dracut-metal-mdsquash.spec +++ b/dracut-metal-mdsquash.spec @@ -1,7 +1,7 @@ # # MIT License # -# (C) Copyright 2022 Hewlett Packard Enterprise Development LP +# (C) Copyright 2022-2023 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -21,52 +21,43 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. # -# disable compressing files -%define __os_install_post %{nil} -%define x_y_z %(echo $VERSION) -%define release_extra %(if [ -e "%{_sourcedir}/_release_extra" ] ; then cat "%{_sourcedir}/_release_extra"; else echo ""; fi) -%define source_name %{name} - -################################################################################ -# Primary package definition # -################################################################################ - Name: %(echo $NAME) Packager: Release: 1 -Vendor: Cray HPE -Version: %{x_y_z} -Source: %{source_name}-%{version}.tar.bz2 +Vendor: Hewlett Packard Enterprise Development LP +Version: %(echo $VERSION) +Source: %{name}-%{version}.tar.bz2 BuildArch: noarch -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} Group: System/Management License: MIT License -Summary: Install the Metal dracut module for loading squashFS and persistent overlays +Summary: Dracut module for loading squashFS and persistent overlays Provides: metal-mdsquash -Provides: 90metalmdsquash Requires: coreutils Requires: curl -Requires: dracut +Requires: diffutils Requires: dosfstools +Requires: dracut Requires: e2fsprogs Requires: efibootmgr Requires: iputils Requires: lvm2 Requires: mdadm Requires: parted +Requires: util-linux Requires: util-linux-systemd Requires: xfsprogs %define dracut_modules /usr/lib/dracut/modules.d -%define url_dracut_doc /usr/share/doc/metal-dracut/mdsquash/ %define module_name 90metalmdsquash +Provides: %{module_name} +%define url_dracut_doc /usr/share/doc/metal/%{module_name}/ %description %prep -%setup +%setup -q %build @@ -74,14 +65,14 @@ Requires: xfsprogs %{__mkdir_p} %{buildroot}%{url_dracut_doc} %{__mkdir_p} %{buildroot}%{dracut_modules}/%{module_name} cp -pvrR ./%{module_name}/* %{buildroot}%{dracut_modules}/%{module_name} | awk '{print $3}' | sed "s/'//g" | sed "s|$RPM_BUILD_ROOT||g" | tee -a INSTALLED_FILES -%{__install} -m 0644 README.md %{buildroot}%{url_dracut_doc} +%{__install} -m 0644 README.adoc %{buildroot}%{url_dracut_doc} %files -f INSTALLED_FILES %defattr(0755, root, root) %license LICENSE %dir %{dracut_modules}/%{module_name} %dir %{url_dracut_doc} -%attr(644, root, root) %{url_dracut_doc}/README.md +%attr(644, root, root) %{url_dracut_doc}/README.adoc %pre @@ -92,8 +83,4 @@ cp -pvrR ./%{module_name}/* %{buildroot}%{dracut_modules}/%{module_name} | awk ' %posttrans mkinitrd -B -if rpm -q kdump 2>&1 >/dev/null ; then - mkdumprd -f -fi - %changelog