From 2ac26880f139100d337be13b781e4dfa7e81a2d3 Mon Sep 17 00:00:00 2001 From: Anton Midyukov Date: Tue, 10 Sep 2019 02:56:41 +0700 Subject: [PATCH] tar2fs: avoid duplicate fstab entry This commit fixes duplication of root device entry in /etc/fstab and changes LABEL=ROOT entry with the proper one if found. Apparently this didn't hurt qemu images much though... --- bin/tar2fs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/tar2fs b/bin/tar2fs index 21611acd..8436ee20 100755 --- a/bin/tar2fs +++ b/bin/tar2fs @@ -224,7 +224,11 @@ tar -C "$ROOTFS" --numeric-owner -xf "$TAR" for i in /dev /proc /sys; do mount --bind "$i" "$ROOTFS$i"; done # loop device so lilo could work... -echo "$ROOTDEV / $ROOTFSTYPE relatime 1 1" >> "$ROOTFS/etc/fstab" +if grep -qe "[[:space:]]/[[:space:]]" "$ROOTFS/etc/fstab"; then \ + sed -i "s/LABEL=ROOT/$ROOTDEV/" "$ROOTFS/etc/fstab" +else + echo "$ROOTDEV / $ROOTFSTYPE relatime 1 1" >> "$ROOTFS/etc/fstab" +fi # target device at once if [ -n "$BOOTPART" ]; then