@@ -67,6 +67,7 @@ type DynamicIgnition struct {
67
67
Rootful bool
68
68
NetRecover bool
69
69
Rosetta bool
70
+ Swap uint64
70
71
}
71
72
72
73
func (ign * DynamicIgnition ) Write () error {
@@ -136,7 +137,7 @@ func (ign *DynamicIgnition) GenerateIgnitionConfig() error {
136
137
137
138
ignStorage := Storage {
138
139
Directories : getDirs (ign .Name ),
139
- Files : getFiles (ign .Name , ign .UID , ign .Rootful , ign .VMType , ign .NetRecover ),
140
+ Files : getFiles (ign .Name , ign .UID , ign .Rootful , ign .VMType , ign .NetRecover , ign . Swap ),
140
141
Links : getLinks (ign .Name ),
141
142
}
142
143
@@ -293,7 +294,7 @@ func getDirs(usrName string) []Directory {
293
294
return dirs
294
295
}
295
296
296
- func getFiles (usrName string , uid int , rootful bool , vmtype define.VMType , _ bool ) []File {
297
+ func getFiles (usrName string , uid int , rootful bool , vmtype define.VMType , _ bool , swap uint64 ) []File {
297
298
files := make ([]File , 0 )
298
299
299
300
lingerExample := parser .NewUnitFile ()
@@ -407,6 +408,21 @@ pids_limit=0
407
408
},
408
409
})
409
410
411
+ if swap > 0 {
412
+ files = append (files , File {
413
+ Node : Node {
414
+ Path : "/etc/systemd/zram-generator.conf" ,
415
+ },
416
+ FileEmbedded1 : FileEmbedded1 {
417
+ Append : nil ,
418
+ Contents : Resource {
419
+ Source : EncodeDataURLPtr (fmt .Sprintf ("[zram0]\n zram-size=%d\n " , swap )),
420
+ },
421
+ Mode : IntToPtr (0644 ),
422
+ },
423
+ })
424
+ }
425
+
410
426
// get certs for current user
411
427
userHome , err := os .UserHomeDir ()
412
428
if err != nil {
0 commit comments