From 7bad45cf0c03475c67196229ae7711021bf69486 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 4 Apr 2016 17:32:05 +0200 Subject: [packager] some improvements for stage4 stuff [wip] --- packager/.gitignore | 1 + packager/blacklists/essential/linux-base | 2 +- packager/blacklists/essential/linux-extended | 4 ++-- packager/openslx.config | 2 +- packager/openslx.functions | 20 ++++++++++++++------ 5 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 packager/.gitignore (limited to 'packager') diff --git a/packager/.gitignore b/packager/.gitignore new file mode 100644 index 00000000..b205ba3d --- /dev/null +++ b/packager/.gitignore @@ -0,0 +1 @@ +builds/* diff --git a/packager/blacklists/essential/linux-base b/packager/blacklists/essential/linux-base index 54e9c294..2c3ec439 100644 --- a/packager/blacklists/essential/linux-base +++ b/packager/blacklists/essential/linux-base @@ -1,4 +1,3 @@ -- /boot/* - /cdrom/* - /dev/* - /adm/* @@ -68,6 +67,7 @@ #- /var/spool/** + /var/spool/torque/* - /var/tmp/* ++ /var/tmp/*guestfs* - /var/lib/nova/instances/* - /var/lib/libvirt diff --git a/packager/blacklists/essential/linux-extended b/packager/blacklists/essential/linux-extended index 3d81000a..90dcdca7 100644 --- a/packager/blacklists/essential/linux-extended +++ b/packager/blacklists/essential/linux-extended @@ -1,5 +1,5 @@ - /home/* - /root/* -+ /root/.bash* -+ /root/.ssh +#+ /root/.bash* +#+ /root/.ssh - /etc/cups diff --git a/packager/openslx.config b/packager/openslx.config index 00fc5501..a02a608b 100644 --- a/packager/openslx.config +++ b/packager/openslx.config @@ -2,7 +2,7 @@ DEFAULT_RSYNC_OPTS="-e ssh -c arcfour -oStrictHostKeyChecking=no" # default size for the qcow2-container (the one containing diffs) -DEFAULT_QCOW_SIZE="10G" +DEFAULT_QCOW_SIZE="25G" # default filesystem type for the qcow2-container DEFAULT_QCOW_FS="ext4" diff --git a/packager/openslx.functions b/packager/openslx.functions index 7fe74e0a..3b5c4394 100644 --- a/packager/openslx.functions +++ b/packager/openslx.functions @@ -353,6 +353,9 @@ clone_stage4() { # run rsync with the exclude/include lists created earlier cat "$INCLUDE" "$EXCLUDE" | \ rsync --verbose \ + --acls \ + --hard-links \ + --xattrs \ --archive \ --delete \ --delete-excluded \ @@ -424,7 +427,7 @@ pack_qcow2() { # which size for the qcow2 container? if [ -z "$DEFAULT_QCOW_SIZE" ]; then - local QCOW_SIZE="10G" + local QCOW_SIZE="25G" else local QCOW_SIZE="$DEFAULT_QCOW_SIZE" fi @@ -446,6 +449,10 @@ pack_qcow2() { perror "qemu-nbd failed with: $?" pinfo "Done." + # expose as a loop device + local NBD_LOOPED_DEV="$(losetup --find)" + losetup "${NBD_LOOPED_DEV}" "${NBD_DEV}" + # which filesystem for the qcow2 container? if [ -z "$DEFAULT_QCOW_FS" ]; then local QCOW_FS="ext4" @@ -457,32 +464,33 @@ pack_qcow2() { fi pinfo "Creating '${QCOW_FS}' filesystem on '${CONTAINER_PATH}'..." _STATE='QCOW_FSING' - mkfs."${QCOW_FS}" "${NBD_DEV}" || perror "mkfs failed with: $?" + mkfs."${QCOW_FS}" "${NBD_LOOPED_DEV}" || perror "mkfs failed with: $?" pinfo "Done." # prepare NBD mount directory and check state to be safe local NBD_MNT="$(mktemp -d)" [ ! -d "${NBD_MNT}" ] && \ - perror "Making temporary dir for mounting '$NBD_DEV' failed." + perror "Making temporary dir for mounting '${NBD_DEV}' failed." is_dir_empty ${NBD_MNT} || \ - perror "'${NBD_MNT}' not empty. Refusing to mount ${NBD_DEV} to it." + perror "'${NBD_MNT}' not empty. Refusing to mount '${NBD_DEV}' to it." pinfo "Mounting '${NBD_DEV}' to '${NBD_MNT}'..." _STATE='QCOW_MOUNTING' - mount "${NBD_DEV}" "${NBD_MNT}" || perror "Mount failed with: $?" + mount "${NBD_LOOPED_DEV}" "${NBD_MNT}" || perror "Mount failed with: $?" pinfo "Done." # copy files from the stage4 directory to the mounted qcow2-container pinfo "Copying '${RSYNC_TARGET}' to '${NBD_MNT}'..." _STATE='QCOW_COPYING' - cp -ra "${RSYNC_TARGET}"/* "${NBD_MNT}" || perror "Copying failed with: $?" + rsync -avAHX "${RSYNC_TARGET}"/ "${NBD_MNT}"/ || perror "Copying failed with: $?" pinfo "Done." pinfo "Cleaning up..." _STATE='QCOW_CLEANING' umount "${NBD_MNT}" || pwarning "Could not unmount '${NBD_MNT}'." rmdir "${NBD_MNT}" || pwarning "Could not remove '${NBD_MNT}'." + losetup -d "${NBD_LOOPED_DEV}" || pwarning "Could not disconnect '${NBD_LOOPED_DEV}'." qemu-nbd -d "${NBD_DEV}" || pwarning "Could not disconnect '${NBD_DEV}'." _STATE='QCOW_DONE' pinfo "Exporting '${RSYNC_TARGET}' to '${CONTAINER_PATH}' completed." -- cgit v1.2.3-55-g7522