Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use writeback rather then the default writethrough for compression #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kronos30
Copy link
Collaborator

The following PR is to help increase the speed of compression/conversions. The default option is writethrough, which is a slower process then writeback. For our purposes, it appears it takes close to 15 minutes, perhaps even more for the compression/conversion to take place. This change is in the attempts to improve the speed of this conversion by switching to use writeback.

Reference: https://opendev.org/openstack/nova/commit/e7b64eaad82db38dd46f586b650da4ddde42533b
and https://linux.die.net/man/1/qemu-img

Copy link
Member

@garyservin garyservin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bearrito
Copy link

bearrito commented Sep 22, 2023

This builds for me, but will not produce an image.

sudo packer build template.json
qemu-chroot: output will be in this color.

==> qemu-chroot: Creating output directory output-qemu-chroot...
==> qemu-chroot: Copying source image...
==> qemu-chroot: Finding available device...
==> qemu-chroot: Connecting source image as a network block device to /dev/nbd0...
==> qemu-chroot: Mounting the root device at /mnt/packer-builder-qemu-chroot/nbd0...
==> qemu-chroot: Mounting additional paths within the chroot...
    qemu-chroot: Mounting: /proc
    qemu-chroot: Mounting: /sys
    qemu-chroot: Mounting: /dev
    qemu-chroot: Mounting: /dev/pts
    qemu-chroot: Mounting: /proc/sys/fs/binfmt_misc
==> qemu-chroot: Copying files from host to chroot...
    qemu-chroot: /etc/resolv.conf
==> qemu-chroot: Provisioning with shell script: /tmp/packer-shell3352148920
==> qemu-chroot:
==> qemu-chroot: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
==> qemu-chroot:
    qemu-chroot: Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
    qemu-chroot: Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
    qemu-chroot: Reading state information...
    qemu-chroot: 20 packages can be upgraded. Run 'apt list --upgradable' to see them.
==> qemu-chroot: Unmounting the root device...
==> qemu-chroot: Error cleaning up: Error unmounting root device: exit status 32
==> qemu-chroot: Unmounting the root device...
==> qemu-chroot: Error unmounting root device: exit status 32
==> qemu-chroot: Disconnecting the source image from /dev/nbd0...
==> qemu-chroot: Deleting output directory...
Build 'qemu-chroot' errored after 15 seconds 966 milliseconds: Error cleaning up: Error unmounting root device: exit status 32

==> Wait completed after 15 seconds 966 milliseconds

==> Some builds didn't complete successfully and had errors:
--> qemu-chroot: Error cleaning up: Error unmounting root device: exit status 32

==> Builds finished but no artifacts were created.

@kronos30 When we talked I seem to remember you having an issue with building? Did I misremember that?

@kronos30
Copy link
Collaborator Author

This builds for me, but will not produce an image.

sudo packer build template.json
qemu-chroot: output will be in this color.

==> qemu-chroot: Creating output directory output-qemu-chroot...
==> qemu-chroot: Copying source image...
==> qemu-chroot: Finding available device...
==> qemu-chroot: Connecting source image as a network block device to /dev/nbd0...
==> qemu-chroot: Mounting the root device at /mnt/packer-builder-qemu-chroot/nbd0...
==> qemu-chroot: Mounting additional paths within the chroot...
    qemu-chroot: Mounting: /proc
    qemu-chroot: Mounting: /sys
    qemu-chroot: Mounting: /dev
    qemu-chroot: Mounting: /dev/pts
    qemu-chroot: Mounting: /proc/sys/fs/binfmt_misc
==> qemu-chroot: Copying files from host to chroot...
    qemu-chroot: /etc/resolv.conf
==> qemu-chroot: Provisioning with shell script: /tmp/packer-shell3352148920
==> qemu-chroot:
==> qemu-chroot: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
==> qemu-chroot:
    qemu-chroot: Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
    qemu-chroot: Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
    qemu-chroot: Reading state information...
    qemu-chroot: 20 packages can be upgraded. Run 'apt list --upgradable' to see them.
==> qemu-chroot: Unmounting the root device...
==> qemu-chroot: Error cleaning up: Error unmounting root device: exit status 32
==> qemu-chroot: Unmounting the root device...
==> qemu-chroot: Error unmounting root device: exit status 32
==> qemu-chroot: Disconnecting the source image from /dev/nbd0...
==> qemu-chroot: Deleting output directory...
Build 'qemu-chroot' errored after 15 seconds 966 milliseconds: Error cleaning up: Error unmounting root device: exit status 32

==> Wait completed after 15 seconds 966 milliseconds

==> Some builds didn't complete successfully and had errors:
--> qemu-chroot: Error cleaning up: Error unmounting root device: exit status 32

==> Builds finished but no artifacts were created.

@kronos30 When we talked I seem to remember you having an issue with building? Did I misremember that?

I was try to build locally using the instructions in the repo and the issue was my packer-sdc was not being found.

image

I haven't had a chance to re-try it, as I suspect I may be doing something incorrectly.

@bearrito
Copy link

bearrito commented Sep 25, 2023

@kronos30

After building packer-sdc, Likely need the following

export PATH=$PATH:/home/klad/go/bin/

Here is my template

{
  "builders": [
    {
      "type": "qemu-chroot",
      "source_image": "/home/bstrausser/Downloads/ubuntu-22.04-server-cloudimg-amd64.img",
      "image_name": "ubuntu-22.04.img",
      "compression": true
    }
  ],
  "provisioners": [

    {
      "type": "shell",
      "inline": [
        "echo '#!/bin/sh' > /usr/sbin/policy-rc.d",
        "echo 'exit 101' >> /usr/sbin/policy-rc.d",
        "chmod a+x /usr/sbin/policy-rc.d"
      ]
      
    },

    {
      "type": "shell",
      "inline": [
        "apt update"
      ]
    },

    {
      "type": "shell",
      "inline": [
        "rm -f /usr/sbin/policy-rc.d"
      ]
    }
    ,
    {
      "type": "shell",
      "inline": [
        "cat /proc/mounts"
      ]
    }


    

  ]
}

You need to add the policy statements so that no services get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants