mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl: move mkfs to ngdump prepare script
The current code first assembles the ngdump init ramdisk, and creates the filesystem on the dump disk afterwards. ngdump uses uuids to mount the dump device. Because the filesystem uuid is changing with the final mkfs, ngdump has to use the partuuid of the device. This does work for nvme, but not for dasds. Another problem is that dryrun likely wouldn't work if there's no partition table on the dump device. To fix these issues, move the mkfs to the ngdump helper script so we can use the filesystem uuid. When --dryrun is specified the script passes /dev/null as ngdump device to make mkinitramfs happy. As the initramdisk is never used in this case, this shouldn't be a problem. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> Acked-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
committed by
Steffen Eiden
parent
f5aa1d4406
commit
41108c98aa
@@ -16,14 +16,21 @@ DRACUT_OMIT_MODULES=(
|
||||
systemd-timedated systemd-timesyncd
|
||||
systemd-networkd systemd-network-manager systemd-coredump)
|
||||
|
||||
[ $# -gt 0 ] || { echo "Usage: $0 <dump partition device>" >&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 <dump partition device> <dryrun>" >&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; }
|
||||
|
||||
@@ -6,18 +6,20 @@
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
#
|
||||
|
||||
[ $# -gt 0 ] || { echo "Usage: $0 <dump partition device>" >&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 <dump partition device> <dryrun>" >&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; }
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user