creating swap with dd is slow

Bug #1482994 reported by Nobuto Murata
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
curtin
Fix Released
Medium
Unassigned
curtin (Ubuntu)
Fix Released
Medium
Unassigned
Trusty
Fix Released
Medium
Unassigned
Xenial
Fix Released
Medium
Unassigned
Zesty
Fix Released
Medium
Unassigned
Artful
Fix Released
Medium
Unassigned

Bug Description

Currently swap file is created by dd command. It takes time linearly correlate with the size.

> 34359738368 bytes (34 GB) copied, 154.964 s, 222 MB/s

It would be nice if curtin used "fallocate" if available instead of dd. It should finish in a second.

[curtin/swap.py]
     83 msg = "creating swap file '%s' of %sMB" % (swapfile, mbsize)
     84 fpath = os.path.sep.join([target, swapfile])
     85 try:
     86 util.ensure_dir(os.path.dirname(fpath))
     87 with util.LogTimer(LOG.debug, msg):
     88 util.subp(
     89 ['sh', '-c',
     90 ('rm -f "$1" && umask 0066 && '
     91 'dd if=/dev/zero "of=$1" bs=1M "count=$2" && '
     92 'mkswap "$1" || { r=$?; rm -f "$1"; exit $r; }'),
     93 'setup_swap', fpath, mbsize])

Tags: cpe-onsite

Related branches

Revision history for this message
Scott Moser (smoser) wrote :

Thanks!
Applied to trunk

Changed in curtin:
status: New → Fix Committed
importance: Undecided → Medium
Nobuto Murata (nobuto)
tags: added: cpec
Revision history for this message
Ante Karamatić (ivoks) wrote :

Shouldn't this be Fix Released now?

tags: added: cpe-onsite
removed: cpec
Scott Moser (smoser)
Changed in curtin (Ubuntu):
status: New → Fix Released
Changed in curtin (Ubuntu Trusty):
status: New → Fix Released
Changed in curtin (Ubuntu Xenial):
status: New → Fix Released
Changed in curtin (Ubuntu Zesty):
status: New → Fix Released
Changed in curtin (Ubuntu Trusty):
importance: Undecided → Medium
Changed in curtin (Ubuntu Artful):
status: New → Fix Released
Changed in curtin (Ubuntu):
importance: Undecided → Medium
Changed in curtin (Ubuntu Xenial):
importance: Undecided → Medium
Changed in curtin (Ubuntu Zesty):
importance: Undecided → Medium
Changed in curtin (Ubuntu Artful):
importance: Undecided → Medium
David Britton (dpb)
Changed in curtin:
status: Fix Committed → Fix Released
Revision history for this message
Scott Moser (smoser) wrote :

This is fixed in all supported Ubuntu (12.04+).
It is in curtin at revision 237.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.