From d8c221959cd4ff00c524af7bb890fa097323bbbe Mon Sep 17 00:00:00 2001 From: marian-pritsak Date: Thu, 16 Feb 2017 21:23:26 +0200 Subject: [PATCH] [installer]: limit size of /var/log Create loop device during installation of size soecified in config file for machine Signed-off-by: marian-pritsak --- files/initramfs-tools/union-mount.j2 | 2 ++ installer/x86_64/install.sh | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/files/initramfs-tools/union-mount.j2 b/files/initramfs-tools/union-mount.j2 index 037a9c240333..2ff58ec949f9 100644 --- a/files/initramfs-tools/union-mount.j2 +++ b/files/initramfs-tools/union-mount.j2 @@ -18,3 +18,5 @@ mount --bind ${rootmnt}/host/{{ DOCKERFS_DIR }} ${rootmnt}/var/lib/docker ## Mount the boot directory in the raw partition, bypass the aufs mkdir -p ${rootmnt}/boot mount --bind ${rootmnt}/host/boot ${rootmnt}/boot +## Mount loop device for /var/log +[ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && mount -t ext4 -o loop,rw ${rootmnt}/host/disk-img/var-log.ext4 ${rootmnt}/var/log diff --git a/installer/x86_64/install.sh b/installer/x86_64/install.sh index 2ff663c188eb..0d2d76a2cd9e 100755 --- a/installer/x86_64/install.sh +++ b/installer/x86_64/install.sh @@ -51,6 +51,10 @@ CONSOLE_SPEED=9600 # Get platform specific linux kernel command line arguments ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="" + +# Default var/log device size in MB +VAR_LOG_SIZE=4096 + [ -r platforms/$onie_platform ] && source platforms/$onie_platform # Install demo on same block device as ONIE @@ -401,6 +405,13 @@ if [ -f $demo_mnt/$FILESYSTEM_DOCKERFS ]; then cd $demo_mnt && mkdir -p $DOCKERFS_DIR && tar xf $FILESYSTEM_DOCKERFS -C $DOCKERFS_DIR; cd $OLDPWD fi +# Create loop device for /var/log to limit its size to $VAR_LOG_SIZE MB +if [ "$VAR_LOG_SIZE" != "0" ]; then + mkdir -p $demo_mnt/disk-img + dd if=/dev/zero of=$demo_mnt/disk-img/var-log.ext4 count=$((2048*$VAR_LOG_SIZE)) + mkfs.ext4 -q $demo_mnt/disk-img/var-log.ext4 -F +fi + # Store machine description in target file system cp /etc/machine.conf $demo_mnt