Support the btrfs filesystem mount for the rootfs image 74/222374/1 accepted/tizen/unified/20200116.102958 submit/tizen/20200116.075025
authorJunghoon Kim <jhoon20.kim@samsung.com>
Tue, 14 Jan 2020 06:13:03 +0000 (15:13 +0900)
committerJunghoon Kim <jhoon20.kim@samsung.com>
Tue, 14 Jan 2020 06:22:56 +0000 (15:22 +0900)
In order to support the btrfs rootfs image, the btrfs tool is required.
Also, the procedure of the rootfs mount is modified properly including
the consistency check and resize.

Change-Id: I7e39720dee943830d959c8d1d6f7e8fab139904f
Signed-off-by: Junghoon Kim <jhoon20.kim@samsung.com>
data/initrd-file.list
packaging/initrd.spec
scripts/init.sh

index bf2933f15be713eb78395cf455393f45a16b0cc8..a8fc00d6b8ac123a895979b554a69f3d9ab9b9aa 100644 (file)
@@ -30,6 +30,7 @@ PROGS="
 /sbin/fsck
 /sbin/fsck.ext4
 /sbin/resize2fs
+/sbin/btrfs
 /etc/blkid.conf
 "
 
index baff86e3cbb95de22daa80e1ddfc1765df0e341d..4787705aa3910c5dfd153627d5ada2d49b7e567b 100644 (file)
@@ -15,6 +15,7 @@ Requires(post): grep
 Requires(post): coreutils
 Requires(post): util-linux
 Requires(post): e2fsprogs
+Requires(post): btrfs-progs
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
index 60235e244774c6a0a89b2f3d7ee40b9e8b5a32e8..dd1fbebc5ca93ca464c24c02434d1b09b2a6c847 100755 (executable)
@@ -53,13 +53,25 @@ fi
 
 if [ x$ROOTFS != "x" ]
 then
-    if [ "$NEED_RESIZEFS" = "1" ]
-    then
-        /sbin/fsck -y $ROOTFS
-        /sbin/resize2fs -f $ROOTFS
-    fi
-    /sbin/fsck -y $ROOTFS
-    /bin/mount $ROOTFS /sysroot -o rw
+       BTRFS_ROOTFS=`/sbin/blkid $ROOTFS -t TYPE=btrfs -o device`
+       if [ x$BTRFS_ROOTFS != "x" ]
+       then
+               /sbin/btrfs check $ROOTFS
+               /bin/mount $ROOTFS /sysroot -o rw,compress=zstd
+               if [ "$NEED_RESIZEFS" = "1" ]
+               then
+                       /sbin/btrfs filesystem resize max /sysroot
+                       /sbin/btrfs balance start -v -f -mconvert=single /sysroot
+               fi
+       else
+               if [ "$NEED_RESIZEFS" = "1" ]
+               then
+                       /sbin/fsck -y $ROOTFS
+                       /sbin/resize2fs -f $ROOTFS
+               fi
+               /sbin/fsck -y $ROOTFS
+               /bin/mount $ROOTFS /sysroot -o rw
+       fi
 else
     echo "WARNING : THERE IS NO ROOTFS."
     exec /bin/sh