From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH] init-install-efi: Implement UUID support
Date: Wed, 10 Jun 2015 18:07:45 +0300 [thread overview]
Message-ID: <1433948865-3729-1-git-send-email-ed.bartosh@linux.intel.com> (raw)
Using UUID in favor of device names is more reliable as
UUID names are persistent.
Device names can change as the order of adding device nodes
is arbitrary. This sometimes results in device names switching
on each boot, which can cause system fail to boot.
Persistent naming solves these issues.
Used partition UUID in kernel command line to specify root partition.
Used partition UUID in /etc/fstab to specify boot and swap partitions.
[YOCTO #6101]
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
---
.../recipes-core/initrdscripts/files/init-install-efi.sh | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index 8dd2749..d03d087 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -158,14 +158,22 @@ mkdir /tgt_root
mkdir /src_root
mkdir -p /boot
+# Get partition UUIDs
+get_partuuid() {
+ sgdisk -i$2 /dev/$1 | sed -n 's/Partition unique GUID: \(.*\)/\1/p'
+}
+bootuuid=$(get_partuuid $device 1)
+rootuuid=$(get_partuuid $device 2)
+swapuuid=$(get_partuuid $device 3)
+
# Handling of the target root partition
mount $rootfs /tgt_root
mount -o rw,loop,noatime,nodiratime /run/media/$1/$2 /src_root
echo "Copying rootfs files..."
cp -a /src_root/* /tgt_root
if [ -d /tgt_root/etc/ ] ; then
- echo "$swap swap swap defaults 0 0" >> /tgt_root/etc/fstab
- echo "$bootfs /boot vfat defaults 1 2" >> /tgt_root/etc/fstab
+ echo "PARTUUID=$swapuuid swap swap defaults 0 0" >> /tgt_root/etc/fstab
+ echo "PARTUUID=$bootuuid /boot vfat defaults 1 2" >> /tgt_root/etc/fstab
# We dont want udev to mount our root device while we're booting...
if [ -d /tgt_root/etc/udev/ ] ; then
echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist
@@ -196,7 +204,7 @@ if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
# Delete any root= strings
sed -i "s/ root=[^ ]*/ /" $GRUBCFG
# Add the root= and other standard boot options
- sed -i "s@linux /vmlinuz *@linux /vmlinuz root=$rootfs rw $rootwait quiet @" $GRUBCFG
+ sed -i "s@linux /vmlinuz *@linux /vmlinuz root=PARTUUID=$rootuuid rw $rootwait quiet @" $GRUBCFG
fi
if [ -d /run/media/$1/loader ]; then
@@ -212,7 +220,7 @@ if [ -d /run/media/$1/loader ]; then
# delete any root= strings
sed -i "s/ root=[^ ]*/ /" $GUMMIBOOT_CFGS
# add the root= and other standard boot options
- sed -i "s@options *@options root=$rootfs rw $rootwait quiet @" $GUMMIBOOT_CFGS
+ sed -i "s@options *@options root=PARTUUID=$rootuuid rw $rootwait quiet @" $GUMMIBOOT_CFGS
fi
umount /tgt_root
--
2.1.4
reply other threads:[~2015-06-10 17:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1433948865-3729-1-git-send-email-ed.bartosh@linux.intel.com \
--to=ed.bartosh@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox