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.
master
Fabio Erculiani 12 years ago
parent 4fa6686515
commit b0418a0272

@ -1661,6 +1661,13 @@ ensure_initramfs_mounts() {
local dev= fstype= opts= mnt= cmd= local dev= fstype= opts= mnt= cmd=
for fs in ${fslist}; do 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}") dev=$(get_mount_device "${fs}")
[ -z "${dev}" ] && continue [ -z "${dev}" ] && continue
# Resolve it like util-linux mount does # Resolve it like util-linux mount does
@ -1680,7 +1687,6 @@ ensure_initramfs_mounts() {
opts="${opts},ro" opts="${opts},ro"
fi fi
mnt="${NEW_ROOT}${fs}"
cmd="mount -t ${fstype} -o ${opts} ${dev} ${mnt}" cmd="mount -t ${fstype} -o ${opts} ${dev} ${mnt}"
good_msg "Mounting ${dev} as ${fs}: ${cmd}" good_msg "Mounting ${dev} as ${fs}: ${cmd}"
if ! ${cmd}; then if ! ${cmd}; then

Loading…
Cancel
Save