pass persistent name to dracut --mount

currently --mount param are retrieved from /proc/mounts, but the device
name could be renamed in initramfs. So here convert them to persistent
names before passing to dracut

lvm canonical dev name is /dev/mapper/lvname-link which will be showed
in /proc/mounts
here fix get_mp function by using findmnt utils to find the mount point.

This patch depends on below dracut patch:
http://permalink.gmane.org/gmane.linux.kernel.initramfs/2903

[chaowang]:
in case device is not mounted we should not echo the mount line in to_mount()
use findmnt -n to strip the header line
for nfs don't pass persistent name to dracut
[vivek]:
improve variable names

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
Dave Young 2012-09-20 11:03:19 +08:00
parent 7de0cc4a92
commit 9d161703a6
2 changed files with 14 additions and 19 deletions

View File

@ -53,23 +53,9 @@ add_dump_code()
DUMP_INSTRUCTION=$1
}
get_mp()
{
local _mp
local dev mp fs opts rest
while read dev mp fs opts rest; do
if [ "$dev" = "$1" ]; then
_mp="$mp"
break
fi
done < /proc/mounts
echo "$_mp"
}
dump_fs()
{
local _dev=$1
local _mp=`get_mp $_dev`
local _mp=$(findmnt -k -f -n -r -o TARGET $1)
if [ -z "$_mp" ]; then
echo "kdump: error: Dump target $1 is not mounted."

View File

@ -78,13 +78,22 @@ get_rootdev() {
}
to_mount() {
local _dev=$(to_dev_name $1)
echo "$(grep "$_dev" /proc/mounts | cut -d' ' -f1-4)"
local _dev _mntopts _pdev
_dev=$(to_dev_name $1)
_mntopts=$(findmnt -k -f -n -r -o TARGET,FSTYPE,OPTIONS $_dev)
[ -z "$_mntopts" ] && return
#for non-nfs _dev converting to use udev persistent name
if [ -b "$_dev" ]; then
_pdev="$(get_persistent_dev $_dev)"
else
_pdev=$_dev
fi
echo "$_pdev $_mntopts"
}
to_mount_point() {
local _dev=$(to_dev_name $1)
echo "$(grep "$_dev" /proc/mounts | cut -d' ' -f2)"
echo $(findmnt -k -f -n -r -o TARGET $1)
}
#Function: get_ssh_size