summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2018-11-12 12:45:59 +0100
committerJonathan Bauer2018-11-12 17:30:33 +0100
commit49a54b6f2157e80c076528c15eb7928c6ef06d24 (patch)
tree43e6f032eb3ff850f6b46b61863bee6316db31e1
parent[dnbd3-rfs] better detection of 'dracut-mount.service' location (diff)
downloadsystemd-init-49a54b6f2157e80c076528c15eb7928c6ef06d24.tar.gz
systemd-init-49a54b6f2157e80c076528c15eb7928c6ef06d24.tar.xz
systemd-init-49a54b6f2157e80c076528c15eb7928c6ef06d24.zip
[dnbd3-rfs] refactor to use slx-partitioner
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh2
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh103
-rwxr-xr-xbuilder/modules.d/dnbd3-rootfs/module-setup.sh11
3 files changed, 19 insertions, 97 deletions
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh b/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh
index 35443def..a5aceab6 100755
--- a/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh
+++ b/builder/modules.d/dnbd3-rootfs/hooks/mount-root-device.sh
@@ -14,7 +14,7 @@ logging.set_log_file "$SLX_LOG_FILE_PATH"
if ! getarg root=; then
source "/etc/openslx"
- mount /dev/mapper/root "$NEWROOT" $SLX_MOUNT_ROOT_OPTIONS
+ mount "$SLX_DNBD3_DEVICE_COW" "$NEWROOT" $SLX_MOUNT_ROOT_OPTIONS
if [ -n "$SLX_GENERATE_FSTAB_SCRIPT" ]; then
eval "$SLX_GENERATE_FSTAB_SCRIPT"
else
diff --git a/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
index 4ac01632..1b575067 100755
--- a/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
+++ b/builder/modules.d/dnbd3-rootfs/hooks/prepare-root-partition.sh
@@ -15,85 +15,7 @@ logging.set_level debug
[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx
logging.set_log_file "$SLX_LOG_FILE_PATH"
-# region find writable partition
-# support comma-separated list of identifiers
-IFS_backup="$IFS"
-IFS=','
-for identifier in $SLX_WRITABLE_DEVICE_IDENTIFIER; do
- if [[ "$identifier" != '' ]] &&
- persistent_device="$(
- tools.find_block_device "$identifier" '' \
- "$SLX_WRITABLE_DEVICE_IDENTIFIER_TIMEOUT_IN_SECONDS")"; then
- break
- fi
- persistent_device=
-done
-IFS="$IFS_backup"
-
-if [ -z "$persistent_device" ]; then
- logging.warn "Failed to find unique device with identifiers" \
- "\"${SLX_WRITABLE_DEVICE_IDENTIFIER}\"; matched devices:" \
- "\"${persistent_device}\""
-fi
-
-if [ -n "$SLX_WRITABLE_DEVICE_STORAGE_FILE_PATH" ] && [ -n "$persistent_device" ]; then
- persistent_mountpoint=/mnt/slx_writable_device
- storage_file_path="${persistent_mountpoint}/$SLX_WRITABLE_DEVICE_STORAGE_FILE_PATH"
- ! mkdir --parents "$(dirname "$storage_file_path")"
- if ! mount --type auto "$persistent_device" "$persistent_mountpoint"; then
- logging.warn "Failed to mount $persistent_device, checking filesystem."
- ! $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CHECK_COMMAND \
- "$persistent_device"
- if ! mount --type auto "$persistent_device" "$persistent_mountpoint"; then
- logging.warn "Mounting $persistent_device, still failing," \
- "creating new filesystem on device"
- $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CREATE_COMMAND \
- "$persistent_device"
- fi
- if ! mount --type auto "$persistent_device" "$persistent_mountpoint"; then
- logging.warn "Mounting $persistent_device, still failing," \
- "giving up, and using ramdisk"
- persistent_device=""
- fi
- fi
- if [ -n "$persistent_device" ]; then
- if [ ! -e "$storage_file_path" ]; then
- # Create a sparse file.
- dd of="$storage_file_path" bs=1M \
- seek="$SLX_WRITABLE_DEVICE_STORAGE_MAXIMUM_FILE_SIZE_IN_MB" count=0
- fi
- persistent_device="$(losetup --find)"
- losetup "$persistent_device" "$storage_file_path"
- fi
-fi
-
-# "P" for persistent storage, "N" for not persistent (affects dmsetup call,
-# see scripts/device-add-write-layer.sh)
-persistent='N'
-if [ -n "$persistent_device" ]; then
- writable_device="$persistent_device"
- if [ "$SLX_WRITABLE_DEVICE_PERSISTENT" = "yes" ]; then
- persistent='P'
- fi
-else
- ramdisk_size_in_kb="$SLX_RAMDISK_SIZE_IN_KB"
- if [ "$ramdisk_size_in_kb" = '' ]; then
- ramdisk_size_in_kb="$(awk '/MemTotal/ {print $2}' /proc/meminfo)"
- fi
- # NOTE: If the kernel modul "brd" is compiled into current kernel we can't
- # configure ram disk size dynamically. In this case it have to be
- # configured via kernel command line: "brd.rd_size=SITE_IN_KILOBYTE"
- # statically:
- #! rmmod brd 2>/dev/null
- #modprobe brd max_part=1 rd_size="$ramdisk_size_in_kb"
- #writable_device='/dev/ram0'
- ramdisk_location="$(mktemp)"
- dd of="$ramdisk_location" seek="$ramdisk_size_in_kb" count=0 1>/dev/null
- writable_device="$(losetup --find)"
- losetup "$writable_device" "$ramdisk_location"
-fi
-# endregion
-# region connect dnbd3
+# region connect dnbd3 image
IFS_backup="$IFS"
IFS=", "
return_code=1
@@ -115,7 +37,7 @@ if [[ $return_code != 0 ]]; then
exit 1
fi
# endregion
-# region scan partitions
+# region unpack dnbd3 image with xmount
if [ "$SLX_LOG_FILE_PATH" != "" ]; then
read_only_device="$(container-unpack-xmount "$SLX_DNBD3_DEVICE" \
2>>"$SLX_LOG_FILE_PATH")"
@@ -123,19 +45,19 @@ else
read_only_device="$(container-unpack-xmount "$SLX_DNBD3_DEVICE")"
fi
-
-# Fail fast if no device could be determined.
+# Fail fast if unpacking dnbd3 image failed.
[ -z "$read_only_device" ] && exit 1
+
# endregion
-# region find read-only partition
+# region find system partition within dnbd3 image
if [ -z "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT" ]; then
if [ -z "$SLX_SYSTEM_PARTITION_IDENTIFIER" ]; then
# if empty use whole device
read_only_partition="$read_only_device"
true
else
- read_only_partition="$(tools.find_block_device \
- "$SLX_SYSTEM_PARTITION_IDENTIFIER" "$read_only_device")"
+ read_only_partition="$(get_partitions_by_id \
+ "$read_only_device" "$SLX_SYSTEM_PARTITION_IDENTIFIER")"
fi
else
eval "$SLX_SYSTEM_PARTITION_PREPARATION_SCRIPT"
@@ -146,14 +68,13 @@ if [[ ! $? || -z "$read_only_partition" ]]; then
"\"${read_only_partition}\""
exit 1
fi
-# endregion
-
logging.info "Using read-only partition: $read_only_partition"
-logging.info "Using writable device $writable_device, persistency: $persistent"
-# combine devices with device mapper
-device-add-write-layer "root" "$read_only_partition" "$writable_device" \
- "$persistent"
+# endregion
+
+# region RW layer through slx-partitioner
+/usr/bin/slx_partitioner $read_only_partition
+# endregion
}
exceptions.catch
diff --git a/builder/modules.d/dnbd3-rootfs/module-setup.sh b/builder/modules.d/dnbd3-rootfs/module-setup.sh
index 759cd476..f956af3c 100755
--- a/builder/modules.d/dnbd3-rootfs/module-setup.sh
+++ b/builder/modules.d/dnbd3-rootfs/module-setup.sh
@@ -153,7 +153,7 @@ depends() {
'
local network_module="network"
dracut_module_included "systemd-initrd" && network_module="systemd-networkd-ext"
- echo base bash kernel-modules shutdown "$network_module"
+ echo base bash kernel-modules shutdown slx-partitioner "$network_module"
}
installkernel() {
local __doc__='
@@ -166,7 +166,6 @@ installkernel() {
'
inst "$moddir/binaries/dnbd3/build/dnbd3.ko" \
/usr/lib/modules/current/extra/dnbd3.ko
- instmods dm_snapshot btrfs crc32c
}
install() {
local __doc__='
@@ -185,6 +184,8 @@ install() {
/usr/bin/device-add-write-layer
inst "$moddir/scripts/container-unpack-xmount.sh" \
/usr/bin/container-unpack-xmount
+ inst "$moddir/scripts/container-unpack-qemu.sh" \
+ /usr/bin/container-unpack-qemu
# xmount
local \
xmount_installation="$moddir/binaries/xmount/trunk/build/release_build"
@@ -206,7 +207,7 @@ install() {
inst_hook pre-udev 00 "$moddir/hooks/load-custom-kernel-modules.sh"
# Get the openslx config from the servers configured in the kernel command
# line (${SLX_SERVER}/${SLX_SERVER_BASE}/config).
- inst_hook pre-mount 00 "$moddir/hooks/fetch-config.sh"
+ inst_hook pre-mount 10 "$moddir/hooks/fetch-config.sh"
# make the final blockdevice for the root system (dnbd3 -> xmount ->
# device-mapper)
if dracut_module_included "systemd-initrd"; then
@@ -257,11 +258,11 @@ install() {
basename bash blockdev \
cat cut \
dd diff dirname dmsetup \
- find fsck.ext4 fsck.xfs \
+ find \
grep \
insmod \
losetup lsblk \
- mkfifo mkfs.ext4 mkfs.xfs mktemp mount mountpoint \
+ mkfifo mktemp mount mountpoint \
sed sleep sort \
tee touch tr \
wget