All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install)
@ 2015-06-16  6:13 Ed Bartosh
  2015-06-16  6:13 ` [PATCH v2 01/11] image-live: Set syslinux timeout to 5s Ed Bartosh
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

Hi,

This patchet adds support of GPT partition table and
UUID support to initramfs installer scripts.

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.

Implementation details:
    Used partition UUID in kernel command line to specify root partition.
    Used partition UUID in /etc/fstab to specify swap partition.
    Used filesystem UUID in /etc/fstab to specify boot partition.

Code cleanup and usability fixes were done along the way. They're also
included into this patchset.

Patchest was tested on NUC device in both EFI and non-EFI modes.

See more details in [YOCTO #6101]

NOTE: Please drop the following pending patches as they're included into the patchset:
    [OE-core] [PATCH] image-live: Set syslinux timeout to 5s
    [OE-core] [PATCH] initramfs-live-install: Add gptdisk to initramfs
    [OE-core] [PATCH] init-install-efi: Implement UUID support

Ed Bartosh (11):
  image-live: Set syslinux timeout to 5s
  initramfs-live-install: Add blkid to initramfs
  busybox: Enable UUID-related options
  init-install-efi: Implement UUID support
  init-install: Use GPT table with GRUB 2
  init-install: Implement UUID support
  init-install: Specify filesystem type in parted command line
  init-install: Specify partition name in parted command line
  init-install: code cleanup: Replace tabs with spaces
  init-install: code cleanup: replace /dev/$device -> $device
  init-install: Properly delete partition table

 meta/classes/image-live.bbclass                    |   2 +-
 meta/recipes-core/busybox/busybox/defconfig        |   8 +-
 .../initrdscripts/files/init-install-efi.sh        |  90 ++++++------
 .../initrdscripts/files/init-install.sh            | 151 +++++++++++++--------
 .../initramfs-live-install-efi_1.0.bb              |   2 +-
 .../initrdscripts/initramfs-live-install_1.0.bb    |   2 +-
 6 files changed, 149 insertions(+), 106 deletions(-)

--
Ed



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 01/11] image-live: Set syslinux timeout to 5s
  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 ` Ed Bartosh
  2015-06-16  6:13 ` [PATCH v2 02/11] initramfs-live-install: Add blkid to initramfs Ed Bartosh
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

Increased syslinux timeout to 5s as default 1s timeout
is not enough to notice syslinux prompt on some devices.

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

diff --git a/meta/classes/image-live.bbclass b/meta/classes/image-live.bbclass
index 7b770fb..52b6de7 100644
--- a/meta/classes/image-live.bbclass
+++ b/meta/classes/image-live.bbclass
@@ -3,7 +3,7 @@ AUTO_SYSLINUXCFG = "1"
 INITRD_IMAGE ?= "core-image-minimal-initramfs"
 INITRD ?= "${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}-${MACHINE}.cpio.gz"
 SYSLINUX_ROOT = "root=/dev/ram0"
-SYSLINUX_TIMEOUT ?= "10"
+SYSLINUX_TIMEOUT ?= "50"
 SYSLINUX_LABELS ?= "boot install"
 LABELS_append = " ${SYSLINUX_LABELS} "
 
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 02/11] initramfs-live-install: Add blkid to initramfs
  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 ` Ed Bartosh
  2015-06-16  6:13 ` [PATCH v2 03/11] busybox: Enable UUID-related options Ed Bartosh
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

Added util-linux-blkid to the list of dependencies of
initramfs-live-install and initramfs-live-install-efi.

This is a part of the work to support partiion UUID in installer.
blkid is going to be used to get partition and filesystem UUIDs.

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

diff --git a/meta/recipes-core/initrdscripts/initramfs-live-install-efi_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-live-install-efi_1.0.bb
index b0994d7..32c1fce 100644
--- a/meta/recipes-core/initrdscripts/initramfs-live-install-efi_1.0.bb
+++ b/meta/recipes-core/initrdscripts/initramfs-live-install-efi_1.0.bb
@@ -5,7 +5,7 @@ SRC_URI = "file://init-install-efi.sh"
 
 PR = "r1"
 
-RDEPENDS_${PN} = "parted e2fsprogs-mke2fs dosfstools"
+RDEPENDS_${PN} = "parted e2fsprogs-mke2fs dosfstools util-linux-blkid"
 
 S = "${WORKDIR}"
 
diff --git a/meta/recipes-core/initrdscripts/initramfs-live-install_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-live-install_1.0.bb
index 6241a90..88b3b30 100644
--- a/meta/recipes-core/initrdscripts/initramfs-live-install_1.0.bb
+++ b/meta/recipes-core/initrdscripts/initramfs-live-install_1.0.bb
@@ -7,7 +7,7 @@ PR = "r9"
 
 S = "${WORKDIR}"
 
-RDEPENDS_${PN} = "grub parted e2fsprogs-mke2fs"
+RDEPENDS_${PN} = "grub parted e2fsprogs-mke2fs util-linux-blkid"
 
 do_install() {
         install -m 0755 ${WORKDIR}/init-install.sh ${D}/install.sh
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 03/11] busybox: Enable UUID-related options
  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 ` Ed Bartosh
  2015-06-16  6:13 ` [PATCH v2 04/11] init-install-efi: Implement UUID support Ed Bartosh
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

Enabled MOUNT_LABEL and VOLUMEID* features for busybox
mount to understand 'UUID=' syntax in fstab.

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

diff --git a/meta/recipes-core/busybox/busybox/defconfig b/meta/recipes-core/busybox/busybox/defconfig
index c200ee0..468c40e 100644
--- a/meta/recipes-core/busybox/busybox/defconfig
+++ b/meta/recipes-core/busybox/busybox/defconfig
@@ -582,7 +582,7 @@ CONFIG_MOUNT=y
 # CONFIG_FEATURE_MOUNT_FAKE is not set
 # CONFIG_FEATURE_MOUNT_VERBOSE is not set
 # CONFIG_FEATURE_MOUNT_HELPERS is not set
-# CONFIG_FEATURE_MOUNT_LABEL is not set
+CONFIG_FEATURE_MOUNT_LABEL=y
 CONFIG_FEATURE_MOUNT_NFS=y
 # CONFIG_FEATURE_MOUNT_CIFS is not set
 CONFIG_FEATURE_MOUNT_FLAGS=y
@@ -607,11 +607,11 @@ CONFIG_FEATURE_UMOUNT_ALL=y
 CONFIG_FEATURE_MOUNT_LOOP=y
 CONFIG_FEATURE_MOUNT_LOOP_CREATE=y
 # CONFIG_FEATURE_MTAB_SUPPORT is not set
-# CONFIG_VOLUMEID is not set
-# CONFIG_FEATURE_VOLUMEID_EXT is not set
+CONFIG_VOLUMEID=y
+CONFIG_FEATURE_VOLUMEID_EXT=y
 # CONFIG_FEATURE_VOLUMEID_BTRFS is not set
 # CONFIG_FEATURE_VOLUMEID_REISERFS is not set
-# CONFIG_FEATURE_VOLUMEID_FAT is not set
+CONFIG_FEATURE_VOLUMEID_FAT=y
 # CONFIG_FEATURE_VOLUMEID_HFS is not set
 # CONFIG_FEATURE_VOLUMEID_JFS is not set
 # CONFIG_FEATURE_VOLUMEID_XFS is not set
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 04/11] init-install-efi: Implement UUID support
  2015-06-16  6:13 [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
                   ` (2 preceding siblings ...)
  2015-06-16  6:13 ` [PATCH v2 03/11] busybox: Enable UUID-related options Ed Bartosh
@ 2015-06-16  6:13 ` Ed Bartosh
  2015-06-16  6:13 ` [PATCH v2 05/11] init-install: Use GPT table with GRUB 2 Ed Bartosh
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

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 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-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index 8dd2749..5fb4d4d 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -164,8 +164,10 @@ 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
+    boot_uuid=$(blkid -o value -s UUID /dev/${device}1)
+    swap_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}3)
+    echo "/dev/disk/by-partuuid/$swap_part_uuid                swap             swap       defaults              0  0" >> /tgt_root/etc/fstab
+    echo "UUID=$boot_uuid              /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
@@ -184,6 +186,7 @@ mkdir -p $EFIDIR
 cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR
 
 if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
+    root_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}2)
     GRUBCFG="$EFIDIR/grub.cfg"
     cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG
     # Update grub config for the installed image
@@ -196,7 +199,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=$root_part_uuid rw $rootwait quiet @" $GRUBCFG
 fi
 
 if [ -d /run/media/$1/loader ]; then
@@ -212,7 +215,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



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 05/11] init-install: Use GPT table with GRUB 2
  2015-06-16  6:13 [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
                   ` (3 preceding siblings ...)
  2015-06-16  6:13 ` [PATCH v2 04/11] init-install-efi: Implement UUID support Ed Bartosh
@ 2015-06-16  6:13 ` Ed Bartosh
  2015-06-16  6:13 ` [PATCH v2 06/11] init-install: Implement UUID support Ed Bartosh
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

Changed partition type from 'msdos' to 'gpt'.
Added special partition for grub stage2 bootloader.

NOTE: This is done only for GRUB 2 as legacy GRUB is
rarely used and doesn't support GPT partitions.

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 cb26163..298ea8d 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -106,10 +106,21 @@ fi
 
 disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
 
+grub_version=$(grub-install -v|sed 's/.* \([0-9]\).*/\1/')
+
+if [ $grub_version -eq 0 ] ; then
+    bios_boot_size=0
+else
+    # For GRUB 2 we need separate parition to store stage2 grub image
+    # 2Mb value is chosen to align partition for best performance.
+    bios_boot_size=2
+fi
+
 swap_size=$((disk_size*swap_ratio/100))
-rootfs_size=$((disk_size-boot_size-swap_size))
+rootfs_size=$((disk_size-bios_boot_size-boot_size-swap_size))
 
-rootfs_start=$((boot_size))
+boot_start=$((bios_boot_size))
+rootfs_start=$((bios_boot_size+boot_size))
 rootfs_end=$((rootfs_start+rootfs_size))
 swap_start=$((rootfs_end))
 
@@ -122,11 +133,21 @@ if [ ! "${device#mmcblk}" = "${device}" ]; then
 	part_prefix="p"
 	rootwait="rootwait"
 fi
-bootfs=/dev/${device}${part_prefix}1
-rootfs=/dev/${device}${part_prefix}2
-swap=/dev/${device}${part_prefix}3
+
+if [ $grub_version -eq 0 ] ; then
+    bios_boot=''
+    bootfs=/dev/${device}${part_prefix}1
+    rootfs=/dev/${device}${part_prefix}2
+    swap=/dev/${device}${part_prefix}3
+else
+    bios_boot=/dev/${device}${part_prefix}1
+    bootfs=/dev/${device}${part_prefix}2
+    rootfs=/dev/${device}${part_prefix}3
+    swap=/dev/${device}${part_prefix}4
+fi
 
 echo "*****************"
+[ $grub_version -ne 0 ] && echo "BIOS boot partition size: $bios_boot_size MB ($bios_boot)"
 echo "Boot partition size:   $boot_size MB ($bootfs)"
 echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
 echo "Swap partition size:   $swap_size MB ($swap)"
@@ -135,10 +156,18 @@ echo "Deleting partition table on /dev/${device} ..."
 dd if=/dev/zero of=/dev/${device} bs=512 count=2
 
 echo "Creating new partition table on /dev/${device} ..."
-parted /dev/${device} mklabel msdos
-
-echo "Creating boot partition on $bootfs"
-parted /dev/${device} mkpart primary 0% $boot_size
+if [ $grub_version -eq 0 ] ; then
+    parted /dev/${device} mktable msdos
+    echo "Creating boot partition on $bootfs"
+    parted /dev/${device} mkpart primary 0% $boot_size
+else
+    parted /dev/${device} mktable gpt
+    echo "Creating BIOS boot partition on $bios_boot"
+    parted /dev/${device} mkpart primary 0% $bios_boot_size
+    parted /dev/${device} set 1 bios_grub on
+    echo "Creating boot partition on $bootfs"
+    parted /dev/${device} mkpart primary $boot_start $boot_size
+fi
 
 echo "Creating rootfs partition on $rootfs"
 parted /dev/${device} mkpart primary $rootfs_start $rootfs_end
@@ -186,7 +215,7 @@ if [ -f /etc/grub.d/00_header ] ; then
     mkdir -p $(dirname $GRUBCFG)
     cat >$GRUBCFG <<_EOF
 menuentry "Linux" {
-    set root=(hd0,1)
+    set root=(hd0,2)
     linux /vmlinuz root=$rootfs $rootwait rw $5 $3 $4 quiet
 }
 _EOF
@@ -195,8 +224,7 @@ fi
 grub-install /dev/${device}
 echo "(hd0) /dev/${device}" > /boot/grub/device.map
 
-# If grub.cfg doesn't exist, assume GRUB 0.97 and create a menu.lst
-if [ ! -f /boot/grub/grub.cfg ] ; then
+if [ $grub_version -eq 0 ] ; then
     echo "Preparing custom grub menu..."
     echo "default 0" > /boot/grub/menu.lst
     echo "timeout 30" >> /boot/grub/menu.lst
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 06/11] init-install: Implement UUID support
  2015-06-16  6:13 [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
                   ` (4 preceding siblings ...)
  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
  2015-06-16  6:13 ` [PATCH v2 07/11] init-install: Specify filesystem type in parted command line Ed Bartosh
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

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



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 07/11] init-install: Specify filesystem type in parted command line
  2015-06-16  6:13 [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
                   ` (5 preceding siblings ...)
  2015-06-16  6:13 ` [PATCH v2 06/11] init-install: Implement UUID support Ed Bartosh
@ 2015-06-16  6:13 ` Ed Bartosh
  2015-06-16  6:13 ` [PATCH v2 08/11] init-install: Specify partition name " Ed Bartosh
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

Explicitly specified filesystem type for parted mkpart command.
This makes partition table to look more informative.

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

diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index 5fb4d4d..7f3e889 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -134,14 +134,14 @@ echo "Creating new partition table on /dev/${device} ..."
 parted /dev/${device} mklabel gpt
 
 echo "Creating boot partition on $bootfs"
-parted /dev/${device} mkpart primary 0% $boot_size
+parted /dev/${device} mkpart primary fat32 0% $boot_size
 parted /dev/${device} set 1 boot on
 
 echo "Creating rootfs partition on $rootfs"
-parted /dev/${device} mkpart primary $rootfs_start $rootfs_end
+parted /dev/${device} mkpart primary ext3 $rootfs_start $rootfs_end
 
 echo "Creating swap partition on $swap"
-parted /dev/${device} mkpart primary $swap_start 100%
+parted /dev/${device} mkpart primary linux-swap $swap_start 100%
 
 parted /dev/${device} print
 
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index 9957c15..10aed07 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -159,21 +159,21 @@ echo "Creating new partition table on /dev/${device} ..."
 if [ $grub_version -eq 0 ] ; then
     parted /dev/${device} mktable msdos
     echo "Creating boot partition on $bootfs"
-    parted /dev/${device} mkpart primary 0% $boot_size
+    parted /dev/${device} mkpart primary ext3 0% $boot_size
 else
     parted /dev/${device} mktable gpt
     echo "Creating BIOS boot partition on $bios_boot"
     parted /dev/${device} mkpart primary 0% $bios_boot_size
     parted /dev/${device} set 1 bios_grub on
     echo "Creating boot partition on $bootfs"
-    parted /dev/${device} mkpart primary $boot_start $boot_size
+    parted /dev/${device} mkpart primary ext3 $boot_start $boot_size
 fi
 
 echo "Creating rootfs partition on $rootfs"
-parted /dev/${device} mkpart primary $rootfs_start $rootfs_end
+parted /dev/${device} mkpart primary ext3 $rootfs_start $rootfs_end
 
 echo "Creating swap partition on $swap"
-parted /dev/${device} mkpart primary $swap_start 100%
+parted /dev/${device} mkpart primary linux-swap $swap_start 100%
 
 parted /dev/${device} print
 
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 08/11] init-install: Specify partition name in parted command line
  2015-06-16  6:13 [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
                   ` (6 preceding siblings ...)
  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 ` Ed Bartosh
  2015-06-16  6:13 ` [PATCH v2 09/11] init-install: code cleanup: Replace tabs with spaces Ed Bartosh
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

parted allows to use names for partitions if GPT partition table
is used on the device. msdos partitioning can have only partition
types: 'primary', 'logical' or 'extended'.

Used meaningful partition names in parted command line for GPT
partitioning.

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

diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index 7f3e889..a6a8679 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -134,14 +134,14 @@ echo "Creating new partition table on /dev/${device} ..."
 parted /dev/${device} mklabel gpt
 
 echo "Creating boot partition on $bootfs"
-parted /dev/${device} mkpart primary fat32 0% $boot_size
+parted /dev/${device} mkpart boot fat32 0% $boot_size
 parted /dev/${device} set 1 boot on
 
 echo "Creating rootfs partition on $rootfs"
-parted /dev/${device} mkpart primary ext3 $rootfs_start $rootfs_end
+parted /dev/${device} mkpart root ext3 $rootfs_start $rootfs_end
 
 echo "Creating swap partition on $swap"
-parted /dev/${device} mkpart primary linux-swap $swap_start 100%
+parted /dev/${device} mkpart swap linux-swap $swap_start 100%
 
 parted /dev/${device} print
 
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index 10aed07..c57a0f3 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -163,17 +163,19 @@ if [ $grub_version -eq 0 ] ; then
 else
     parted /dev/${device} mktable gpt
     echo "Creating BIOS boot partition on $bios_boot"
-    parted /dev/${device} mkpart primary 0% $bios_boot_size
+    parted /dev/${device} mkpart bios_boot 0% $bios_boot_size
     parted /dev/${device} set 1 bios_grub on
     echo "Creating boot partition on $bootfs"
-    parted /dev/${device} mkpart primary ext3 $boot_start $boot_size
+    parted /dev/${device} mkpart boot ext3 $boot_start $boot_size
 fi
 
 echo "Creating rootfs partition on $rootfs"
-parted /dev/${device} mkpart primary ext3 $rootfs_start $rootfs_end
+[ $grub_version -eq 0 ] && pname='primary' || pname='root'
+parted /dev/${device} mkpart $pname ext3 $rootfs_start $rootfs_end
 
 echo "Creating swap partition on $swap"
-parted /dev/${device} mkpart primary linux-swap $swap_start 100%
+[ $grub_version -eq 0 ] && pname='primary' || pname='swap'
+parted /dev/${device} mkpart $pname linux-swap $swap_start 100%
 
 parted /dev/${device} print
 
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 09/11] init-install: code cleanup: Replace tabs with spaces
  2015-06-16  6:13 [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
                   ` (7 preceding siblings ...)
  2015-06-16  6:13 ` [PATCH v2 08/11] init-install: Specify partition name " Ed Bartosh
@ 2015-06-16  6:13 ` 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
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

Cleaned up spaces from init-install* shell scripts.

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

diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index a6a8679..dca1432 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -24,22 +24,22 @@ echo "Searching for hard drives ..."
 
 for device in `ls /sys/block/`; do
     case $device in
-	loop*)
+        loop*)
             # skip loop device
-	    ;;
-	sr*)
+            ;;
+        sr*)
             # skip CDROM device
-	    ;;
-	ram*)
+            ;;
+        ram*)
             # skip ram device
-	    ;;
-	*)
-	    # skip the device LiveOS is on
-	    # Add valid hard drive name to the list
-	    if [ $device != $live_dev_name -a -e /dev/$device ]; then
-		hdnamelist="$hdnamelist $device"
-	    fi
-	    ;;
+            ;;
+        *)
+            # skip the device LiveOS is on
+            # Add valid hard drive name to the list
+            if [ $device != $live_dev_name -a -e /dev/$device ]; then
+                hdnamelist="$hdnamelist $device"
+            fi
+            ;;
     esac
 done
 
@@ -49,8 +49,8 @@ for hdname in $hdnamelist; do
     echo "-------------------------------"
     echo /dev/$hdname
     if [ -r /sys/block/$hdname/device/vendor ]; then
-	echo -n "VENDOR="
-	cat /sys/block/$hdname/device/vendor
+        echo -n "VENDOR="
+        cat /sys/block/$hdname/device/vendor
     fi
     if [ -r /sys/block/$hdname/device/model ]; then
         echo -n "MODEL="
@@ -63,18 +63,17 @@ for hdname in $hdnamelist; do
     echo
     # Get user choice
     while true; do
-	echo -n "Do you want to install this image there? [y/n] "
-	read answer
-	if [ "$answer" = "y" -o "$answer" = "n" ]; then
-	    break
-	fi
-	echo "Please answer y or n"
+        echo -n "Do you want to install this image there? [y/n] "
+        read answer
+        if [ "$answer" = "y" -o "$answer" = "n" ]; then
+            break
+        fi
+        echo "Please answer y or n"
     done
     if [ "$answer" = "y" ]; then
-	TARGET_DEVICE_NAME=$hdname
-	break
+        TARGET_DEVICE_NAME=$hdname
+        break
     fi
-
 done
 
 if [ -n "$TARGET_DEVICE_NAME" ]; then
@@ -170,7 +169,7 @@ if [ -d /tgt_root/etc/ ] ; then
     echo "UUID=$boot_uuid              /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
+        echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist
     fi
 fi
 
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index c57a0f3..e1e7cb1 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -23,22 +23,22 @@ echo "Searching for hard drives ..."
 
 for device in `ls /sys/block/`; do
     case $device in
-	loop*)
+        loop*)
             # skip loop device
-	    ;;
-	sr*)
+            ;;
+        sr*)
             # skip CDROM device
-	    ;;
-	ram*)
+            ;;
+        ram*)
             # skip ram device
-	    ;;
-	*)
-	    # skip the device LiveOS is on
-	    # Add valid hard drive name to the list
-	    if [ $device != $live_dev_name -a -e /dev/$device ]; then
-		hdnamelist="$hdnamelist $device"
-	    fi
-	    ;;
+            ;;
+        *)
+            # skip the device LiveOS is on
+            # Add valid hard drive name to the list
+            if [ $device != $live_dev_name -a -e /dev/$device ]; then
+                hdnamelist="$hdnamelist $device"
+            fi
+            ;;
     esac
 done
 
@@ -48,8 +48,8 @@ for hdname in $hdnamelist; do
     echo "-------------------------------"
     echo /dev/$hdname
     if [ -r /sys/block/$hdname/device/vendor ]; then
-	echo -n "VENDOR="
-	cat /sys/block/$hdname/device/vendor
+        echo -n "VENDOR="
+        cat /sys/block/$hdname/device/vendor
     fi
     if [ -r /sys/block/$hdname/device/model ]; then
         echo -n "MODEL="
@@ -62,16 +62,16 @@ for hdname in $hdnamelist; do
     echo
     # Get user choice
     while true; do
-	echo -n "Do you want to install this image there? [y/n] "
-	read answer
-	if [ "$answer" = "y" -o "$answer" = "n" ]; then
-	    break
-	fi
-	echo "Please answer y or n"
+        echo -n "Do you want to install this image there? [y/n] "
+        read answer
+        if [ "$answer" = "y" -o "$answer" = "n" ]; then
+            break
+        fi
+        echo "Please answer y or n"
     done
     if [ "$answer" = "y" ]; then
-	TARGET_DEVICE_NAME=$hdname
-	break
+        TARGET_DEVICE_NAME=$hdname
+        break
     fi
 done
 
@@ -101,7 +101,7 @@ fi
 
 mkdir -p /tmp
 if [ ! -L /etc/mtab ]; then
-	cat /proc/mounts > /etc/mtab
+    cat /proc/mounts > /etc/mtab
 fi
 
 disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
@@ -130,8 +130,8 @@ swap_start=$((rootfs_end))
 rootwait=""
 part_prefix=""
 if [ ! "${device#mmcblk}" = "${device}" ]; then
-	part_prefix="p"
-	rootwait="rootwait"
+    part_prefix="p"
+    rootwait="rootwait"
 fi
 
 if [ $grub_version -eq 0 ] ; then
@@ -211,7 +211,7 @@ if [ -d /tgt_root/etc/ ] ; then
     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
+        echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist
     fi
 fi
 umount /tgt_root
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 10/11] init-install: code cleanup: replace /dev/$device -> $device
  2015-06-16  6:13 [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
                   ` (8 preceding siblings ...)
  2015-06-16  6:13 ` [PATCH v2 09/11] init-install: code cleanup: Replace tabs with spaces Ed Bartosh
@ 2015-06-16  6:13 ` Ed Bartosh
  2015-06-16  6:13 ` [PATCH v2 11/11] init-install: Properly delete partition table Ed Bartosh
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

Shortened code by including /dev/ prefix into variable.

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

diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index dca1432..74372b0 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -83,7 +83,7 @@ else
     exit 1
 fi
 
-device=$TARGET_DEVICE_NAME
+device=/dev/$TARGET_DEVICE_NAME
 
 #
 # The udev automounter can cause pain here, kill it
@@ -94,12 +94,12 @@ rm -f /etc/udev/scripts/mount*
 #
 # Unmount anything the automounter had mounted
 #
-umount /dev/${device}* 2> /dev/null || /bin/true
+umount ${device}* 2> /dev/null || /bin/true
 
 mkdir -p /tmp
 cat /proc/mounts > /etc/mtab
 
-disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
+disk_size=$(parted ${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
 
 swap_size=$((disk_size*swap_ratio/100))
 rootfs_size=$((disk_size-boot_size-swap_size))
@@ -117,32 +117,32 @@ if [ ! "${device#mmcblk}" = "${device}" ]; then
     part_prefix="p"
     rootwait="rootwait"
 fi
-bootfs=/dev/${device}${part_prefix}1
-rootfs=/dev/${device}${part_prefix}2
-swap=/dev/${device}${part_prefix}3
+bootfs=${device}${part_prefix}1
+rootfs=${device}${part_prefix}2
+swap=${device}${part_prefix}3
 
 echo "*****************"
 echo "Boot partition size:   $boot_size MB ($bootfs)"
 echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
 echo "Swap partition size:   $swap_size MB ($swap)"
 echo "*****************"
-echo "Deleting partition table on /dev/${device} ..."
-dd if=/dev/zero of=/dev/${device} bs=512 count=2
+echo "Deleting partition table on ${device} ..."
+dd if=/dev/zero of=${device} bs=512 count=2
 
-echo "Creating new partition table on /dev/${device} ..."
-parted /dev/${device} mklabel gpt
+echo "Creating new partition table on ${device} ..."
+parted ${device} mklabel gpt
 
 echo "Creating boot partition on $bootfs"
-parted /dev/${device} mkpart boot fat32 0% $boot_size
-parted /dev/${device} set 1 boot on
+parted ${device} mkpart boot fat32 0% $boot_size
+parted ${device} set 1 boot on
 
 echo "Creating rootfs partition on $rootfs"
-parted /dev/${device} mkpart root ext3 $rootfs_start $rootfs_end
+parted ${device} mkpart root ext3 $rootfs_start $rootfs_end
 
 echo "Creating swap partition on $swap"
-parted /dev/${device} mkpart swap linux-swap $swap_start 100%
+parted ${device} mkpart swap linux-swap $swap_start 100%
 
-parted /dev/${device} print
+parted ${device} print
 
 echo "Formatting $bootfs to vfat..."
 mkfs.vfat $bootfs
@@ -163,13 +163,13 @@ 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
-    boot_uuid=$(blkid -o value -s UUID /dev/${device}1)
-    swap_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}3)
+    boot_uuid=$(blkid -o value -s UUID ${device}1)
+    swap_part_uuid=$(blkid -o value -s PARTUUID ${device}3)
     echo "/dev/disk/by-partuuid/$swap_part_uuid                swap             swap       defaults              0  0" >> /tgt_root/etc/fstab
     echo "UUID=$boot_uuid              /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
+        echo "${device}" >> /tgt_root/etc/udev/mount.blacklist
     fi
 fi
 
@@ -185,7 +185,7 @@ mkdir -p $EFIDIR
 cp /run/media/$1/EFI/BOOT/*.efi $EFIDIR
 
 if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then
-    root_part_uuid=$(blkid -o value -s PARTUUID /dev/${device}2)
+    root_part_uuid=$(blkid -o value -s PARTUUID ${device}2)
     GRUBCFG="$EFIDIR/grub.cfg"
     cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG
     # Update grub config for the installed image
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index e1e7cb1..0593b3c 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -82,7 +82,7 @@ else
     exit 1
 fi
 
-device=$TARGET_DEVICE_NAME
+device=/dev/$TARGET_DEVICE_NAME
 
 #
 # The udev automounter can cause pain here, kill it
@@ -93,7 +93,7 @@ rm -f /etc/udev/scripts/mount*
 #
 # Unmount anything the automounter had mounted
 #
-umount /dev/${device}* 2> /dev/null || /bin/true
+umount ${device}* 2> /dev/null || /bin/true
 
 if [ ! -b /dev/loop0 ] ; then
     mknod /dev/loop0 b 7 0
@@ -104,7 +104,7 @@ if [ ! -L /etc/mtab ]; then
     cat /proc/mounts > /etc/mtab
 fi
 
-disk_size=$(parted /dev/${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
+disk_size=$(parted ${device} unit mb print | grep Disk | cut -d" " -f 3 | sed -e "s/MB//")
 
 grub_version=$(grub-install -v|sed 's/.* \([0-9]\).*/\1/')
 
@@ -136,14 +136,14 @@ fi
 
 if [ $grub_version -eq 0 ] ; then
     bios_boot=''
-    bootfs=/dev/${device}${part_prefix}1
-    rootfs=/dev/${device}${part_prefix}2
-    swap=/dev/${device}${part_prefix}3
+    bootfs=${device}${part_prefix}1
+    rootfs=${device}${part_prefix}2
+    swap=${device}${part_prefix}3
 else
-    bios_boot=/dev/${device}${part_prefix}1
-    bootfs=/dev/${device}${part_prefix}2
-    rootfs=/dev/${device}${part_prefix}3
-    swap=/dev/${device}${part_prefix}4
+    bios_boot=${device}${part_prefix}1
+    bootfs=${device}${part_prefix}2
+    rootfs=${device}${part_prefix}3
+    swap=${device}${part_prefix}4
 fi
 
 echo "*****************"
@@ -152,32 +152,32 @@ echo "Boot partition size:   $boot_size MB ($bootfs)"
 echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
 echo "Swap partition size:   $swap_size MB ($swap)"
 echo "*****************"
-echo "Deleting partition table on /dev/${device} ..."
-dd if=/dev/zero of=/dev/${device} bs=512 count=2
+echo "Deleting partition table on ${device} ..."
+dd if=/dev/zero of=${device} bs=512 count=2
 
-echo "Creating new partition table on /dev/${device} ..."
+echo "Creating new partition table on ${device} ..."
 if [ $grub_version -eq 0 ] ; then
-    parted /dev/${device} mktable msdos
+    parted ${device} mktable msdos
     echo "Creating boot partition on $bootfs"
-    parted /dev/${device} mkpart primary ext3 0% $boot_size
+    parted ${device} mkpart primary ext3 0% $boot_size
 else
-    parted /dev/${device} mktable gpt
+    parted ${device} mktable gpt
     echo "Creating BIOS boot partition on $bios_boot"
-    parted /dev/${device} mkpart bios_boot 0% $bios_boot_size
-    parted /dev/${device} set 1 bios_grub on
+    parted ${device} mkpart bios_boot 0% $bios_boot_size
+    parted ${device} set 1 bios_grub on
     echo "Creating boot partition on $bootfs"
-    parted /dev/${device} mkpart boot ext3 $boot_start $boot_size
+    parted ${device} mkpart boot ext3 $boot_start $boot_size
 fi
 
 echo "Creating rootfs partition on $rootfs"
 [ $grub_version -eq 0 ] && pname='primary' || pname='root'
-parted /dev/${device} mkpart $pname ext3 $rootfs_start $rootfs_end
+parted ${device} mkpart $pname ext3 $rootfs_start $rootfs_end
 
 echo "Creating swap partition on $swap"
 [ $grub_version -eq 0 ] && pname='primary' || pname='swap'
-parted /dev/${device} mkpart $pname linux-swap $swap_start 100%
+parted ${device} mkpart $pname linux-swap $swap_start 100%
 
-parted /dev/${device} print
+parted ${device} print
 
 echo "Formatting $bootfs to ext3..."
 mkfs.ext3 $bootfs
@@ -211,7 +211,7 @@ if [ -d /tgt_root/etc/ ] ; then
     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
+        echo "${device}" >> /tgt_root/etc/udev/mount.blacklist
     fi
 fi
 umount /tgt_root
@@ -222,8 +222,8 @@ mount $bootfs /boot
 echo "Preparing boot partition..."
 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)
+    root_part_uuid=$(blkid -o value -s PARTUUID ${device}3)
+    boot_uuid=$(blkid -o value -s UUID ${device}2)
     GRUBCFG="/boot/grub/grub.cfg"
     mkdir -p $(dirname $GRUBCFG)
     cat >$GRUBCFG <<_EOF
@@ -234,10 +234,10 @@ menuentry "Linux" {
 _EOF
     chmod 0444 $GRUBCFG
 fi
-grub-install /dev/${device}
+grub-install ${device}
 
 if [ $grub_version -eq 0 ] ; then
-    echo "(hd0) /dev/${device}" > /boot/grub/device.map
+    echo "(hd0) ${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



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 11/11] init-install: Properly delete partition table
  2015-06-16  6:13 [PATCH v2 00/11] UUID support in installer (poky-contrib: ed/oe-core/uuid-init-install) Ed Bartosh
                   ` (9 preceding siblings ...)
  2015-06-16  6:13 ` [PATCH v2 10/11] init-install: code cleanup: replace /dev/$device -> $device Ed Bartosh
@ 2015-06-16  6:13 ` Ed Bartosh
  10 siblings, 0 replies; 12+ messages in thread
From: Ed Bartosh @ 2015-06-16  6:13 UTC (permalink / raw)
  To: openembedded-core

Fixed deletion of the partition table by increasing
amount of sectors from 2(correct for msdos PT) to 35 as
GPT size is 34 sectors + 1 sector for protective MBR.

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

diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index 74372b0..14939ac 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -127,7 +127,7 @@ echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
 echo "Swap partition size:   $swap_size MB ($swap)"
 echo "*****************"
 echo "Deleting partition table on ${device} ..."
-dd if=/dev/zero of=${device} bs=512 count=2
+dd if=/dev/zero of=${device} bs=512 count=35
 
 echo "Creating new partition table on ${device} ..."
 parted ${device} mklabel gpt
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index 0593b3c..7fccdde 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -153,7 +153,7 @@ echo "Rootfs partition size: $rootfs_size MB ($rootfs)"
 echo "Swap partition size:   $swap_size MB ($swap)"
 echo "*****************"
 echo "Deleting partition table on ${device} ..."
-dd if=/dev/zero of=${device} bs=512 count=2
+dd if=/dev/zero of=${device} bs=512 count=35
 
 echo "Creating new partition table on ${device} ..."
 if [ $grub_version -eq 0 ] ; then
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-06-16  8:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2 06/11] init-install: Implement UUID support Ed Bartosh
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

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.