add 'get_uuid_by_path()' to get UUID by the given path

Signed-off-by: Dongjin Kim <tobetter@gmail.com>
Change-Id: I432d051ee1f0424ede9736985d7991ac52bb551a
This commit is contained in:
Dongjin Kim
2020-11-22 02:46:41 +09:00
parent b3afb95c60
commit fb6f744b4b

View File

@@ -114,6 +114,10 @@ do_mount() {
mount -o bind /sys ${rootfs_mnt}/sys
}
get_uuid_by_path() {
grep " ${1} " ${rootfs_mnt}/etc/fstab | cut -d' ' -f1 | cut -d'=' -f2 | tr -d '"'
}
do_create_partition() {
local disk=${1}
local boot_blk=$((${2} * 1024 * 1024 / 512 - 1))
@@ -155,8 +159,8 @@ do_create_partition() {
echo ${LOOPBACK}
fi
UUID_BOOT=$(grep " /boot " ${rootfs_mnt}/etc/fstab | cut -d' ' -f1 | cut -d'=' -f2 | tr -d '"')
UUID_ROOT=$(grep " / " ${rootfs_mnt}/etc/fstab | cut -d' ' -f1 | cut -d'=' -f2 | tr -d '"')
UUID_BOOT=$(get_uuid_by_path "/boot")
UUID_ROOT=$(get_uuid_by_path "/")
sudo mkfs.ext2 -F -L BOOT -U ${UUID_BOOT} \
-d ${boot_mnt} $(get_part_boot) 2>/dev/null \