Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
a239a5: - create rootfs.meta data file which includes info...
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Marcus Schäfer  
View profile  
 More options May 4 2012, 5:26 am
From: Marcus Schäfer <m...@suse.de>
Date: Fri, 04 May 2012 02:26:03 -0700
Local: Fri, May 4 2012 5:26 am
Subject: [openSUSE/kiwi] a239a5: - create rootfs.meta data file which includes info...

  Branch: refs/heads/master
  Home:   https://github.com/openSUSE/kiwi
  Commit: a239a59649452834e1d1208bb543b9bc6a38bfb9
      https://github.com/openSUSE/kiwi/commit/a239a59649452834e1d1208bb543b...
  Author: Marcus Schäfer <m...@suse.de>
  Date:   2012-05-04 (Fri, 04 May 2012)

  Changed paths:
    M modules/KIWIImage.pm
    M modules/KIWILinuxRC.sh

  Log Message:
  -----------
  - create rootfs.meta data file which includes information about
  the required min size and (good) inode value for split systems.
  This prevents the initrd code from getting that information out
  of the rootfs.tar tarball and thus speeds up the boot

diff --git a/modules/KIWIImage.pm b/modules/KIWIImage.pm
index eb6722f..4f3d001 100644
--- a/modules/KIWIImage.pm
+++ b/modules/KIWIImage.pm
@@ -2158,12 +2158,14 @@ sub createImageSplit {
        my $kiwi = $this->{kiwi};
        my $cmdL = $this->{cmdL};
        my $arch = $this->{arch};
-       my $imageTree = $this->{imageTree};
-       my $baseSystem= $this->{baseSystem};
-       my $checkBase = $cmdL->getRootTargetDir()."/".$baseSystem;
-       my $sxml = $this->{xml};
-       my $idest= $cmdL->getImageTargetDir();
-       my %xenc = $sxml->getXenConfig();
+       my $imageTree  = $this->{imageTree};
+       my $baseSystem = $this->{baseSystem};
+       my $checkBase  = $cmdL->getRootTargetDir()."/".$baseSystem;
+       my $sxml       = $this->{xml};
+       my $idest      = $cmdL->getImageTargetDir();
+       my %xenc       = $sxml->getXenConfig();
+       my $fsopts     = $cmdL -> getFilesystemOptions();
+       my $inodesize  = $fsopts->[1];
        my $FSTypeRW;
        my $FSTypeRO;
        my $error;
@@ -2182,6 +2184,8 @@ sub createImageSplit {
        my $name;
        my $treebase;
        my $xendomain;
+       my $minInodes;
+       my $sizeBytes;
        #==========================================
        # check for xen domain setup
        #------------------------------------------
@@ -2471,11 +2475,44 @@ sub createImageSplit {
                }
        }
        #==========================================
-       # Embed tmp extend into ro extend
+       # Embed rootfs meta data into ro extend
+       #------------------------------------------
+       $minInodes = qxx ("find $imageTreeTmp | wc -l");
+       $sizeBytes = qxx ("du -s --block-size=1 $imageTreeTmp | cut -f1");
+       $sizeBytes+= $minInodes * $inodesize;
+       $sizeBytes = sprintf ("%.0f", $sizeBytes);
+       $minInodes*= 2;
+       if (open (my $FD,">$imageTree/rootfs.meta")) {
+               print $FD "inode_nr=$minInodes\n";
+               print $FD "min_size=$sizeBytes\n";
+               close $FD;
+       } else {
+               $kiwi -> error  ("Failed to create rootfs meta data: $!");
+               $kiwi -> failed ();
+               qxx ("rm -rf $imageTreeRW");
+               qxx ("rm -rf $imageTreeTmp");
+               qxx ("rm -rf $imageTree");
+               return;
+       }
+       #==========================================
+       # Embed rootfs.tar for tmpfs into ro extend
+       #------------------------------------------
+       $data = qxx (
+               "cd $imageTreeTmp && tar -cf $imageTree/rootfs.tar * 2>&1"
+       );
+       $code = $? >> 8;
+       if ($code != 0) {
+               $kiwi -> error  ("Failed to create rootfs tarball: $data");
+               $kiwi -> failed ();
+               qxx ("rm -rf $imageTreeRW");
+               qxx ("rm -rf $imageTreeTmp");
+               qxx ("rm -rf $imageTree");
+               return;
+       }
+       #==========================================
+       # Clean rootfs tmp tree
        #------------------------------------------
-       qxx ("cd $imageTreeTmp && tar cvf $imageTree/rootfs.tar * 2>&1");
        qxx ("rm -rf $imageTreeTmp");
-
        #==========================================
        # Count disk space for extends
        #------------------------------------------
diff --git a/modules/KIWILinuxRC.sh b/modules/KIWILinuxRC.sh
index 42ff8e9..1532ca4 100644
--- a/modules/KIWILinuxRC.sh
+++ b/modules/KIWILinuxRC.sh
@@ -4267,32 +4267,6 @@ function validateSize {
        return 1
 }
 #======================================
-# validateTarSize
-#--------------------------------------
-function validateTarSize {
-       # /.../
-       # this function requires a destination directory which
-       # could be a tmpfs mount and a compressed tar source file.
-       # The function will then check if the tar file could be
-       # unpacked according to the size of the destination
-       # ----
-       local tsrc=$1
-       local haveKByte=0
-       local haveMByte=0
-       local needBytes=0
-       local needMByte=0
-       haveKByte=`cat /proc/meminfo | grep MemFree | cut -f2 -d: | cut -f1 -dk`
-       haveMByte=`expr $haveKByte / 1024`
-       needBytes=`du --bytes $tsrc | cut -f1`
-       needMByte=`expr $needBytes / 1048576`
-       Echo "Have size: proc/meminfo -> $haveMByte MB"
-       Echo "Need size: $tsrc -> $needMByte MB [ uncompressed ]"
-       if [ "$haveMByte" -gt "$needMByte" ];then
-               return 0
-       fi
-       return 1
-}
-#======================================
 # validateBlockSize
 #--------------------------------------
 function validateBlockSize {
@@ -4703,7 +4677,12 @@ function mountSystemCombined {
        local rwDevice
        local options
        local rootfs
-       local inr
+       local meta
+       local inode_nr
+       local min_size
+       local haveKByte
+       local haveMByte
+       local needMByte
        if [ "$haveLuks" = "yes" ]; then
                rwDevice="/dev/mapper/luksReadWrite"
        elif [ "$haveLVM" = "yes" ]; then
@@ -4731,15 +4710,27 @@ function mountSystemCombined {
                umount "$roDevice" &>/dev/null
                return 1
        fi
+       meta=/read-only/rootfs.meta
+       if [ ! -f $inodes ];then
+               Echo "Can't find rootfs meta data"
+               umount "$roDevice" &>/dev/null
+               return 1
+       fi
        # /.../
-       # count inode numbers for files in rootfs tarball
+       # source rootfs meta data variables:
+       # => min_size # minimum required tmpfs size in bytes
+       # => inode_nr # number of inodes
        # ----
-       inr=$(tar -tf $rootfs | wc -l)
-       inr=$((inr * 2))
+       source $meta
        # /.../
        # check if rootfs tarball fits into memory
        # ----
-       if ! validateTarSize $rootfs;then
+       haveKByte=$(cat /proc/meminfo | grep MemFree | cut -f2 -d: | cut -f1 -dk)
+       haveMByte=$((haveKByte / 1024))
+       needMByte=$((min_size  / 1048576))
+       Echo "Have size: proc/meminfo -> $haveMByte MB"
+       Echo "Need size: $rootfs -> $needMByte MB"
+       if [ "$haveMByte" -lt "$needMByte" ];then
                systemException \
                        "Not enough RAM space available for temporary data" \
                "reboot"
@@ -4747,7 +4738,7 @@ function mountSystemCombined {
        # /.../
        # mount tmpfs, reserve max $splitroot_size for the rootfs data
        # ----
-       options="size=${splitroot_size}M,nr_inodes=$inr"
+       options="size=${splitroot_size}M,nr_inodes=$inode_nr"
        if ! mount -t tmpfs tmpfs -o $options /mnt;then
                systemException \
                        "Failed to mount root tmpfs" \

================================================================


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »