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:
225
225
"a b c". By default this values is empty.
226
226
227
227
- 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.
230
232
231
233
- OS_VERSION:
232
234
Clear Linux version to use as base rootfs.
Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ info()
39
39
echo -e " \e[1mINFO\e[0m: $* "
40
40
}
41
41
42
+ warning ()
43
+ {
44
+ echo -e " \e[93mWARNING\e[0m: $* "
45
+ }
46
+
42
47
usage ()
43
48
{
44
49
cat << EOT
@@ -53,15 +58,23 @@ exit 1
53
58
[ " $( id -u) " -eq 0 ] || die " $0 : must be run as root"
54
59
[ -d " ${ROOTFS} " ] || die " ${ROOTFS} is not a directory"
55
60
61
+ # In order to support memory hotplug, image must be aligned to 128M
62
+ MEM_BOUNDARY=128
56
63
# Image file to be created:
57
64
IMAGE=" container.img"
58
65
# Image contents source folder
59
- IMG_SIZE=${IMG_SIZE:- 80M }
66
+ IMG_SIZE=${IMG_SIZE:- $MEM_BOUNDARY }
60
67
BLOCK_SIZE=${BLOCK_SIZE:- 4096}
61
68
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"
63
76
# Create image file
64
- qemu-img create -f raw " ${IMAGE} " " ${IMG_SIZE} "
77
+ qemu-img create -f raw " ${IMAGE} " " ${IMG_SIZE} M "
65
78
66
79
# Only one partition is required for the image
67
80
# Create partition table
You can’t perform that action at this time.
0 commit comments