Persistent device name is an uuid in directory /dev/disk/by-uuid which can determine the unique devices by soft link. The uuid is created, once the device are formated by command mkfs, and one filesystem has an unique uuid to detect itself.
For btrfs, one filesystem may contain several devices. So it may fail to find the device from the /dev/disk/by-uuid as usual, because /dev/disk/by-uuid/* only points to the one of the several devices by the soft link, although there is a filesystem on the devices.
In order to get the persistent device, we can use command "blkid", instead of finding it in directory /dev/disk/by-uuid directly.
Signed-off-by: Minfei Huang mhuang@redhat.com --- v1: - describe the commit log more detail --- mkdumprd | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/mkdumprd b/mkdumprd index 8cf3c7b..52d560e 100644 --- a/mkdumprd +++ b/mkdumprd @@ -30,14 +30,14 @@ perror() { }
get_persistent_dev() { - local i _tmp _dev + local i _tmp _dev _uuid
_dev=$(udevadm info --query=name --name="$1" 2>/dev/null) [ -z "$_dev" ] && { perror_exit "Kernel dev name of $1 is not found." }
- for i in /dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*; do + for i in /dev/mapper/* /dev/disk/by-id/*; do _tmp=$(udevadm info --query=name --name="$i" 2>/dev/null) if [ "$_tmp" = "$_dev" ]; then echo $i @@ -45,6 +45,18 @@ get_persistent_dev() { fi done
+ if [ "x" != "x""$(blkid $1 | grep "UUID")" ]; then + _uuid=`blkid $1 | grep "UUID" | awk '{print $2}'` + _uuid=${_uuid#*"} + _uuid=${_uuid%"*} + _dev=/dev/disk/by-uuid/$_uuid + _tmp=$(udevadm info --query=name --name=$_dev 2>/dev/null) + if [ "x" != "x"$_tmp ]; then + echo $_dev + return + fi + fi + perror "WARNING: Persistent device name of $1 not found. Using $1 as dump target name" echo $1 }
On 06/02/15 at 05:04pm, Minfei Huang wrote:
Persistent device name is an uuid in directory /dev/disk/by-uuid which can determine the unique devices by soft link. The uuid is created, once the device are formated by command mkfs, and one filesystem has an unique uuid to detect itself.
For btrfs, one filesystem may contain several devices. So it may fail to find the device from the /dev/disk/by-uuid as usual, because /dev/disk/by-uuid/* only points to the one of the several devices by the soft link, although there is a filesystem on the devices.
In order to get the persistent device, we can use command "blkid", instead of finding it in directory /dev/disk/by-uuid directly.
Hi Minfei,
Could you please give an example in your testing environment? If you don't like the specific inforamtion, you can use things like a btrfs is built on /dev/{a,b,c}, then how problems happened and how you fixed it. Otherwise I need build a btrfs and execute your shell command line by line to understand your patch.
Giving example can accelerate people's review, seriously.
Thanks Baoquan
Signed-off-by: Minfei Huang mhuang@redhat.com
v1:
- describe the commit log more detail
mkdumprd | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/mkdumprd b/mkdumprd index 8cf3c7b..52d560e 100644 --- a/mkdumprd +++ b/mkdumprd @@ -30,14 +30,14 @@ perror() { }
get_persistent_dev() {
- local i _tmp _dev
local i _tmp _dev _uuid
_dev=$(udevadm info --query=name --name="$1" 2>/dev/null) [ -z "$_dev" ] && { perror_exit "Kernel dev name of $1 is not found." }
- for i in /dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*; do
- for i in /dev/mapper/* /dev/disk/by-id/*; do _tmp=$(udevadm info --query=name --name="$i" 2>/dev/null) if [ "$_tmp" = "$_dev" ]; then echo $i
@@ -45,6 +45,18 @@ get_persistent_dev() { fi done
- if [ "x" != "x""$(blkid $1 | grep "UUID")" ]; then
_uuid=`blkid $1 | grep "UUID" | awk '{print $2}'`_uuid=${_uuid#*\"}_uuid=${_uuid%\"*}_dev=/dev/disk/by-uuid/$_uuid_tmp=$(udevadm info --query=name --name=$_dev 2>/dev/null)if [ "x" != "x"$_tmp ]; thenecho $_devreturnfi- fi
- perror "WARNING: Persistent device name of $1 not found. Using $1 as dump target name" echo $1
}
1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec