All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ed Bartosh <ed.bartosh@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH v2 06/11] init-install: Implement UUID support
Date: Tue, 16 Jun 2015 09:13:49 +0300	[thread overview]
Message-ID: <1434435234-4892-7-git-send-email-ed.bartosh@linux.intel.com> (raw)
In-Reply-To: <1434435234-4892-1-git-send-email-ed.bartosh@linux.intel.com>

Used partition UUID in kernel command line to specify root partition.
Searched root device by file system uuid in GRUB configuration.
Used partition UUID in /etc/fstab to specify swap partition.
Used filesystem UUID in /etc/fstab to specify boot partition.

[YOCTO #6101]

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>

diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index 298ea8d..9957c15 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -196,8 +196,17 @@ 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            ext3       defaults              1  2" >> /tgt_root/etc/fstab
+    if [ $grub_version -ne 0 ] ; then
+        boot_uuid=$(blkid -o value -s UUID ${device}2)
+        swap_part_uuid=$(blkid -o value -s PARTUUID ${device}4)
+        bootdev="UUID=$boot_uuid"
+        swapdev=/dev/disk/by-partuuid/$swap_part_uuid
+    else
+        bootdev=${device}2
+        swapdev=${device}4
+    fi
+    echo "$swapdev                swap             swap       defaults              0  0" >> /tgt_root/etc/fstab
+    echo "$bootdev              /boot            ext3       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
@@ -209,22 +218,24 @@ umount /src_root
 # Handling of the target boot partition
 mount $bootfs /boot
 echo "Preparing boot partition..."
-if [ -f /etc/grub.d/00_header ] ; then
+if [ -f /etc/grub.d/00_header -a $grub_version -ne 0 ] ; then
     echo "Preparing custom grub2 menu..."
+    root_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}3)
+    boot_uuid=$(blkid -o value -s UUID /dev/${device}2)
     GRUBCFG="/boot/grub/grub.cfg"
     mkdir -p $(dirname $GRUBCFG)
     cat >$GRUBCFG <<_EOF
 menuentry "Linux" {
-    set root=(hd0,2)
-    linux /vmlinuz root=$rootfs $rootwait rw $5 $3 $4 quiet
+    search --no-floppy --fs-uuid $boot_uuid --set root
+    linux /vmlinuz root=PARTUUID=$root_part_uuid $rootwait rw $5 $3 $4 quiet
 }
 _EOF
     chmod 0444 $GRUBCFG
 fi
 grub-install /dev/${device}
-echo "(hd0) /dev/${device}" > /boot/grub/device.map
 
 if [ $grub_version -eq 0 ] ; then
+    echo "(hd0) /dev/${device}" > /boot/grub/device.map
     echo "Preparing custom grub menu..."
     echo "default 0" > /boot/grub/menu.lst
     echo "timeout 30" >> /boot/grub/menu.lst
-- 
2.1.4



  parent reply	other threads:[~2015-06-16  8:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-16  6:13 [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
2015-06-16  6:13 ` [PATCH v2 01/11] image-live: Set syslinux timeout to 5s Ed Bartosh
2015-06-16  6:13 ` [PATCH v2 02/11] initramfs-live-install: Add blkid to initramfs Ed Bartosh
2015-06-16  6:13 ` [PATCH v2 03/11] busybox: Enable UUID-related options Ed Bartosh
2015-06-16  6:13 ` [PATCH v2 04/11] init-install-efi: Implement UUID support Ed Bartosh
2015-06-16  6:13 ` [PATCH v2 05/11] init-install: Use GPT table with GRUB 2 Ed Bartosh
2015-06-16  6:13 ` Ed Bartosh [this message]
2015-06-16  6:13 ` [PATCH v2 07/11] init-install: Specify filesystem type in parted command line Ed Bartosh
2015-06-16  6:13 ` [PATCH v2 08/11] init-install: Specify partition name " Ed Bartosh
2015-06-16  6:13 ` [PATCH v2 09/11] init-install: code cleanup: Replace tabs with spaces Ed Bartosh
2015-06-16  6:13 ` [PATCH v2 10/11] init-install: code cleanup: replace /dev/$device -> $device Ed Bartosh
2015-06-16  6:13 ` [PATCH v2 11/11] init-install: Properly delete partition table Ed Bartosh

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=1434435234-4892-7-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.