diff --git a/zipl/dracut/zipl_helper.prepare-ngdump b/zipl/dracut/zipl_helper.prepare-ngdump index 7f774876..f078480c 100755 --- a/zipl/dracut/zipl_helper.prepare-ngdump +++ b/zipl/dracut/zipl_helper.prepare-ngdump @@ -16,14 +16,21 @@ DRACUT_OMIT_MODULES=( systemd-timedated systemd-timesyncd systemd-networkd systemd-network-manager systemd-coredump) -[ $# -gt 0 ] || { echo "Usage: $0 " >&2; exit 1; } +function create_dumpfs() +{ + [ "$dryrun" -eq 1 ] && { echo "/dev/null"; return 0; } + mkfs -F "$device" >/dev/null || { echo "Couldn't create filesystem on $1." >&2; return 1; } + local disk_path=/dev/disk/by-uuid/$(blkid -o value -s UUID "$device") + for i in $(seq 0 30) + do + [ -e "$disk_path" ] && break; + sleep 1 + done + + [ -e "$disk_path" ] || { echo "Filesystem device link missing." >&2; return 1; } + echo "$disk_path" +} -# -# Retrieve partition UUID -# -# We use PARTUUID because zipl re-formats the given partition after -# calling us, therefore, a UUID will change. -# device=$(readlink -f $1) disk_path=/dev/disk/by-partuuid/$(blkid -o value -s PARTUUID "$device") @@ -69,6 +76,11 @@ function create_initrd() --kver "$kver" -f "$initrd" 2>&1 } +[ $# -gt 1 ] || { echo "Usage: $0 " >&2; exit 1; } + +device=$(readlink -f $1) +dryrun=$2 +disk_path=$(create_dumpfs $device) kernel_version=$(get_kernel_version) kernel=$(get_kernel_image "$kernel_version") [ -e "$kernel" ] || { echo "Couldn't find kernel image." >&2; exit 1; } diff --git a/zipl/initramfs-tools/zipl_helper.prepare-ngdump b/zipl/initramfs-tools/zipl_helper.prepare-ngdump index 5727474b..6dd4ce73 100755 --- a/zipl/initramfs-tools/zipl_helper.prepare-ngdump +++ b/zipl/initramfs-tools/zipl_helper.prepare-ngdump @@ -6,18 +6,20 @@ # it under the terms of the MIT license. See LICENSE for details. # -[ $# -gt 0 ] || { echo "Usage: $0 " >&2; exit 1; } +function create_dumpfs() +{ + [ "$dryrun" -eq 1 ] && { echo "/dev/null"; return 0; } + mkfs -F "$device" >/dev/null || { echo "Couldn't create filesystem on $1." >&2; return 1; } + local disk_path=/dev/disk/by-uuid/$(blkid -o value -s UUID "$device") + for i in $(seq 0 30) + do + [ -e "$disk_path" ] && break; + sleep 1 + done -# -# Retrieve partition UUID -# -# We use PARTUUID because zipl re-formats the given partition after -# calling us, therefore, a UUID will change. -# -device=$(readlink -f $1) -disk_path=/dev/disk/by-partuuid/$(blkid -o value -s PARTUUID "$device") - -[ -e "$disk_path" ] || { echo "Couldn't find disk by PARTUUID." >&2; exit 1; } + [ -e "$disk_path" ] || { echo "Filesystem device link missing." >&2; return 1; } + echo "$disk_path" +} function get_kernel_version() { @@ -49,6 +51,11 @@ function create_initrd() NGDUMP=y NGDUMP_DEVICE="$disk" mkinitramfs -o "$initrd" "$kver" 2>&1 } +[ $# -gt 1 ] || { echo "Usage: $0 " >&2; exit 1; } + +device=$(readlink -f $1) +dryrun=$2 +disk_path=$(create_dumpfs $device) kernel_version=$(get_kernel_version) kernel=$(get_kernel_image "$kernel_version") [ -e "$kernel" ] || { echo "Couldn't find kernel image." >&2; exit 1; } diff --git a/zipl/src/bootmap.c b/zipl/src/bootmap.c index 9e13639a..7770b062 100644 --- a/zipl/src/bootmap.c +++ b/zipl/src/bootmap.c @@ -1667,7 +1667,6 @@ static int prepare_bootloader_ngdump(struct job_data *job, { struct disk_info *info; char *bootmap_dir; - int rc; /* Retrieve target device information */ if (disk_get_info(job->data.dump.device, &job->target, &info)) @@ -1693,22 +1692,6 @@ static int prepare_bootloader_ngdump(struct job_data *job, return -1; } bis->dump_tmp_dir_created = 1; - if (!dry_run) { - char *cmd = NULL; - util_asprintf(&cmd, "mkfs.%s -qF %s >/dev/null", - NGDUMP_FSTYPE, job->data.dump.device); - if (verbose) - printf("Formatting partition '%s'\n", - job->data.dump.device); - rc = system(cmd); - free(cmd); - if (rc) { - error_reason(strerror(errno)); - error_text("Could not format partition '%s':", - job->data.dump.device); - return -1; - } - } /* * Mount partition where bootmap file and also a dump file will * be stored. diff --git a/zipl/src/job.c b/zipl/src/job.c index 41e674b7..53c1a4e6 100644 --- a/zipl/src/job.c +++ b/zipl/src/job.c @@ -919,7 +919,7 @@ check_job_images_ngdump(struct job_dump_data* dump, char *name) FILE *fp; int rc; - misc_asprintf(&ppn_cmd, "%s %s", helper, dump->device); + misc_asprintf(&ppn_cmd, "%s %s %d", helper, dump->device, dry_run); printf("Run %s\n", ppn_cmd); fp = popen(ppn_cmd, "r");