This repository was archived by the owner on May 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -225,8 +225,10 @@ Environment Variables:
225225 "a b c". By default this values is empty.
226226
227227- IMG_SIZE
228- Change the image size of the image to generate (accepts any value
229- recognised by qemu-img(1)).
228+ Specify the image size in megabytes. In order to support memory hot plug, this
229+ value must be aligned to 128 (defined by PAGE_SECTION_MASK in the Linux Kernel),
230+ otherwise memory will not be plugged by the guest Linux Kernel, If this value
231+ is not aligned, osbuilder will align it. By default this value is 128.
230232
231233- OS_VERSION:
232234 Clear Linux version to use as base rootfs.
Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ info()
3939 echo -e " \e[1mINFO\e[0m: $* "
4040}
4141
42+ warning ()
43+ {
44+ echo -e " \e[93mWARNING\e[0m: $* "
45+ }
46+
4247usage ()
4348{
4449 cat << EOT
@@ -53,15 +58,23 @@ exit 1
5358[ " $( id -u) " -eq 0 ] || die " $0 : must be run as root"
5459[ -d " ${ROOTFS} " ] || die " ${ROOTFS} is not a directory"
5560
61+ # In order to support memory hotplug, image must be aligned to 128M
62+ MEM_BOUNDARY=128
5663# Image file to be created:
5764IMAGE=" container.img"
5865# Image contents source folder
59- IMG_SIZE=${IMG_SIZE:- 80M }
66+ IMG_SIZE=${IMG_SIZE:- $MEM_BOUNDARY }
6067BLOCK_SIZE=${BLOCK_SIZE:- 4096}
6168
62- info " Creating raw disk with size ${IMG_SIZE} "
69+ remaining=$( echo " $IMG_SIZE % $MEM_BOUNDARY " | bc)
70+ if [ " $remaining " != " 0" ]; then
71+ warning " image size '$IMG_SIZE ' is not aligned to memory boundary '$MEM_BOUNDARY ', aligning it"
72+ IMG_SIZE=" $(( IMG_SIZE + MEM_BOUNDARY - remaining)) "
73+ fi
74+
75+ info " Creating raw disk with size ${IMG_SIZE} M"
6376# Create image file
64- qemu-img create -f raw " ${IMAGE} " " ${IMG_SIZE} "
77+ qemu-img create -f raw " ${IMAGE} " " ${IMG_SIZE} M "
6578
6679# Only one partition is required for the image
6780# Create partition table
You can’t perform that action at this time.
0 commit comments