From 04f9e36adff1f1c00e77a12f79ddfa00f627c29e Mon Sep 17 00:00:00 2001 From: Dongjin Kim Date: Sun, 21 Jan 2024 00:14:26 +0900 Subject: [PATCH] functions/fixups: edit /etc/fstab when it exists Signed-off-by: Dongjin Kim Change-Id: I5b8054b8951f16ba48da4cacdab5f7af23f91f1c --- fixups/S90-fstab | 12 +++++++----- functions | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/fixups/S90-fstab b/fixups/S90-fstab index a6aa4ad..a64b24f 100755 --- a/fixups/S90-fstab +++ b/fixups/S90-fstab @@ -1,7 +1,12 @@ #!/bin/sh -sed -i "/ \/boot /d" /etc/fstab -sed -i "/ \/ /d" /etc/fstab +if [ -f /etc/fstab ]; then + # Remove BOOT/ROOTFS mount points + sed -i "/ \/boot /d" /etc/fstab + sed -i "/ \/ /d" /etc/fstab + # Remove EFI partition not to mount + sed -i "/\/boot\/efi/d" /etc/fstab +fi if [ "x@@DEFAULT_DEV_ROOTFS@@" != "x" ]; then cat <<__EOF | tee -a /etc/fstab >/dev/null @@ -15,7 +20,4 @@ UUID="@@DEFAULT_DEV_BOOT@@" /boot ext2 rw,relatime,errors=continue 0 0 __EOF fi -# Remove EFI partition not to mount -sed -i "/\/boot\/efi/d" /etc/fstab - update-initramfs -u diff --git a/functions b/functions index 4427e6c..1eb22fd 100644 --- a/functions +++ b/functions @@ -242,7 +242,10 @@ do_mount() { } get_uuid_by_path() { - grep " ${1} " ${rootfs_mnt}/etc/fstab | cut -d' ' -f1 | cut -d'=' -f2 | tr -d '"' + if [ -f ${rootfs_mnt}/etc/fstab ]; then + grep " ${1} " ${rootfs_mnt}/etc/fstab \ + | cut -d' ' -f1 | cut -d'=' -f2 | tr -d '"' + fi } do_create_squashfs() {