Parcourir la source

Speed up initial /rw setup

On first VM's boot, setup-rwdev.sh script create filesystem on
/dev/xvdb. But it does so only after checking if /dev/xvdb is really
empty, by comparing it to /dev/zero. Speed up reads from /dev/zero bu
using larger blocks (default of head - 8k, instead of explicit 512).
This speed up the check over 5 times.
Marek Marczykowski-Górecki il y a 6 ans
Parent
commit
1781568d08
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  1. 1 1
      init/setup-rwdev.sh

+ 1 - 1
init/setup-rwdev.sh

@@ -9,7 +9,7 @@ if [ -e "$dev" ] ; then
 
     # check if private.img (xvdb) is empty - all zeros
     private_size_512=$(blockdev --getsz "$dev")
-    if dd if=/dev/zero bs=512 count="$private_size_512" 2>/dev/null | diff "$dev" - >/dev/null; then
+    if head -c $(( private_size_512 * 512 )) /dev/zero | diff "$dev" - >/dev/null; then
         # the device is empty, create filesystem
         echo "Virgin boot of the VM: creating private.img filesystem on $dev" >&2
         if ! content=$(mkfs.ext4 -m 0 -q "$dev" 2>&1) ; then