Write image directly to disk

Write image directly to disk by telling qemu-img that the output
file is the disk. Still uses O_DIRECT directly within qemu-img.

This avoids the need to have a huge amount of system memory to be
able to deploy an image that contains a huge disk.

The only feature left behind by that commit is the 64K block size.

Change-Id: If60bcd82581b2ea76c4acbc3eaa3f317d2ee6590
This commit is contained in:
Mathieu Mitchell 2014-10-16 16:51:44 -04:00
parent 082cf29cec
commit e53e297a5e
1 changed files with 3 additions and 9 deletions

View File

@ -38,14 +38,8 @@ DEVICE="$2"
log "Erasing existing mbr from ${DEVICE}"
dd if=/dev/zero of=$DEVICE bs=512 count=10
## Doing two steps allows us to use dd, which allows us to tweak things like
## blocksize and allows use of direct io
# Converts image to raw
log "Converting $IMAGEFILE to RAW format"
qemu-img convert -O raw $IMAGEFILE /tmp/image.raw
# Write image onto device
log "Imaging $DEVICE"
dd if=/tmp/image.raw of=$DEVICE bs=64K oflag=direct
log "Imaging $IMAGEFILE to $DEVICE"
qemu-img convert -t directsync -O raw $IMAGEFILE $DEVICE
sync
log "${DEVICE} imaged successfully!"