From 261af90a7aad0a72c776235b462fa8d1bf312679 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Thu, 5 Nov 2015 16:38:55 +0000 Subject: Exclude dev, proc, sys and run from mksquashfs --- vmdebootstrap/filesystem.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'vmdebootstrap') diff --git a/vmdebootstrap/filesystem.py b/vmdebootstrap/filesystem.py index df3e7b5..a26145c 100644 --- a/vmdebootstrap/filesystem.py +++ b/vmdebootstrap/filesystem.py @@ -24,6 +24,7 @@ import os import cliapp import logging +import tempfile from vmdebootstrap.base import ( Base, runcmd, @@ -181,10 +182,18 @@ class Filesystem(Base): suffixed = os.path.join(self.settings['squash'], "filesystem.squashfs") if os.path.exists(suffixed): os.unlink(suffixed) + _, exclusions = tempfile.mkstemp() + with open(exclusions, 'w') as exclude: + exclude.write("/proc\n") + exclude.write("/dev\n") + exclude.write("/sys\n") + exclude.write("/run\n") self.message("Running mksquashfs on rootfs.") msg = runcmd( ['mksquashfs', self.devices['rootdir'], suffixed, - '-no-progress', '-comp', 'xz'], ignore_fail=False) + '-no-progress', '-comp', 'xz', + '-e', exclusions], ignore_fail=False) + os.unlink(exclusions) logging.debug(msg) check_size = os.path.getsize(suffixed) logging.debug("Created squashfs: %s", suffixed) -- cgit v1.2.1