From b0418a0272fde5dbe2725f9ba55a1dd497763ad1 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Tue, 6 Aug 2013 13:48:42 +0200 Subject: [PATCH] initrd.scripts: ensure_initramfs_mounts: check if partition is mounted Before trying to mount a filesystem, check if it's already mounted first. This way we can call ensure_initramfs_mounts multiple times during the pivot root initialization. --- defaults/initrd.scripts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 9937ff4..a42aa82 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -1661,6 +1661,13 @@ ensure_initramfs_mounts() { local dev= fstype= opts= mnt= cmd= for fs in ${fslist}; do + + mnt="${NEW_ROOT}${fs}" + if mountpoint -q "${mnt}"; then + good_msg "${fs} already mounted, skipping..." + continue + fi + dev=$(get_mount_device "${fs}") [ -z "${dev}" ] && continue # Resolve it like util-linux mount does @@ -1680,7 +1687,6 @@ ensure_initramfs_mounts() { opts="${opts},ro" fi - mnt="${NEW_ROOT}${fs}" cmd="mount -t ${fstype} -o ${opts} ${dev} ${mnt}" good_msg "Mounting ${dev} as ${fs}: ${cmd}" if ! ${cmd}; then