1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
|
'\" t
.\" Automatically generated by Pandoc 2.17.1.1
.\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
.ie "\f[CB]x\f[]"x" \{\
. ftr V B
. ftr VI BI
. ftr VB B
. ftr VBI BI
.\}
.el \{\
. ftr V CR
. ftr VI CI
. ftr VB CB
. ftr VBI CBI
.\}
.TH "mkosi" "1" "" "" ""
.hy
.SH NAME
.PP
mkosi \[em] Build Bespoke OS Images
.SH SYNOPSIS
.PP
\f[V]mkosi [options\&...] summary\f[R]
.PP
\f[V]mkosi [options\&...] build [command line\&...]\f[R]
.PP
\f[V]mkosi [options\&...] shell [command line\&...]\f[R]
.PP
\f[V]mkosi [options\&...] boot [nspawn settings\&...]\f[R]
.PP
\f[V]mkosi [options\&...] qemu [qemu parameters\&...]\f[R]
.PP
\f[V]mkosi [options\&...] vmspawn [vmspawn settings\&...]\f[R]
.PP
\f[V]mkosi [options\&...] ssh [command line\&...]\f[R]
.PP
\f[V]mkosi [options\&...] journalctl [command line\&...]\f[R]
.PP
\f[V]mkosi [options\&...] coredumpctl [command line\&...]\f[R]
.PP
\f[V]mkosi [options\&...] clean\f[R]
.PP
\f[V]mkosi [options\&...] serve\f[R]
.PP
\f[V]mkosi [options\&...] burn <device>\f[R]
.PP
\f[V]mkosi [options\&...] bump\f[R]
.PP
\f[V]mkosi [options\&...] genkey\f[R]
.PP
\f[V]mkosi [options\&...] documentation\f[R]
.PP
\f[V]mkosi [options\&...] help\f[R]
.SH DESCRIPTION
.PP
\f[V]mkosi\f[R] is a tool for easily building customized OS images.
It\[cq]s a fancy wrapper around \f[V]dnf --installroot\f[R],
\f[V]apt\f[R], \f[V]pacman\f[R] and \f[V]zypper\f[R] that may generate
disk images with a number of bells and whistles.
.SS Command Line Verbs
.PP
The following command line verbs are known:
.TP
\f[V]summary\f[R]
Outputs a human-readable summary of all options used for building an
image.
This will parse the command line and \f[V]mkosi.conf\f[R] file as it
would do on \f[V]build\f[R], but only output what it is configured for
and not actually build anything.
.TP
\f[V]build\f[R]
This builds the image based on the settings passed in on the command
line or read from configuration files.
This command is the default if no verb is explicitly specified.
If any command line arguments are specified, these are passed directly
to the build script if one is defined.
.TP
\f[V]shell\f[R]
This builds the image if it is not built yet, and then invokes
\f[V]systemd-nspawn\f[R] to acquire an interactive shell prompt in it.
An optional command line may be specified after the \f[V]shell\f[R]
verb, to be invoked in place of the shell in the container.
Use \f[V]-f\f[R] in order to rebuild the image unconditionally before
acquiring the shell, see below.
This command must be executed as \f[V]root\f[R].
.TP
\f[V]boot\f[R]
Similar to \f[V]shell\f[R], but boots the image using
\f[V]systemd-nspawn\f[R].
An optional command line may be specified after the \f[V]boot\f[R] verb,
which can contain extra nspawn options as well as arguments which are
passed as the \f[I]kernel command line\f[R] to the init system in the
image.
.TP
\f[V]qemu\f[R]
Similar to \f[V]boot\f[R], but uses \f[V]qemu\f[R] to boot up the image,
i.e.\ instead of container virtualization virtual machine virtualization
is used.
This verb is only supported for disk images that contain a boot loader
and cpio images in which a kernel was installed.
For cpio images a kernel can also be provided by passing the
\f[V]-kernel\f[R] qemu argument to the \f[V]qemu\f[R] verb.
Any arguments specified after the \f[V]qemu\f[R] verb are appended to
the \f[V]qemu\f[R] invocation.
.TP
\f[V]vmspawn\f[R]
Similar to \f[V]boot\f[R], but uses \f[V]systemd-vmspawn\f[R] to boot up
the image, i.e.
instead of container virtualization virtual machine virtualization is
used.
This verb is only supported for disk and directory type images.
Any arguments specified after the \f[V]vmspawn\f[R] verb are appended to
the \f[V]systemd-vmspawn\f[R] invocation.
.TP
\f[V]ssh\f[R]
When the image is built with the \f[V]Ssh=yes\f[R] option, this command
connects to a booted virtual machine (\f[V]qemu\f[R]) via SSH.
Make sure to run \f[V]mkosi ssh\f[R] with the same config as
\f[V]mkosi build\f[R] so that it has the necessary information available
to connect to the running virtual machine via SSH.
Specifically, the SSH private key from the \f[V]SshKey=\f[R] setting is
used to connect to the virtual machine.
Use \f[V]mkosi genkey\f[R] to automatically generate a key and
certificate that will be picked up by mkosi.
Any arguments passed after the \f[V]ssh\f[R] verb are passed as
arguments to the \f[V]ssh\f[R] invocation.
To connect to a container, use \f[V]machinectl login\f[R] or
\f[V]machinectl shell\f[R].
.TP
\f[V]journalctl\f[R]
Uses \f[V]journalctl\f[R] to inspect the journal inside the image.
Any arguments specified after the \f[V]journalctl\f[R] verb are appended
to the \f[V]journalctl\f[R] invocation.
.TP
\f[V]coredumpctl\f[R]
Uses \f[V]coredumpctl\f[R] to look for coredumps inside the image.
Any arguments specified after the \f[V]coredumpctl\f[R] verb are
appended to the \f[V]coredumpctl\f[R] invocation.
.TP
\f[V]clean\f[R]
Remove build artifacts generated on a previous build.
If combined with \f[V]-f\f[R], also removes incremental build cache
images.
If \f[V]-f\f[R] is specified twice, also removes any package cache.
.TP
\f[V]serve\f[R]
This builds the image if it is not built yet, and then serves the output
directory (i.e.\ usually \f[V]mkosi.output/\f[R], see below) via a small
embedded HTTP server, listening on port 8081.
Combine with \f[V]-f\f[R] in order to rebuild the image unconditionally
before serving it.
This command is useful for testing network based acquisition of OS
images, for example via \f[V]machinectl pull-raw \&...\f[R] and
\f[V]machinectl pull-tar \&...\f[R].
.TP
\f[V]burn <device>\f[R]
This builds the image if it is not built yet, and then writes it to the
specified block device.
The partition contents are written as-is, but the GPT partition table is
corrected to match sector and disk size of the specified medium.
.TP
\f[V]bump\f[R]
Bumps the image version from \f[V]mkosi.version\f[R] and writes the
resulting version string to \f[V]mkosi.version\f[R].
This is useful for implementing a simple versioning scheme: each time
this verb is called the version is bumped in preparation for the
subsequent build.
Note that \f[V]--auto-bump\f[R]/\f[V]-B\f[R] may be used to
automatically bump the version after each successful build.
.TP
\f[V]genkey\f[R]
Generate a pair of SecureBoot keys for usage with the
\f[V]SecureBootKey=\f[R]/\f[V]--secure-boot-key=\f[R] and
\f[V]SecureBootCertificate=\f[R]/\f[V]--secure-boot-certificate=\f[R]
options.
.TP
\f[V]documentation\f[R]
Show mkosi\[cq]s documentation.
By default this verb will try several ways to output the documentation,
but a specific option can be chosen with the \f[V]--doc-format\f[R]
option.
Distro packagers are encouraged to add a file \f[V]mkosi.1\f[R] into the
\f[V]mkosi/resources\f[R] directory of the Python package, if it is
missing, as well as to install it in the appropriate search path for man
pages.
The man page can be generated from the markdown file
\f[V]mkosi/resources/mkosi.md\f[R] e.g via
\f[V]pandoc -t man -s -o mkosi.1 mkosi.md\f[R].
.TP
\f[V]help\f[R]
This verb is equivalent to the \f[V]--help\f[R] switch documented below:
it shows a brief usage explanation.
.SS Commandline-only Options
.PP
Those settings cannot be configured in the configuration files.
.TP
\f[V]--force\f[R], \f[V]-f\f[R]
Replace the output file if it already exists, when building an image.
By default when building an image and an output artifact already exists
\f[V]mkosi\f[R] will refuse operation.
Specify this option once to delete all build artifacts from a previous
run before re-building the image.
If incremental builds are enabled, specifying this option twice will
ensure the intermediary cache files are removed, too, before the
re-build is initiated.
If a package cache is used (also see the \f[B]Files\f[R] section below),
specifying this option thrice will ensure the package cache is removed
too, before the re-build is initiated.
For the \f[V]clean\f[R] operation this option has a slightly different
effect: by default the verb will only remove build artifacts from a
previous run, when specified once the incremental cache files are
deleted too, and when specified twice the package cache is also removed.
.TP
\f[V]--directory=\f[R], \f[V]-C\f[R]
Takes a path to a directory.
\f[V]mkosi\f[R] switches to this directory before doing anything.
Note that the various configuration files are searched for in this
directory, hence using this option is an effective way to build a
project located in a specific directory.
.TP
\f[V]--debug=\f[R]
Enable additional debugging output.
.TP
\f[V]--debug-shell\f[R]
When executing a command in the image fails, mkosi will start an
interactive shell in the image allowing further debugging.
.TP
\f[V]--debug-workspace=\f[R]
When an error occurs, the workspace directory will not be deleted.
.TP
\f[V]--version\f[R]
Show package version.
.TP
\f[V]--help\f[R], \f[V]-h\f[R]
Show brief usage information.
.TP
\f[V]--genkey-common-name=\f[R]
Common name to be used when generating keys via mkosi\[cq]s
\f[V]genkey\f[R] command.
Defaults to \f[V]mkosi of %u\f[R], where \f[V]%u\f[R] expands to the
username of the user invoking mkosi.
.TP
\f[V]--genkey-valid-days=\f[R]
Number of days that the keys should remain valid when generating keys
via mkosi\[cq]s \f[V]genkey\f[R] command.
Defaults to two years (730 days).
.TP
\f[V]--auto-bump=\f[R], \f[V]-B\f[R]
If specified, after each successful build the the version is bumped in a
fashion equivalent to the \f[V]bump\f[R] verb, in preparation for the
next build.
This is useful for simple, linear version management: each build in a
series will have a version number one higher then the previous one.
.TP
\f[V]--doc-format\f[R]
The format to show the documentation in.
Supports the values \f[V]markdown\f[R], \f[V]man\f[R], \f[V]pandoc\f[R],
\f[V]system\f[R] and \f[V]auto\f[R].
In the case of \f[V]markdown\f[R] the documentation is shown in the
original Markdown format.
\f[V]man\f[R] shows the documentation in man page format, if it is
available.
\f[V]pandoc\f[R] will generate the man page format on the fly, if
\f[V]pandoc\f[R] is available.
\f[V]system\f[R] will show the system-wide man page for mkosi, which may
or may not correspond to the version you are using, depending on how you
installed mkosi.
\f[V]auto\f[R], which is the default, will try all methods in the order
\f[V]man\f[R], \f[V]pandoc\f[R], \f[V]markdown\f[R], \f[V]system\f[R].
.TP
\f[V]--json\f[R]
Show the summary output as JSON-SEQ.
.SS Supported output formats
.PP
The following output formats are supported:
.IP \[bu] 2
Raw \f[I]GPT\f[R] disk image, created using systemd-repart
(\f[I]disk\f[R])
.IP \[bu] 2
Plain directory, containing the OS tree (\f[I]directory\f[R])
.IP \[bu] 2
Tar archive (\f[I]tar\f[R])
.IP \[bu] 2
CPIO archive (\f[I]cpio\f[R])
.PP
The output format may also be set to \f[I]none\f[R] to have mkosi
produce no image at all.
This can be useful if you only want to use the image to produce another
output in the build scripts (e.g.\ build an rpm).
.PP
When a \f[I]GPT\f[R] disk image is created, repart partition definition
files may be placed in \f[V]mkosi.repart/\f[R] to configure the
generated disk image.
.PP
It is highly recommended to run \f[V]mkosi\f[R] on a file system that
supports reflinks such as XFS and btrfs and to keep all related
directories on the same file system.
This allows mkosi to create images very quickly by using reflinks to
perform copying via copy-on-write operations.
.SS Configuration Settings
.PP
The following settings can be set through configuration files (the
syntax with \f[V]SomeSetting=value\f[R]) and on the command line (the
syntax with \f[V]--some-setting=value\f[R]).
For some command line parameters, a single-letter shortcut is also
allowed.
In the configuration files, the setting must be in the appropriate
section, so the settings are grouped by section below.
.PP
Configuration is parsed in the following order:
.IP \[bu] 2
The command line arguments are parsed
.IP \[bu] 2
\f[V]mkosi.local.conf\f[R] is parsed if it exists.
This file should be in the gitignore (or equivalent) and is intended for
local configuration.
.IP \[bu] 2
Any default paths (depending on the option) are configured if the
corresponding path exists.
.IP \[bu] 2
\f[V]mkosi.conf\f[R] is parsed if it exists in the directory configured
with \f[V]--directory=\f[R] or the current working directory if
\f[V]--directory=\f[R] is not used.
.IP \[bu] 2
\f[V]mkosi.conf.d/\f[R] is parsed in the same directory if it exists.
Each directory and each file with the \f[V].conf\f[R] extension in
\f[V]mkosi.conf.d/\f[R] is parsed.
Any directory in \f[V]mkosi.conf.d\f[R] is parsed as if it were a
regular top level directory.
.PP
Note that if the same setting is configured twice, the later assignment
overrides the earlier assignment unless the setting is a list based
setting.
Also note that before v16, we used to do the opposite, where the earlier
assignment would be used instead of later assignments.
.PP
Settings that take a list of values are merged by appending the new
values to the previously configured values.
Assigning the empty string to such a setting removes all previously
assigned values, and overrides any configured default values as well.
.PP
If a setting\[cq]s name in the configuration file is prefixed with
\f[V]\[at]\f[R], it configures the default value used for that setting
if no explicit default value is set.
This can be used to set custom default values in configuration files
that can still be overridden by specifying the setting explicitly via
the CLI.
.PP
To conditionally include configuration files, the \f[V][Match]\f[R]
section can be used.
A \f[V][Match]\f[R] section consists of invididual conditions.
Conditions can use a pipe symbol (\f[V]|\f[R]) after the equals sign
(\f[V]\&...=|\&...\f[R]), which causes the condition to become a
triggering condition.
The config file will be included if the logical AND of all
non-triggering conditions and the logical OR of all triggering
conditions is satisfied.
To negate the result of a condition, prefix the argument with an
exclamation mark.
If an argument is prefixed with the pipe symbol and an exclamation mark,
the pipe symbol must be passed first, and the exclamation second.
.PP
Note that \f[V][Match]\f[R] conditions compare against the current
values of specific settings, and do not take into account changes made
to the setting in configuration files that have not been parsed yet.
Also note that matching against a setting and then changing its value
afterwards in a different config file may lead to unexpected results.
.PP
The \f[V][Match]\f[R] section of a \f[V]mkosi.conf\f[R] file in a
directory applies to the entire directory.
If the conditions are not satisfied, the entire directory is skipped.
The \f[V][Match]\f[R] sections of files in \f[V]mkosi.conf.d/\f[R] and
\f[V]mkosi.local.conf\f[R] only apply to the file itself.
.PP
If there are multiple \f[V][Match]\f[R] sections in the same
configuration file, each of them has to be satisfied in order for the
configuration file to be included.
Specifically, triggering conditions only apply to the current
\f[V][Match]\f[R] section and are reset between multiple
\f[V][Match]\f[R] sections.
As an example, the following will only match if the output format is one
of \f[V]disk\f[R] or \f[V]directory\f[R] and the architecture is one of
\f[V]x86-64\f[R] or \f[V]arm64\f[R]:
.IP
.nf
\f[C]
[Match]
Format=|disk
Format=|directory
[Match]
Architecture=|x86-64
Architecture=|arm64
\f[R]
.fi
.PP
The \f[V][TriggerMatch]\f[R] section can be used to indicate triggering
match sections.
These are identical to triggering conditions except they apply to the
entire match section instead of just a single condition.
As an example, the following will match if the distribution is
\f[V]debian\f[R] and the release is \f[V]bookworm\f[R] or if the
distribution is \f[V]ubuntu\f[R] and the release is \f[V]focal\f[R].
.IP
.nf
\f[C]
[TriggerMatch]
Distribution=debian
Release=bookworm
[TriggerMatch]
Distribution=ubuntu
Release=focal
\f[R]
.fi
.PP
The semantics of conditions in \f[V][TriggerMatch]\f[R] sections is the
same as in \f[V][Match]\f[R], i.e.\ all normal conditions are joined by
a logical AND and all triggering conditions are joined by a logical OR.
When mixing \f[V][Match]\f[R] and \f[V][TriggerMatch]\f[R] sections, a
match is achieved when all \f[V][Match]\f[R] sections match and at least
one \f[V][TriggerMatch]\f[R] section matches.
No match sections are valued as true.
Logically this means:
.IP
.nf
\f[C]
(\[u22C0]\[u1D62] Match\[u1D62]) \[AN] (\[u22C1]\[u1D62] TriggerMatch\[u1D62])
\f[R]
.fi
.PP
Command line options that take no argument are shown without \f[V]=\f[R]
in their long version.
In the config files, they should be specified with a boolean argument:
either \f[V]1\f[R], \f[V]yes\f[R], or \f[V]true\f[R] to enable, or
\f[V]0\f[R], \f[V]no\f[R], \f[V]false\f[R] to disable.
.SS [Match] Section.
.TP
\f[V]Profile=\f[R]
Matches against the configured profile.
.TP
\f[V]Distribution=\f[R]
Matches against the configured distribution.
.TP
\f[V]Release=\f[R]
Matches against the configured distribution release.
If this condition is used and no distribution has been explicitly
configured yet, the host distribution and release are used.
.TP
\f[V]Architecture=\f[R]
Matches against the configured architecture.
If this condition is used and no architecture has been explicitly
configured yet, the host architecture is used.
.TP
\f[V]PathExists=\f[R]
This condition is satisfied if the given path exists.
Relative paths are interpreted relative to the parent directory of the
config file that the condition is read from.
.TP
\f[V]ImageId=\f[R]
Matches against the configured image ID, supporting globs.
If this condition is used and no image ID has been explicitly configured
yet, this condition fails.
.TP
\f[V]ImageVersion=\f[R]
Matches against the configured image version.
Image versions can be prepended by the operators \f[V]==\f[R],
\f[V]!=\f[R], \f[V]>=\f[R], \f[V]<=\f[R], \f[V]<\f[R], \f[V]>\f[R] for
rich version comparisons according to the UAPI group version format
specification.
If no operator is prepended, the equality operator is assumed by
default.
If this condition is used and no image version has been explicitly
configured yet, this condition fails.
.TP
\f[V]Bootable=\f[R]
Matches against the configured value for the \f[V]Bootable=\f[R]
feature.
Takes a boolean value or \f[V]auto\f[R].
.TP
\f[V]Format=\f[R]
Matches against the configured value for the \f[V]Format=\f[R] option.
Takes an output format (see the \f[V]Format=\f[R] option).
.TP
\f[V]SystemdVersion=\f[R]
Matches against the systemd version on the host (as reported by
\f[V]systemctl --version\f[R]).
Values can be prepended by the operators \f[V]==\f[R], \f[V]!=\f[R],
\f[V]>=\f[R], \f[V]<=\f[R], \f[V]<\f[R], \f[V]>\f[R] for rich version
comparisons according to the UAPI group version format specification.
If no operator is prepended, the equality operator is assumed by
default.
.TP
\f[V]BuildSources=\f[R]
Takes a build source target path (see \f[V]BuildSources=\f[R]).
This match is satisfied if any of the configured build sources uses this
target path.
For example, if we have a \f[V]mkosi.conf\f[R] file containing:
.IP
.nf
\f[C]
[Content]
BuildSources=../abc/qed:kernel
\f[R]
.fi
.PP
and a drop-in containing:
.IP
.nf
\f[C]
[Match]
BuildSources=kernel
\f[R]
.fi
.TP
The drop-in will be included.
Any absolute paths passed to this setting are interpreted relative to
the current working directory.
.TP
\f[V]HostArchitecture=\f[R]
Matches against the host\[cq]s native architecture.
See the \f[V]Architecture=\f[R] setting for a list of possible values.
.PP
.TS
tab(@);
lw(20.7n) lw(6.9n) lw(17.7n) lw(24.6n).
T{
Matcher
T}@T{
Globs
T}@T{
Rich Comparisons
T}@T{
Default
T}
_
T{
\f[V]Profile=\f[R]
T}@T{
no
T}@T{
no
T}@T{
match fails
T}
T{
\f[V]Distribution=\f[R]
T}@T{
no
T}@T{
no
T}@T{
match host distribution
T}
T{
\f[V]Release=\f[R]
T}@T{
no
T}@T{
no
T}@T{
match host release
T}
T{
\f[V]Architecture=\f[R]
T}@T{
no
T}@T{
no
T}@T{
match host architecture
T}
T{
\f[V]PathExists=\f[R]
T}@T{
no
T}@T{
no
T}@T{
n/a
T}
T{
\f[V]ImageId=\f[R]
T}@T{
yes
T}@T{
no
T}@T{
match fails
T}
T{
\f[V]ImageVersion=\f[R]
T}@T{
no
T}@T{
yes
T}@T{
match fails
T}
T{
\f[V]Bootable=\f[R]
T}@T{
no
T}@T{
no
T}@T{
match auto feature
T}
T{
\f[V]Format=\f[R]
T}@T{
no
T}@T{
no
T}@T{
match default format
T}
T{
\f[V]SystemdVersion=\f[R]
T}@T{
no
T}@T{
yes
T}@T{
n/a
T}
T{
\f[V]BuildSources=\f[R]
T}@T{
no
T}@T{
no
T}@T{
match fails
T}
T{
\f[V]HostArchitecture=\f[R]
T}@T{
no
T}@T{
no
T}@T{
n/a
T}
.TE
.SS [Config] Section
.TP
\f[V]Profile=\f[R], \f[V]--profile=\f[R]
Select the given profile.
A profile is a configuration file or directory in the
\f[V]mkosi.profiles/\f[R] directory.
When selected, this configuration file or directory is included after
parsing the \f[V]mkosi.conf\f[R] file, but before any
\f[V]mkosi.conf.d/*.conf\f[R] drop in configuration.
.TP
\f[V]Include=\f[R], \f[V]--include=\f[R]
Include extra configuration from the given file or directory.
The extra configuration is included immediately after parsing the
setting, except when a default is set using \f[V]\[at]Include=\f[R], in
which case the configuration is included after parsing all the other
configuration files.
Note that each path containing extra configuration is only parsed once,
even if included more than once with \f[V]Include=\f[R].
The builtin configs for the mkosi default initrd and default tools tree
can be included by including the literal value \f[V]mkosi-initrd\f[R]
and \f[V]mkosi-tools\f[R] respectively.
Note: Include names starting with either of the literals
\f[V]mkosi-\f[R] or \f[V]contrib-\f[R] are reserved for use by mkosi
itself.
.TP
\f[V]InitrdInclude=\f[R], \f[V]--initrd-include=\f[R]
Same as \f[V]Include=\f[R], but the extra configuration files or
directories are included when building the default initrd.
.TP
\f[V]Images=\f[R], \f[V]--image=\f[R]
If specified, only build the given image.
Can be specified multiple times to build multiple images.
All the given images and their dependencies are built.
If not specified, all images are built.
See the \f[B]Building multiple images\f[R] section for more information.
Note that this section only takes effect when specified in the global
configuration files.
It has no effect if specified as an image specific setting.
.TP
\f[V]Dependencies=\f[R], \f[V]--dependency=\f[R]
The images that this image depends on specified as a comma-separated
list.
All images configured in this option will be built before this image and
will be pulled in as dependencies of this image when \f[V]Images=\f[R]
is used.
.TP
\f[V]MinimumVersion=\f[R], \f[V]--minimum-version=\f[R]
The minimum mkosi version required to build this configuration.
If specified multiple times, the highest specified version is used.
.SS [Distribution] Section
.TP
\f[V]Distribution=\f[R], \f[V]--distribution=\f[R], \f[V]-d\f[R]
The distribution to install in the image.
Takes one of the following arguments: \f[V]fedora\f[R],
\f[V]debian\f[R], \f[V]ubuntu\f[R], \f[V]arch\f[R], \f[V]opensuse\f[R],
\f[V]mageia\f[R], \f[V]centos\f[R], \f[V]rhel\f[R], \f[V]rhel-ubi\f[R],
\f[V]openmandriva\f[R], \f[V]rocky\f[R], \f[V]alma\f[R],
\f[V]custom\f[R].
If not specified, defaults to the distribution of the host or
\f[V]custom\f[R] if the distribution of the host is not a supported
distribution.
.TP
\f[V]Release=\f[R], \f[V]--release=\f[R], \f[V]-r\f[R]
The release of the distribution to install in the image.
The precise syntax of the argument this takes depends on the
distribution used, and is either a numeric string (in case of Fedora
Linux, CentOS, \&..., e.g.\ \f[V]29\f[R]), or a distribution version
name (in case of Debian, Ubuntu, \&..., e.g.\ \f[V]artful\f[R]).
Defaults to a recent version of the chosen distribution, or the version
of the distribution running on the host if it matches the configured
distribution.
.TP
\f[V]Architecture=\f[R], \f[V]--architecture=\f[R]
The architecture to build the image for.
The architectures that are actually supported depends on the
distribution used and whether a bootable image is requested or not.
When building for a foreign architecture, you\[cq]ll also need to
install and register a user mode emulator for that architecture.
One of the following architectures can be specified per image built:
\f[V]alpha\f[R], \f[V]arc\f[R], \f[V]arm\f[R], \f[V]arm64\f[R],
\f[V]ia64\f[R], \f[V]loongarch64\f[R], \f[V]mips64-le\f[R],
\f[V]mips-le\f[R], \f[V]parisc\f[R], \f[V]ppc\f[R], \f[V]ppc64\f[R],
\f[V]ppc64-le\f[R], \f[V]riscv32\f[R], \f[V]riscv64\f[R],
\f[V]s390\f[R], \f[V]s390x\f[R], \f[V]tilegx\f[R], \f[V]x86\f[R],
\f[V]x86-64\f[R].
.TP
\f[V]Mirror=\f[R], \f[V]--mirror=\f[R], \f[V]-m\f[R]
The mirror to use for downloading the distribution packages.
Expects a mirror URL as argument.
If not provided, the default mirror for the distribution is used.
The default mirrors for each distribution are as follows (unless
specified, the same mirror is used for all architectures):
.PP
.TS
tab(@);
lw(13.5n) lw(29.5n) lw(27.0n).
T{
T}@T{
x86-64
T}@T{
aarch64
T}
_
T{
\f[V]debian\f[R]
T}@T{
http://deb.debian.org/debian
T}@T{
T}
T{
\f[V]arch\f[R]
T}@T{
https://geo.mirror.pkgbuild.com
T}@T{
http://mirror.archlinuxarm.org
T}
T{
\f[V]opensuse\f[R]
T}@T{
http://download.opensuse.org
T}@T{
T}
T{
\f[V]ubuntu\f[R]
T}@T{
http://archive.ubuntu.com
T}@T{
http://ports.ubuntu.com
T}
T{
\f[V]centos\f[R]
T}@T{
https://mirrors.centos.org
T}@T{
T}
T{
\f[V]rocky\f[R]
T}@T{
https://mirrors.rockylinux.org
T}@T{
T}
T{
\f[V]alma\f[R]
T}@T{
https://mirrors.almalinux.org
T}@T{
T}
T{
\f[V]fedora\f[R]
T}@T{
https://mirrors.fedoraproject.org
T}@T{
T}
T{
\f[V]rhel-ubi\f[R]
T}@T{
https://cdn-ubi.redhat.com
T}@T{
T}
T{
\f[V]mageia\f[R]
T}@T{
https://www.mageia.org
T}@T{
T}
T{
\f[V]openmandriva\f[R]
T}@T{
http://mirrors.openmandriva.org
T}@T{
T}
.TE
.TP
\f[V]LocalMirror=\f[R], \f[V]--local-mirror=\f[R]
The mirror will be used as a local, plain and direct mirror instead of
using it as a prefix for the full set of repositories normally supported
by distributions.
Useful for fully offline builds with a single repository.
Supported on deb/rpm/arch based distributions.
Overrides \f[V]--mirror=\f[R] but only for the local mkosi build, it
will not be configured inside the final image, \f[V]--mirror=\f[R] (or
the default repository) will be configured inside the final image
instead.
.TP
\f[V]RepositoryKeyCheck=\f[R], \f[V]--repository-key-check=\f[R]
Controls signature/key checks when using repositories, enabled by
default.
Useful to disable checks when combined with \f[V]--local-mirror=\f[R]
and using only a repository from a local filesystem.
Not used for DNF-based distros yet.
.TP
\f[V]Repositories=\f[R], \f[V]--repositories=\f[R]
Enable package repositories that are disabled by default.
This can be used to enable the EPEL repos for CentOS or different
components of the Debian/Ubuntu repositories.
.TP
\f[V]CacheOnly=\f[R], \f[V]--cache-only=\f[R]
Takes one of \f[V]none\f[R], \f[V]metadata\f[R] or \f[V]always\f[R].
If \f[V]always\f[R], the package manager is instructed not to contact
the network.
This provides a minimal level of reproducibility, as long as the package
cache is already fully populated.
If set to \f[V]metadata\f[R], the package manager can still download
packages, but we won\[cq]t sync the repository metadata.
If set to \f[V]none\f[R], the repository metadata is synced and packages
can be downloaded during the build.
.TP
\f[V]PackageManagerTrees=\f[R], \f[V]--package-manager-tree=\f[R]
This option mirrors the above \f[V]SkeletonTrees=\f[R] option and
defaults to the same value if not configured otherwise, but installs the
files to a subdirectory of the workspace directory instead of the OS
tree.
This subdirectory of the workspace is used to configure the package
manager.
\f[V]mkosi\f[R] will look for the package manager configuration and
related files in the configured package manager trees.
Unless specified otherwise, it will use the configuration files from
their canonical locations in \f[V]/usr\f[R] or \f[V]/etc\f[R] in the
package manager trees.
For example, it will look for \f[V]etc/dnf/dnf.conf\f[R] in the package
manager trees if \f[V]dnf\f[R] is used to install packages.
\f[V]SkeletonTrees=\f[R] and \f[V]PackageManagerTrees=\f[R] fulfill
similar roles.
Use \f[V]SkeletonTrees=\f[R] if you want the files to be present in the
final image.
Use \f[V]PackageManagerTrees=\f[R] if you don\[cq]t want the files to be
present in the final image, e.g.\ when building an initrd or if you want
to refer to paths outside of the image in your repository configuration.
.SS [Output] Section
.TP
\f[V]Format=\f[R], \f[V]--format=\f[R], \f[V]-t\f[R]
The image format type to generate.
One of \f[V]directory\f[R] (for generating an OS image directly in a
local directory), \f[V]tar\f[R] (similar, but a tarball of the OS image
is generated), \f[V]cpio\f[R] (similar, but a cpio archive is
generated), \f[V]disk\f[R] (a block device OS image with a GPT partition
table), \f[V]uki\f[R] (a unified kernel image with the OS image in the
\f[V].initrd\f[R] PE section), \f[V]esp\f[R] (\f[V]uki\f[R] but wrapped
in a disk image with only an ESP partition), \f[V]sysext\f[R],
\f[V]confext\f[R], \f[V]portable\f[R] or \f[V]none\f[R] (the OS image is
solely intended as a build image to produce another artifact).
If the \f[V]disk\f[R] output format is used, the disk image is generated
using \f[V]systemd-repart\f[R].
The repart partition definition files to use can be configured using the
\f[V]RepartDirectories=\f[R] setting or via \f[V]mkosi.repart/\f[R].
When verity partitions are configured using systemd-repart\[cq]s
\f[V]Verity=\f[R] setting, mkosi will automatically parse the verity
hash partition\[cq]s roothash from systemd-repart\[cq]s JSON output and
include it in the kernel command line of every unified kernel image
built by mkosi.
.TP
\f[V]ManifestFormat=\f[R], \f[V]--manifest-format=\f[R]
The manifest format type or types to generate.
A comma-delimited list consisting of \f[V]json\f[R] (the standard JSON
output format that describes the packages installed),
\f[V]changelog\f[R] (a human-readable text format designed for diffing).
By default no manifest is generated.
.TP
\f[V]Output=\f[R], \f[V]--output=\f[R], \f[V]-o\f[R]
Name to use for the generated output image file or directory.
All outputs will be prefixed with the given name.
Defaults to \f[V]image\f[R] or, if \f[V]ImageId=\f[R] is specified, it
is used as the default output name, optionally suffixed with the version
set with \f[V]ImageVersion=\f[R].
Note that this option does not allow configuring the output directory,
use \f[V]OutputDirectory=\f[R] for that.
Note that this only specifies the output prefix, depending on the
specific output format, compression and image version used, the full
output name might be \f[V]image_7.8.raw.xz\f[R].
.TP
\f[V]CompressOutput=\f[R], \f[V]--compress-output=\f[R]
Configure compression for the resulting image or archive.
The argument can be either a boolean or a compression algorithm
(\f[V]xz\f[R], \f[V]zstd\f[R]).
\f[V]zstd\f[R] compression is used by default, except CentOS and
derivatives up to version 8, which default to \f[V]xz\f[R].
Note that when applied to block device image types, compression means
the image cannot be started directly but needs to be decompressed first.
This also means that the \f[V]shell\f[R], \f[V]boot\f[R], \f[V]qemu\f[R]
verbs are not available when this option is used.
Implied for \f[V]tar\f[R], \f[V]cpio\f[R], \f[V]uki\f[R], and
\f[V]esp\f[R].
.TP
\f[V]CompressLevel=\f[R], \f[V]--compress-level=\f[R]
Configure the compression level to use.
Takes an integer.
The possible values depend on the compression being used.
.TP
\f[V]OutputDirectory=\f[R], \f[V]--output-dir=\f[R], \f[V]-O\f[R]
Path to a directory where to place all generated artifacts.
If this is not specified and the directory \f[V]mkosi.output/\f[R]
exists in the local directory, it is automatically used for this
purpose.
.TP
\f[V]WorkspaceDirectory=\f[R], \f[V]--workspace-dir=\f[R]
Path to a directory where to store data required temporarily while
building the image.
This directory should have enough space to store the full OS image,
though in most modes the actually used disk space is smaller.
If not specified, a subdirectory of \f[V]$XDG_CACHE_HOME\f[R] (if set),
\f[V]$HOME/.cache\f[R] (if set) or \f[V]/var/tmp\f[R] is used.
The data in this directory is removed automatically after each build.
It\[cq]s safe to manually remove the contents of this directory should
an \f[V]mkosi\f[R] invocation be aborted abnormally (for example, due to
reboot/power failure).
.TP
\f[V]CacheDirectory=\f[R], \f[V]--cache-dir=\f[R]
Takes a path to a directory to use as the incremental cache directory
for the incremental images produced when the \f[V]Incremental=\f[R]
option is enabled.
If this option is not used, but a \f[V]mkosi.cache/\f[R] directory is
found in the local directory it is automatically used for this purpose.
.TP
\f[V]PackageCacheDirectory=\f[R], \f[V]--package-cache-dir\f[R]
Takes a path to a directory to use as the package cache directory for
the distribution package manager used.
If unset, a suitable directory in the user\[cq]s home directory or
system is used.
.TP
\f[V]BuildDirectory=\f[R], \f[V]--build-dir=\f[R]
Takes a path to a directory to use as the build directory for build
systems that support out-of-tree builds (such as Meson).
The directory used this way is shared between repeated builds, and
allows the build system to reuse artifacts (such as object files,
executable, \&...)
generated on previous invocations.
The build scripts can find the path to this directory in the
\f[V]$BUILDDIR\f[R] environment variable.
This directory is mounted into the image\[cq]s root directory when
\f[V]mkosi-chroot\f[R] is invoked during execution of the build scripts.
If this option is not specified, but a directory
\f[V]mkosi.builddir/\f[R] exists in the local directory it is
automatically used for this purpose (also see the \f[B]Files\f[R]
section below).
.TP
\f[V]ImageVersion=\f[R], \f[V]--image-version=\f[R]
Configure the image version.
This accepts any string, but it is recommended to specify a series of
dot separated components.
The version may also be configured in a file \f[V]mkosi.version\f[R] in
which case it may be conveniently managed via the \f[V]bump\f[R] verb or
the \f[V]--auto-bump\f[R] option.
When specified the image version is included in the default output file
name, i.e.\ instead of \f[V]image.raw\f[R] the default will be
\f[V]image_0.1.raw\f[R] for version \f[V]0.1\f[R] of the image, and
similar.
The version is also passed via the \f[V]$IMAGE_VERSION\f[R] to any build
scripts invoked (which may be useful to patch it into
\f[V]/etc/os-release\f[R] or similar, in particular the
\f[V]IMAGE_VERSION=\f[R] field of it).
.TP
\f[V]ImageId=\f[R], \f[V]--image-id=\f[R]
Configure the image identifier.
This accepts a freeform string that shall be used to identify the image
with.
If set the default output file will be named after it (possibly suffixed
with the version).
The identifier is also passed via the \f[V]$IMAGE_ID\f[R] to any build
scripts invoked.
The image ID is automatically added to \f[V]/usr/lib/os-release\f[R].
.TP
\f[V]SplitArtifacts=\f[R], \f[V]--split-artifacts\f[R]
If specified and building a disk image, pass \f[V]--split=yes\f[R] to
systemd-repart to have it write out split partition files for each
configured partition.
Read the
man (https://www.freedesktop.org/software/systemd/man/systemd-repart.html#--split=BOOL)
page for more information.
This is useful in A/B update scenarios where an existing disk image
shall be augmented with a new version of a root or \f[V]/usr\f[R]
partition along with its Verity partition and unified kernel.
.TP
\f[V]RepartDirectories=\f[R], \f[V]--repart-dir=\f[R]
Paths to directories containing systemd-repart partition definition
files that are used when mkosi invokes systemd-repart when building a
disk image.
If \f[V]mkosi.repart/\f[R] exists in the local directory, it will be
used for this purpose as well.
Note that mkosi invokes repart with \f[V]--root=\f[R] set to the root of
the image root, so any \f[V]CopyFiles=\f[R] source paths in partition
definition files will be relative to the image root directory.
.TP
\f[V]SectorSize=\f[R], \f[V]--sector-size=\f[R]
Override the default sector size that systemd-repart uses when building
a disk image.
.TP
\f[V]RepartOffline=\f[R], \f[V]--repart-offline=\f[R]
Specifies whether to build disk images using loopback devices.
Enabled by default.
When enabled, \f[V]systemd-repart\f[R] will not use loopback devices to
build disk images.
When disabled, \f[V]systemd-repart\f[R] will always use loopback devices
to build disk images.
Note that when using \f[V]RepartOffline=no\f[R] mkosi cannot run
unprivileged and the image build has to be done as the root user outside
of any containers and with loopback devices available on the host
system.
There are currently two known scenarios where \f[V]RepartOffline=no\f[R]
has to be used.
The first is when using \f[V]Subvolumes=\f[R] in a repart partition
definition file, as subvolumes cannot be created without using loopback
devices.
The second is when creating a system with SELinux and an XFS root
partition.
Because \f[V]mkfs.xfs\f[R] does not support populating an XFS filesystem
with extended attributes, loopback devices have to be used to ensure the
SELinux extended attributes end up in the generated XFS filesystem.
.TP
\f[V]Overlay=\f[R], \f[V]--overlay\f[R]
When used together with \f[V]BaseTrees=\f[R], the output will consist
only out of changes to the specified base trees.
Each base tree is attached as a lower layer in an overlayfs structure,
and the output becomes the upper layer, initially empty.
Thus files that are not modified compared to the base trees will not be
present in the final output.
This option may be used to create systemd \f[I]system extensions\f[R] or
\f[I]portable
services\f[R] (https://uapi-group.org/specifications/specs/extension_image).
.TP
\f[V]UseSubvolumes=\f[R], \f[V]--use-subvolumes=\f[R]
Takes a boolean or \f[V]auto\f[R].
Enables or disables use of btrfs subvolumes for directory tree outputs.
If enabled, mkosi will create the root directory as a btrfs subvolume
and use btrfs subvolume snapshots where possible to copy base or cached
trees which is much faster than doing a recursive copy.
If explicitly enabled and \f[V]btrfs\f[R] is not installed or subvolumes
cannot be created, an error is raised.
If \f[V]auto\f[R], missing \f[V]btrfs\f[R] or failures to create
subvolumes are ignored.
.TP
\f[V]Seed=\f[R], \f[V]--seed=\f[R]
Takes a UUID as argument or the special value \f[V]random\f[R].
Overrides the seed that
\f[V]systemd-repart(8)\f[R] (https://www.freedesktop.org/software/systemd/man/systemd-repart.service.html)
uses when building a disk image.
This is useful to achieve reproducible builds, where deterministic UUIDs
and other partition metadata should be derived on each build.
.TP
\f[V]SourceDateEpoch=\f[R], \f[V]--source-date-epoch=\f[R]
Takes a timestamp as argument.
Resets file modification times of all files to this timestamp.
The variable is also propagated to systemd-repart and scripts executed
by mkosi.
If not set explicitly, \f[V]SOURCE_DATE_EPOCH\f[R] from
\f[V]--environment\f[R] and from the host environment are tried in that
order.
This is useful to make builds reproducible.
See
SOURCE_DATE_EPOCH (https://reproducible-builds.org/specs/source-date-epoch/)
for more information.
.SS [Content] Section
.TP
\f[V]Packages=\f[R], \f[V]--package=\f[R], \f[V]-p\f[R]
Install the specified distribution packages (i.e.\ RPM, DEB, \&...)
in the image.
Takes a comma separated list of package specifications.
This option may be used multiple times in which case the specified
package lists are combined.
Use \f[V]BuildPackages=\f[R] to specify packages that shall only be
installed in an overlay that is mounted when the prepare scripts are
executed with the \f[V]build\f[R] argument and when the build scripts
are executed.
The types and syntax of \f[I]package specifications\f[R] that are
allowed depend on the package installer (e.g.\ \f[V]dnf\f[R] for
\f[V]rpm\f[R]-based distros or \f[V]apt\f[R] for \f[V]deb\f[R]-based
distros), but may include package names, package names with version
and/or architecture, package name globs, paths to packages in the file
system, package groups, and virtual provides, including file paths.
Example: when using a distro that uses \f[V]dnf\f[R], the following
configuration would install the \f[V]meson\f[R] package (in the latest
version), the 32-bit version of the \f[V]libfdisk-devel\f[R] package,
all available packages that start with the \f[V]git-\f[R] prefix, a
\f[V]systemd\f[R] rpm from the local file system, one of the packages
that provides \f[V]/usr/bin/ld\f[R], the packages in the
\f[I]Development Tools\f[R] group, and the package that contains the
\f[V]mypy\f[R] python module.
.IP
.nf
\f[C]
Packages=meson
libfdisk-devel.i686
git-*
prebuilt/rpms/systemd-249-rc1.local.rpm
/usr/bin/ld
\[at]development-tools
python3dist(mypy)
\f[R]
.fi
.PP
: Note that since mkosi runs in a sandbox with most of the host files
unavailable, any local packages have to be mounted into the sandbox
explicitly using \f[V]BuildSources=\f[R].
For example, let\[cq]s say we have a local package located at
\f[V]../my-packages/abc.rpm\f[R] relative to the mkosi working
directory, then we\[cq]d be able to install it as follows:
.IP
.nf
\f[C]
BuildSources=../my-packages:my-packages-in-sandbox
Packages=my-packages-in-sandbox/abc.rpm
\f[R]
.fi
.TP
\f[V]BuildPackages=\f[R], \f[V]--build-package=\f[R]
Similar to \f[V]Packages=\f[R], but configures packages to install only
in an overlay that is made available on top of the image to the prepare
scripts when executed with the \f[V]build\f[R] argument and the build
scripts.
This option should be used to list packages containing header files,
compilers, build systems, linkers and other build tools the
\f[V]mkosi.build\f[R] scripts require to operate.
Note that packages listed here will be absent in the final image.
.TP
\f[V]PackageDirectories=\f[R], \f[V]--package-directory=\f[R]
Specify directories containing extra packages to be made available
during the build.
\f[V]mkosi\f[R] will create a local repository containing all packages
in these directories and make it available when installing packages or
running scripts.
Note that this local repository is also made available when running
scripts.
Build scripts can add more packages to the local repository by placing
the built packages in \f[V]$PACKAGEDIR\f[R].
.TP
\f[V]WithRecommends=\f[R], \f[V]--with-recommends=\f[R]
Configures whether to install recommended or weak dependencies,
depending on how they are named by the used package manager, or not.
By default, recommended packages are not installed.
This is only used for package managers that support the concept, which
are currently apt, dnf and zypper.
.TP
\f[V]WithDocs=\f[R], \f[V]--with-docs\f[R]
Include documentation in the image.
Enabled by default.
When disabled, if the underlying distribution package manager supports
it documentation is not included in the image.
The \f[V]$WITH_DOCS\f[R] environment variable passed to the
\f[V]mkosi.build\f[R] scripts is set to \f[V]0\f[R] or \f[V]1\f[R]
depending on whether this option is enabled or disabled.
.TP
\f[V]BaseTrees=\f[R], \f[V]--base-tree=\f[R]
Takes a comma separated list of paths to use as base trees.
When used, these base trees are each copied into the OS tree and form
the base distribution instead of installing the distribution from
scratch.
Only extra packages are installed on top of the ones already installed
in the base trees.
Note that for this to work properly, the base image still needs to
contain the package manager metadata by setting
\f[V]CleanPackageMetadata=no\f[R] (see \f[V]CleanPackageMetadata=\f[R]).
Instead of a directory, a tar file or a disk image may be provided.
In this case it is unpacked into the OS tree.
This mode of operation allows setting permissions and file ownership
explicitly, in particular for projects stored in a version control
system such as \f[V]git\f[R] which retain full file ownership and access
mode metadata for committed files.
.TP
\f[V]SkeletonTrees=\f[R], \f[V]--skeleton-tree=\f[R]
Takes a comma separated list of colon separated path pairs.
The first path of each pair refers to a directory to copy into the OS
tree before invoking the package manager.
The second path of each pair refers to the target directory inside the
image.
If the second path is not provided, the directory is copied on top of
the root directory of the image.
The second path is always interpreted as an absolute path.
Use this to insert files and directories into the OS tree before the
package manager installs any packages.
If the \f[V]mkosi.skeleton/\f[R] directory is found in the local
directory it is also used for this purpose with the root directory as
target (also see the \f[B]Files\f[R] section below).
Note that skeleton trees are cached and any changes to skeleton trees
after a cached image has been built (when using \f[V]Incremental=\f[R])
are only applied when the cached image is rebuilt (by using
\f[V]-ff\f[R] or running \f[V]mkosi -f clean\f[R]).
As with the base tree logic above, instead of a directory, a tar file
may be provided too.
\f[V]mkosi.skeleton.tar\f[R] will be automatically used if found in the
local directory.
.TP
\f[V]ExtraTrees=\f[R], \f[V]--extra-tree=\f[R]
Takes a comma separated list of colon separated path pairs.
The first path of each pair refers to a directory to copy from the host
into the image.
The second path of each pair refers to the target directory inside the
image.
If the second path is not provided, the directory is copied on top of
the root directory of the image.
The second path is always interpreted as an absolute path.
Use this to override any default configuration files shipped with the
distribution.
If the \f[V]mkosi.extra/\f[R] directory is found in the local directory
it is also used for this purpose with the root directory as target.
(also see the \f[B]Files\f[R] section below).
As with the base tree logic above, instead of a directory, a tar file
may be provided too.
\f[V]mkosi.extra.tar\f[R] will be automatically used if found in the
local directory.
.TP
\f[V]RemovePackages=\f[R], \f[V]--remove-package=\f[R]
Takes a comma-separated list of package specifications for removal, in
the same format as \f[V]Packages=\f[R].
The removal will be performed as one of the last steps.
This step is skipped if \f[V]CleanPackageMetadata=no\f[R] is used.
.TP
\f[V]RemoveFiles=\f[R], \f[V]--remove-files=\f[R]
Takes a comma-separated list of globs.
Files in the image matching the globs will be purged at the end.
.TP
\f[V]CleanPackageMetadata=\f[R], \f[V]--clean-package-metadata=\f[R]
Enable/disable removal of package manager databases and repository
metadata at the end of installation.
Can be specified as \f[V]true\f[R], \f[V]false\f[R], or \f[V]auto\f[R]
(the default).
With \f[V]auto\f[R], package manager databases and repository metadata
will be removed if the respective package manager executable is
\f[I]not\f[R] present at the end of the installation.
.TP
\f[V]SyncScripts=\f[R], \f[V]--sync-script=\f[R]
Takes a comma-separated list of paths to executables that are used as
the sync scripts for this image.
See the \f[B]Scripts\f[R] section for more information.
.TP
\f[V]PrepareScripts=\f[R], \f[V]--prepare-script=\f[R]
Takes a comma-separated list of paths to executables that are used as
the prepare scripts for this image.
See the \f[B]Scripts\f[R] section for more information.
.TP
\f[V]BuildScripts=\f[R], \f[V]--build-script=\f[R]
Takes a comma-separated list of paths to executables that are used as
the build scripts for this image.
See the \f[B]Scripts\f[R] section for more information.
.TP
\f[V]PostInstallationScripts=\f[R], \f[V]--postinst-script=\f[R]
Takes a comma-separated list of paths to executables that are used as
the post-installation scripts for this image.
See the \f[B]Scripts\f[R] section for more information.
.TP
\f[V]FinalizeScripts=\f[R], \f[V]--finalize-script=\f[R]
Takes a comma-separated list of paths to executables that are used as
the finalize scripts for this image.
See the \f[B]Scripts\f[R] section for more information.
.TP
\f[V]BuildSources=\f[R], \f[V]--build-sources=\f[R]
Takes a comma separated list of colon separated path pairs.
The first path of each pair refers to a directory to mount from the
host.
The second path of each pair refers to the directory where the source
directory should be mounted when running scripts.
Every target path is prefixed with \f[V]/work/src\f[R] and all build
sources are sorted lexicographically by their target before mounting, so
that top level paths are mounted first.
If not configured explicitly, the current working directory is mounted
to \f[V]/work/src\f[R].
.TP
\f[V]BuildSourcesEphemeral=\f[R], \f[V]--build-sources-ephemeral=\f[R]
Takes a boolean.
Disabled by default.
Configures whether changes to source directories (The working directory
and configured using \f[V]BuildSources=\f[R]) are persisted.
If enabled, all source directories will be reset to their original state
after scripts (except sync scripts) finish executing.
.TP
\f[V]Environment=\f[R], \f[V]--environment=\f[R]
Adds variables to the environment that package managers and the
prepare/build/postinstall/finalize scripts are executed with.
Takes a space-separated list of variable assignments or just variable
names.
In the latter case, the values of those variables will be passed through
from the environment in which \f[V]mkosi\f[R] was invoked.
This option may be specified more than once, in which case all listed
variables will be set.
If the same variable is set twice, the later setting overrides the
earlier one.
.TP
\f[V]EnvironmentFiles=\f[R], \f[V]--env-file=\f[R]
Takes a comma-separated list of paths to files that contain environment
variable definitions to be added to the scripting environment.
Uses \f[V]mkosi.env\f[R] if it is found in the local directory.
The variables are first read from \f[V]mkosi.env\f[R] if it exists, then
from the given list of files and then from the \f[V]Environment=\f[R]
settings.
.TP
\f[V]WithTests=\f[R], \f[V]--without-tests\f[R], \f[V]-T\f[R]
If set to false (or when the command-line option is used), the
\f[V]$WITH_TESTS\f[R] environment variable is set to \f[V]0\f[R] when
the \f[V]mkosi.build\f[R] scripts are invoked.
This is supposed to be used by the build scripts to bypass any unit or
integration tests that are normally run during the source build process.
Note that this option has no effect unless the \f[V]mkosi.build\f[R]
build scripts honor it.
.TP
\f[V]WithNetwork=\f[R], \f[V]--with-network=\f[R]
When true, enables network connectivity while the build scripts
\f[V]mkosi.build\f[R] are invoked.
By default, the build scripts run with networking turned off.
The \f[V]$WITH_NETWORK\f[R] environment variable is passed to the
\f[V]mkosi.build\f[R] build scripts indicating whether the build is done
with or without network.
.TP
\f[V]Bootable=\f[R], \f[V]--bootable=\f[R]
Takes a boolean or \f[V]auto\f[R].
Enables or disables generation of a bootable image.
If enabled, mkosi will install an EFI bootloader, and add an ESP
partition when the disk image output is used.
If the selected EFI bootloader (See \f[V]Bootloader=\f[R]) is not
installed or no kernel images can be found, the build will fail.
\f[V]auto\f[R] behaves as if the option was enabled, but the build
won\[cq]t fail if either no kernel images or the selected EFI bootloader
can\[cq]t be found.
If disabled, no bootloader will be installed even if found inside the
image, no unified kernel images will be generated and no ESP partition
will be added to the image if the disk output format is used.
.TP
\f[V]Bootloader=\f[R], \f[V]--bootloader=\f[R]
Takes one of \f[V]none\f[R], \f[V]systemd-boot\f[R], \f[V]uki\f[R] or
\f[V]grub\f[R].
Defaults to \f[V]systemd-boot\f[R].
If set to \f[V]none\f[R], no EFI bootloader will be installed into the
image.
If set to \f[V]systemd-boot\f[R], systemd-boot will be installed and for
each installed kernel, a UKI will be generated and stored in
\f[V]EFI/Linux\f[R] in the ESP.
If set to \f[V]uki\f[R], a single UKI will be generated for the latest
installed kernel (the one with the highest version) which is installed
to \f[V]EFI/BOOT/BOOTX64.EFI\f[R] in the ESP.
If set to \f[V]grub\f[R], for each installed kernel, a UKI will be
generated and stored in \f[V]EFI/Linux\f[R] in the ESP.
For each generated UKI, a menu entry is appended to the grub
configuration in \f[V]grub/grub.cfg\f[R] in the ESP which chainloads
into the UKI.
A shim grub.cfg is also written to \f[V]EFI/<distribution>/grub.cfg\f[R]
in the ESP which loads \f[V]grub/grub.cfg\f[R] in the ESP for
compatibility with signed versions of grub which load the grub
configuration from this location.
Note that we do not yet install grub to the ESP when
\f[V]Bootloader=\f[R] is set to \f[V]grub\f[R].
This has to be done manually in a postinst or finalize script.
The grub EFI binary should be installed to
\f[V]/efi/EFI/BOOT/BOOTX64.EFI\f[R] (or similar depending on the
architecture) and should be configured to load its configuration from
\f[V]EFI/<distribution>/grub.cfg\f[R] in the ESP.
Signed versions of grub shipped by distributions will load their
configuration from this location by default.
.TP
\f[V]BiosBootloader=\f[R], \f[V]--bios-bootloader=\f[R]
Takes one of \f[V]none\f[R] or \f[V]grub\f[R].
Defaults to \f[V]none\f[R].
If set to \f[V]none\f[R], no BIOS bootloader will be installed.
If set to \f[V]grub\f[R], grub is installed as the BIOS boot loader if a
bootable image is requested with the \f[V]Bootable=\f[R] option.
If no repart partition definition files are configured, mkosi will add a
grub BIOS boot partition and an EFI system partition to the default
partition definition files.
Note that this option is not mutually exclusive with
\f[V]Bootloader=\f[R].
It is possible to have an image that is both bootable on UEFI and BIOS
by configuring both \f[V]Bootloader=\f[R] and \f[V]BiosBootloader=\f[R].
The grub BIOS boot partition should have UUID
\f[V]21686148-6449-6e6f-744e-656564454649\f[R] and should be at least
1MB.
Even if no EFI bootloader is installed, we still need an ESP for BIOS
boot as that\[cq]s where we store the kernel, initrd and grub modules.
.TP
\f[V]ShimBootloader=\f[R], \f[V]--shim-bootloader=\f[R]
Takes one of \f[V]none\f[R], \f[V]unsigned\f[R], or \f[V]signed\f[R].
Defaults to \f[V]none\f[R].
If set to \f[V]none\f[R], shim and MokManager will not be installed to
the ESP.
If set to \f[V]unsigned\f[R], mkosi will search for unsigned shim and
MokManager EFI binaries and install them.
If \f[V]SecureBoot=\f[R] is enabled, mkosi will sign the unsigned EFI
binaries before installing thel.
If set to \f[V]signed\f[R], mkosi will search for signed EFI binaries
and install those.
Even if \f[V]SecureBoot=\f[R] is enabled, mkosi won\[cq]t sign these
binaries again.
Note that this option only takes effect when an image that is bootable
on UEFI firmware is requested using other options (\f[V]Bootable=\f[R],
\f[V]Bootloader=\f[R]).
Note that when this option is enabled, mkosi will only install already
signed bootloader binaries, kernel image files and unified kernel images
as self-signed binaries would not be accepted by the signed version of
shim.
.TP
\f[V]UnifiedKernelImages=\f[R], \f[V]--unified-kernel-images=\f[R]
Specifies whether to use unified kernel images or not when
\f[V]Bootloader=\f[R] is set to \f[V]systemd-boot\f[R] or
\f[V]grub\f[R].
Takes a boolean value or \f[V]auto\f[R].
Defaults to \f[V]auto\f[R].
If enabled, unified kernel images are always used and the build will
fail if any components required to build unified kernel images are
missing.
If set to \f[V]auto\f[R], unified kernel images will be used if all
necessary components are available.
Otherwise Type 1 entries as defined by the Boot Loader Specification
will be used instead.
If disabled, Type 1 entries will always be used.
.TP
\f[V]Initrds=\f[R], \f[V]--initrd\f[R]
Use user-provided initrd(s).
Takes a comma separated list of paths to initrd files.
This option may be used multiple times in which case the initrd lists
are combined.
If no initrds are specified and a bootable image is requested, mkosi
will automatically build a default initrd.
.TP
\f[V]InitrdPackages=\f[R], \f[V]--initrd-package=\f[R]
Extra packages to install into the default initrd.
Takes a comma separated list of package specifications.
This option may be used multiple times in which case the specified
package lists are combined.
.TP
\f[V]MicrocodeHost=\f[R], \f[V]--microcode-host=\f[R]
When set to true only include microcode for the host\[cq]s CPU in the
image.
.TP
\f[V]KernelCommandLine=\f[R], \f[V]--kernel-command-line=\f[R]
Use the specified kernel command line when building images.
Defaults to \f[V]console=ttyS0\f[R].
For \f[V]arm\f[R], \f[V]s390\f[R] and \f[V]ppc\f[R], \f[V]ttyS0\f[R] is
replaced with \f[V]ttyAMA0\f[R], \f[V]ttysclp0\f[R] or \f[V]hvc0\f[R],
respectively.
.TP
\f[V]KernelModulesInclude=\f[R], \f[V]--kernel-modules-include=\f[R]
Takes a list of regex patterns that specify kernel modules to include in
the image.
Patterns should be relative to the
\f[V]/usr/lib/modules/<kver>/kernel\f[R] directory.
mkosi checks for a match anywhere in the module path
(e.g.\ \f[V]i915\f[R] will match against
\f[V]drivers/gpu/drm/i915.ko\f[R]).
All modules that match any of the specified patterns are included in the
image.
All module and firmware dependencies of the matched modules are included
in the image as well.
This setting takes priority over \f[V]KernelModulesExclude=\f[R] and
only makes sense when used in combination with it because all kernel
modules are included in the image by default.
.TP
\f[V]KernelModulesExclude=\f[R], \f[V]--kernel-modules-exclude=\f[R]
Takes a list of regex patterns that specify modules to exclude from the
image.
Behaves the same as \f[V]KernelModulesInclude=\f[R] except that all
modules that match any of the specified patterns are excluded from the
image.
.TP
\f[V]KernelModulesIncludeHost=\f[R], \f[V]--kernel-modules-include-host=\f[R]
Takes a boolean.
Specifies whether to include the currently loaded modules on the host
system in the image.
This setting takes priority over \f[V]KernelModulesExclude=\f[R] and
only makes sense when used in combination with it because all kernel
modules are included in the image by default.
.TP
\f[V]KernelModulesInitrd=\f[R], \f[V]--kernel-modules-initrd=\f[R]
Enable/Disable generation of the kernel modules initrd when building a
bootable image.
Enabled by default.
If enabled, when building a bootable image, for each kernel that we
assemble a unified kernel image for we generate an extra initrd
containing only the kernel modules for that kernel version and append it
to the prebuilt initrd.
This allows generating kernel independent initrds which are augmented
with the necessary kernel modules when the UKI is assembled.
.TP
\f[V]KernelModulesInitrdInclude=\f[R], \f[V]--kernel-modules-initrd-include=\f[R]
Like \f[V]KernelModulesInclude=\f[R], but applies to the kernel modules
included in the kernel modules initrd.
.TP
\f[V]KernelModulesInitrdExclude=\f[R], \f[V]--kernel-modules-initrd-exclude=\f[R]
Like \f[V]KernelModulesExclude=\f[R], but applies to the kernel modules
included in the kernel modules initrd.
.TP
\f[V]KernelModulesInitrdIncludeHost=\f[R], \f[V]--kernel-modules-initrd-include-host=\f[R]
Like \f[V]KernelModulesIncludeHost=\f[R], but applies to the kernel
modules included in the kernel modules initrd.
.TP
\f[V]Locale=\f[R], \f[V]--locale=\f[R], \f[V]LocaleMessages=\f[R], \f[V]--locale-messages=\f[R], \f[V]Keymap=\f[R], \f[V]--keymap=\f[R], \f[V]Timezone=\f[R], \f[V]--timezone=\f[R], \f[V]Hostname=\f[R], \f[V]--hostname=\f[R], \f[V]RootShell=\f[R], \f[V]--root-shell=\f[R]
The settings \f[V]Locale=\f[R], \f[V]--locale=\f[R],
\f[V]LocaleMessages=\f[R], \f[V]--locale-messages=\f[R],
\f[V]Keymap=\f[R], \f[V]--keymap=\f[R], \f[V]Timezone=\f[R],
\f[V]--timezone=\f[R], \f[V]Hostname=\f[R], \f[V]--hostname=\f[R],
\f[V]RootShell=\f[R], \f[V]--root-shell=\f[R] correspond to the
identically named systemd-firstboot options.
See the systemd firstboot
manpage (https://www.freedesktop.org/software/systemd/man/systemd-firstboot.html)
for more information.
Additionally, where applicable, the corresponding systemd credentials
for these settings are written to \f[V]/usr/lib/credstore\f[R], so that
they apply even if only \f[V]/usr\f[R] is shipped in the image.
.TP
\f[V]RootPassword=\f[R], \f[V]--root-password=\f[R],
Set the system root password.
If this option is not used, but a \f[V]mkosi.rootpw\f[R] file is found
in the local directory, the password is automatically read from it.
If the password starts with \f[V]hashed:\f[R], it is treated as an
already hashed root password.
The root password is also stored in \f[V]/usr/lib/credstore\f[R] under
the appropriate systemd credential so that it applies even if only
\f[V]/usr\f[R] is shipped in the image.
To create an unlocked account without any password use \f[V]hashed:\f[R]
without a hash.
.TP
\f[V]Autologin=\f[R], \f[V]--autologin\f[R]
Enable autologin for the \f[V]root\f[R] user on \f[V]/dev/pts/0\f[R]
(nspawn), \f[V]/dev/tty1\f[R] and \f[V]/dev/ttyS0\f[R].
.TP
\f[V]MakeInitrd=\f[R], \f[V]--make-initrd\f[R]
Add \f[V]/etc/initrd-release\f[R] and \f[V]/init\f[R] to the image so
that it can be used as an initramfs.
.TP
\f[V]Ssh=\f[R], \f[V]--ssh\f[R]
If specified, an sshd socket unit and matching service are installed in
the final image that expose SSH over VSock.
When building with this option and running the image using
\f[V]mkosi qemu\f[R], the \f[V]mkosi ssh\f[R] command can be used to
connect to the container/VM via SSH.
Note that you still have to make sure openssh is installed in the image
to make this option behave correctly.
Run \f[V]mkosi genkey\f[R] to automatically generate an X509 certificate
and private key to be used by mkosi to enable SSH access to any virtual
machines via \f[V]mkosi ssh\f[R].
To access images booted using \f[V]mkosi boot\f[R], use
\f[V]machinectl\f[R].
.TP
\f[V]SELinuxRelabel=\f[R], \f[V]--selinux-relabel=\f[R]
Specifies whether to relabel files to match the image\[cq]s SELinux
policy.
Takes a boolean value or \f[V]auto\f[R].
Defaults to \f[V]auto\f[R].
If disabled, files will not relabeled.
If enabled, an SELinux policy has to be installed in the image and
\f[V]setfiles\f[R] has to be available to relabel files.
If any errors occur during \f[V]setfiles\f[R], the build will fail.
If set to \f[V]auto\f[R], files will be relabeled if an SELinux policy
is installed in the image and if \f[V]setfiles\f[R] is available.
Any errors occurred during \f[V]setfiles\f[R] will be ignored.
Note that when running unprivileged, \f[V]setfiles\f[R] will fail to set
any labels that are not in the host\[cq]s SELinux policy.
To ensure \f[V]setfiles\f[R] succeeds without errors, make sure to run
mkosi as root or build from a host system with the same SELinux policy
as the image you\[cq]re building.
.SS [Validation] Section
.TP
\f[V]SecureBoot=\f[R], \f[V]--secure-boot\f[R]
Sign systemd-boot (if it is not signed yet) and any generated unified
kernel images for UEFI SecureBoot.
.TP
\f[V]SecureBootAutoEnroll=\f[R], \f[V]--secure-boot-auto-enroll=\f[R]
Set up automatic enrollment of the secure boot keys in virtual machines
as documented in the systemd-boot man
page (https://www.freedesktop.org/software/systemd/man/systemd-boot.html)
if \f[V]SecureBoot=\f[R] is used.
Note that systemd-boot will only do automatic secure boot key enrollment
in virtual machines starting from systemd v253.
To do auto enrollment on systemd v252 or on bare metal machines, write a
systemd-boot configuration file to \f[V]/efi/loader/loader.conf\f[R]
using an extra tree with \f[V]secure-boot-enroll force\f[R] or
\f[V]secure-boot-enroll manual\f[R] in it.
Auto enrollment is not supported on systemd versions older than v252.
Defaults to \f[V]yes\f[R].
.TP
\f[V]SecureBootKey=\f[R], \f[V]--secure-boot-key=\f[R]
Path to the PEM file containing the secret key for signing the UEFI
kernel image if \f[V]SecureBoot=\f[R] is used and PCR signatures when
\f[V]SignExpectedPcr=\f[R] is also used.
When \f[V]SecureBootKeySource=\f[R] is specified, the input type depends
on the source.
.TP
\f[V]SecureBootKeySource=\f[R], \f[V]--secure-boot-key-source=\f[R]
Source of \f[V]SecureBootKey=\f[R], to support OpenSSL engines.
E.g.: \f[V]--secure-boot-key-source=engine:pkcs11\f[R]
.TP
\f[V]SecureBootCertificate=\f[R], \f[V]--secure-boot-certificate=\f[R]
Path to the X.509 file containing the certificate for the signed UEFI
kernel image, if \f[V]SecureBoot=\f[R] is used.
.TP
\f[V]SecureBootSignTool=\f[R], \f[V]--secure-boot-sign-tool\f[R]
Tool to use to sign secure boot PE binaries.
Takes one of \f[V]sbsign\f[R], \f[V]pesign\f[R] or \f[V]auto\f[R].
Defaults to \f[V]auto\f[R].
If set to \f[V]auto\f[R], either sbsign or pesign are used if available,
with sbsign being preferred if both are installed.
.TP
\f[V]VerityKey=\f[R], \f[V]--verity-key=\f[R]
Path to the PEM file containing the secret key for signing the verity
signature, if a verity signature partition is added with systemd-repart.
When \f[V]VerityKeySource=\f[R] is specified, the input type depends on
the source.
.TP
\f[V]VerityKeySource=\f[R], \f[V]--verity-key-source=\f[R]
Source of \f[V]VerityKey=\f[R], to support OpenSSL engines.
E.g.: \f[V]--verity-key-source=engine:pkcs11\f[R]
.TP
\f[V]VerityCertificate=\f[R], \f[V]--verity-certificate=\f[R]
Path to the X.509 file containing the certificate for signing the verity
signature, if a verity signature partition is added with systemd-repart.
.TP
\f[V]SignExpectedPcr=\f[R], \f[V]--sign-expected-pcr\f[R]
Measure the components of the unified kernel image (UKI) using
\f[V]systemd-measure\f[R] and embed the PCR signature into the unified
kernel image.
This option takes a boolean value or the special value \f[V]auto\f[R],
which is the default, which is equal to a true value if the
\f[V]systemd-measure\f[R] binary is in \f[V]PATH\f[R].
Depends on \f[V]SecureBoot=\f[R] being enabled and key from
\f[V]SecureBootKey=\f[R].
.TP
\f[V]Passphrase=\f[R], \f[V]--passphrase\f[R]
Specify the path to a file containing the passphrase to use for LUKS
encryption.
It should contain the passphrase literally, and not end in a newline
character (i.e.\ in the same format as cryptsetup and
\f[V]/etc/crypttab\f[R] expect the passphrase files).
The file must have an access mode of 0600 or less.
.TP
\f[V]Checksum=\f[R], \f[V]--checksum\f[R]
Generate a \f[V]SHA256SUMS\f[R] file of all generated artifacts after
the build is complete.
.TP
\f[V]Sign=\f[R], \f[V]--sign\f[R]
Sign the generated \f[V]SHA256SUMS\f[R] using \f[V]gpg\f[R] after
completion.
.TP
\f[V]Key=\f[R], \f[V]--key=\f[R]
Select the \f[V]gpg\f[R] key to use for signing \f[V]SHA256SUMS\f[R].
This key must be already present in the \f[V]gpg\f[R] keyring.
.SS [Host] Section
.TP
\f[V]Incremental=\f[R], \f[V]--incremental=\f[R], \f[V]-i\f[R]
Enable incremental build mode.
In this mode, a copy of the OS image is created immediately after all OS
packages are installed and the prepare scripts have executed but before
the \f[V]mkosi.build\f[R] scripts are invoked (or anything that happens
after it).
On subsequent invocations of \f[V]mkosi\f[R] with the \f[V]-i\f[R]
switch this cached image may be used to skip the OS package
installation, thus drastically speeding up repetitive build times.
Note that while there is some rudimentary cache invalidation, it is
definitely not perfect.
In order to force rebuilding of the cached image, combine \f[V]-i\f[R]
with \f[V]-ff\f[R] to ensure the cached image is first removed and then
re-created.
.TP
\f[V]NSpawnSettings=\f[R], \f[V]--settings=\f[R]
Specifies a \f[V].nspawn\f[R] settings file for \f[V]systemd-nspawn\f[R]
to use in the \f[V]boot\f[R] and \f[V]shell\f[R] verbs, and to place
next to the generated image file.
This is useful to configure the \f[V]systemd-nspawn\f[R] environment
when the image is run.
If this setting is not used but an \f[V]mkosi.nspawn\f[R] file found in
the local directory it is automatically used for this purpose.
.TP
\f[V]ExtraSearchPaths=\f[R], \f[V]--extra-search-path=\f[R]
List of colon-separated paths to look for tools in, before using the
regular \f[V]$PATH\f[R] search path.
.TP
\f[V]QemuGui=\f[R], \f[V]--qemu-gui=\f[R]
If enabled, qemu is executed with its graphical interface instead of
with a serial console.
.TP
\f[V]QemuSmp=\f[R], \f[V]--qemu-smp=\f[R]
When used with the \f[V]qemu\f[R] verb, this options sets
\f[V]qemu\f[R]\[cq]s \f[V]-smp\f[R] argument which controls the number
of guest\[cq]s CPUs.
Defaults to \f[V]2\f[R].
.TP
\f[V]QemuMem=\f[R], \f[V]--qemu-mem=\f[R]
When used with the \f[V]qemu\f[R] verb, this options sets
\f[V]qemu\f[R]\[cq]s \f[V]-m\f[R] argument which controls the amount of
guest\[cq]s RAM.
Defaults to \f[V]2G\f[R].
.TP
\f[V]QemuKvm=\f[R], \f[V]--qemu-kvm=\f[R]
When used with the \f[V]qemu\f[R] verb, this option specifies whether
QEMU should use KVM acceleration.
Takes a boolean value or \f[V]auto\f[R].
Defaults to \f[V]auto\f[R].
.TP
\f[V]QemuVsock=\f[R], \f[V]--qemu-vsock=\f[R]
When used with the \f[V]qemu\f[R] verb, this option specifies whether
QEMU should be configured with a vsock.
Takes a boolean value or \f[V]auto\f[R].
Defaults to \f[V]auto\f[R].
.TP
\f[V]QemuVsockConnectionId=\f[R], \f[V]--qemu-vsock-cid=\f[R]
When used with the \f[V]qemu\f[R] verb, this option specifies the vsock
connection ID to use.
Takes a number in the interval \f[V][3, 0xFFFFFFFF)\f[R] or
\f[V]hash\f[R] or \f[V]auto\f[R].
Defaults to \f[V]hash\f[R].
When set to \f[V]hash\f[R], the connection ID will be derived from the
full path to the image.
When set to \f[V]auto\f[R], \f[V]mkosi\f[R] will try to find a free
connection ID automatically.
Otherwise, the provided number will be used as is.
Note that when set to \f[V]auto\f[R], \f[V]mkosi ssh\f[R] cannot be used
as we cannot figure out which free connection ID we found when booting
the image earlier.
.TP
\f[V]QemuSwtpm=\f[R], \f[V]--qemu-swtpm=\f[R]
When used with the \f[V]qemu\f[R] verb, this option specifies whether to
start an instance of swtpm to be used as a TPM with qemu.
This requires swtpm to be installed on the host.
Takes a boolean value or \f[V]auto\f[R].
Defaults to \f[V]auto\f[R].
.TP
\f[V]QemuCdrom=\f[R], \f[V]--qemu-cdrom=\f[R]
When used with the \f[V]qemu\f[R] verb, this option specifies whether to
attach the image to the virtual machine as a CD-ROM device.
Takes a boolean.
Defaults to \f[V]no\f[R].
.TP
\f[V]QemuFirmware=\f[R], \f[V]--qemu-firmware=\f[R]
When used with the \f[V]qemu\f[R] verb, this option specifies which
firmware to use.
Takes one of \f[V]uefi\f[R], \f[V]uefi-secure-boot\f[R], \f[V]bios\f[R],
\f[V]linux\f[R], or \f[V]auto\f[R].
Defaults to \f[V]auto\f[R].
When set to \f[V]uefi\f[R], the OVMF firmware without secure boot
support is used.
When set to \f[V]uefi-secure-boot\f[R], the OVMF firmware with secure
boot support is used.
When set to \f[V]bios\f[R], the default SeaBIOS firmware is used.
When set to \f[V]linux\f[R], direct kernel boot is used.
See the \f[V]QemuKernel=\f[R] option for more details on which kernel
image is used with direct kernel boot.
When set to \f[V]auto\f[R], \f[V]uefi-secure-boot\f[R] is used if
possible and \f[V]linux\f[R] otherwise.
.TP
\f[V]QemuFirmwareVariables=\f[R], \f[V]--qemu-firmware-variables=\f[R]
When used with the \f[V]qemu\f[R] verb, this option specifies the path
to the the firmware variables file to use.
Currently, this option is only taken into account when the
\f[V]uefi\f[R] or \f[V]uefi-secure-boot\f[R] firmware is used.
If not specified, mkosi will search for the default variables file and
use that instead.
When set to \f[V]microsoft\f[R], a firmware variables file with the
Microsoft secure boot certificates already enrolled will be used.
When set to \f[V]custom\f[R], the secure boot certificate from
\f[V]SecureBootCertificate=\f[R] will be enrolled into the default
firmware variables file.
\f[V]virt-fw-vars\f[R] from the
virt-firmware (https://gitlab.com/kraxel/virt-firmware) project can be
used to customize OVMF variable files.
.TP
\f[V]QemuKernel=\f[R], \f[V]--qemu-kernel=\f[R]
Set the kernel image to use for qemu direct kernel boot.
If not specified, mkosi will use the kernel provided via the command
line (\f[V]-kernel\f[R] option) or latest the kernel that was installed
into the image (or fail if no kernel was installed into the image).
Note that when the \f[V]cpio\f[R] output format is used, direct kernel
boot is used regardless of the configured firmware.
Depending on the configured firmware, qemu might boot the kernel itself
or using the configured firmware.
.TP
\f[V]QemuDrives=\f[R], \f[V]--qemu-drive=\f[R]
Add a qemu drive.
Takes a colon-delimited string of format
\f[V]<id>:<size>[:<directory>[:<options>]]\f[R].
\f[V]id\f[R] specifies the qemu id we assign to the drive.
This can be used as the \f[V]drive=\f[R] property in various qemu
devices.
\f[V]size\f[R] specifies the size of the drive.
This takes a size in bytes.
Additionally, the suffixes \f[V]K\f[R], \f[V]M\f[R] and \f[V]G\f[R] can
be used to specify a size in kilobytes, megabytes and gigabytes
respectively.
\f[V]directory\f[R] optionally specifies the directory in which to
create the file backing the drive.
\f[V]options\f[R] optionally specifies extra comma-delimited properties
which are passed verbatim to qemu\[cq]s \f[V]-drive\f[R] option.
Example usage:
.IP
.nf
\f[C]
[Host]
QemuDrives=btrfs:10G
ext4:20G
QemuArgs=-device nvme,serial=btrfs,drive=btrfs
-device nvme,serial=ext4,drive=ext4
\f[R]
.fi
.TP
\f[V]QemuArgs=\f[R]
Space-delimited list of additional arguments to pass when invoking qemu.
.TP
\f[V]Ephemeral=\f[R], \f[V]--ephemeral\f[R]
When used with the \f[V]shell\f[R], \f[V]boot\f[R], or \f[V]qemu\f[R]
verbs, this option runs the specified verb on a temporary snapshot of
the output image that is removed immediately when the container
terminates.
Taking the temporary snapshot is more efficient on file systems that
support reflinks natively (btrfs or xfs) than on more traditional file
systems that do not (ext4).
.TP
\f[V]Credentials=\f[R], \f[V]--credential=\f[R]
Set credentials to be passed to systemd-nspawn or qemu respectively when
\f[V]mkosi shell/boot\f[R] or \f[V]mkosi qemu\f[R] are used.
This option takes a space separated list of key=value assignments.
.TP
\f[V]KernelCommandLineExtra=\f[R], \f[V]--kernel-command-line-extra=\f[R]
Set extra kernel command line entries that are appended to the kernel
command line at runtime when booting the image.
When booting in a container, these are passed as extra arguments to
systemd.
When booting in a VM, these are appended to the kernel command line via
the SMBIOS io.systemd.stub.kernel-cmdline-extra OEM string.
This will only be picked up by systemd-boot/systemd-stub versions newer
than or equal to v254.
.TP
\f[V]Acl=\f[R], \f[V]--acl=\f[R]
If specified, ACLs will be set on any generated root filesystem
directories that allow the user running mkosi to remove them without
needing privileges.
.TP
\f[V]ToolsTree=\f[R], \f[V]--tools-tree=\f[R]
If specified, programs executed by mkosi to build and boot an image are
looked up inside the given tree instead of in the host system.
Use this option to make image builds more reproducible by always using
the same versions of programs to build the final image instead of
whatever version is installed on the host system.
If this option is not used, but the \f[V]mkosi.tools/\f[R] directory is
found in the local directory it is automatically used for this purpose
with the root directory as target.
Note that when looking up binaries in \f[V]--tools-tree=\f[R], only
\f[V]/usr/bin\f[R] and \f[V]/usr/sbin\f[R] are considered.
Specifically, paths specified by \f[V]--extra-search-path=\f[R] are
ignored when looking up binaries in the given tools tree.
If set to \f[V]default\f[R], mkosi will automatically add an extra tools
tree image and use it as the tools tree.
The following table shows for which distributions default tools tree
packages are defined and which packages are included in those default
tools trees:
.PP
.TS
tab(@);
lw(24.0n) lw(7.7n) lw(7.7n) lw(7.7n) lw(7.7n) lw(5.8n) lw(9.6n).
T{
T}@T{
Fedora
T}@T{
CentOS
T}@T{
Debian
T}@T{
Ubuntu
T}@T{
Arch
T}@T{
openSUSE
T}
_
T{
\f[V]acl\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]apt\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
T}
T{
\f[V]archlinux-keyring\f[R]
T}@T{
X
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
T}
T{
\f[V]attr\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]bash\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]btrfs-progs\f[R]
T}@T{
X
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]bubblewrap\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]ca-certificates\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]coreutils\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]cpio\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]curl\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]debian-keyring\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
T}
T{
\f[V]diffutils\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]distribution-gpg-keys\f[R]
T}@T{
X
T}@T{
X
T}@T{
T}@T{
T}@T{
T}@T{
X
T}
T{
\f[V]dnf\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]dnf-plugins-core\f[R]
T}@T{
X
T}@T{
X
T}@T{
T}@T{
T}@T{
T}@T{
X
T}
T{
\f[V]dnf5\f[R]
T}@T{
X
T}@T{
T}@T{
T}@T{
T}@T{
T}@T{
T}
T{
\f[V]dnf5-plugins\f[R]
T}@T{
X
T}@T{
T}@T{
T}@T{
T}@T{
T}@T{
T}
T{
\f[V]dosfstools\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]e2fsprogs\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]edk2-ovmf\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]erofs-utils\f[R]
T}@T{
X
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]findutils\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]git\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]grep\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]jq\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]kmod\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]less\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]mtools\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]nano\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]openssh\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]openssl\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]sed\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]pacman\f[R]
T}@T{
X
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
T}
T{
\f[V]pesign\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]policycoreutils\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
T}@T{
X
T}
T{
\f[V]qemu\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]sbsigntools\f[R]
T}@T{
X
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]socat\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]squashfs-tools\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]strace\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]swtpm\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]systemd\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]ukify\f[R]
T}@T{
X
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]tar\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]ubuntu-keyring\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
T}
T{
\f[V]util-linux\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]virtiofsd\f[R]
T}@T{
X
T}@T{
X
T}@T{
T}@T{
T}@T{
X
T}@T{
X
T}
T{
\f[V]virt-firmware\f[R]
T}@T{
X
T}@T{
X
T}@T{
T}@T{
T}@T{
X
T}@T{
T}
T{
\f[V]xfsprogs\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]xz\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]zstd\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]zypper\f[R]
T}@T{
X
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
T}
.TE
.TP
\f[V]ToolsTreeDistribution=\f[R], \f[V]--tools-tree-distribution=\f[R]
Set the distribution to use for the default tools tree.
By default, the same distribution as the image that\[cq]s being built is
used, except for CentOS and Ubuntu images, in which case Fedora and
Debian are used respectively.
.TP
\f[V]ToolsTreeRelease=\f[R], \f[V]--tools-tree-release=\f[R]
Set the distribution release to use for the default tools tree.
By default, the hardcoded default release in mkosi for the distribution
is used.
.TP
\f[V]ToolsTreeMirror=\f[R], \f[V]--tools-tree-mirror=\f[R]
Set the mirror to use for the default tools tree.
By default, the default mirror for the tools tree distribution is used.
.TP
\f[V]ToolsTreeRepositories=\f[R], \f[V]--tools-tree-repository\f[R]
Same as \f[V]Repositories=\f[R] but for the default tools tree.
.TP
\f[V]ToolsTreePackageManagerTrees=\f[R], \f[V]--tools-tree-package-manager-tree=\f[R]
Same as \f[V]PackageManagerTrees=\f[R] but for the default tools tree.
.TP
\f[V]ToolsTreePackages=\f[R], \f[V]--tools-tree-packages=\f[R]
Extra packages to install into the default tools tree.
Takes a comma separated list of package specifications.
This option may be used multiple times in which case the specified
package lists are combined.
.TP
\f[V]RuntimeTrees=\f[R], \f[V]--runtime-tree=\f[R]
Takes a colon separated pair of paths.
The first path refers to a directory to mount into any machine
(container or VM) started by mkosi.
The second path refers to the target directory inside the machine.
If the second path is not provided, the directory is mounted below
\f[V]/root/src\f[R] in the machine.
If the second path is relative, it is interpreted relative to
\f[V]/root/src\f[R] in the machine.
For each mounted directory, the uid and gid of the user running mkosi
are mapped to the root user in the machine.
This means that all the files and directories will appear as if
they\[cq]re owned by root in the machine, and all new files and
directories created by root in the machine in these directories will be
owned by the user running mkosi on the host.
Note that when using \f[V]mkosi qemu\f[R] with this feature systemd v254
or newer has to be installed in the image.
.TP
\f[V]RuntimeSize=\f[R], \f[V]--runtime-size=\f[R]
If specified, disk images are grown to the specified size before
they\[cq]re booted with systemd-nspawn or qemu.
Takes a size in bytes.
Additionally, the suffixes \f[V]K\f[R], \f[V]M\f[R] and \f[V]G\f[R] can
be used to specify a size in kilobytes, megabytes and gigabytes
respectively.
.TP
\f[V]RuntimeScratch=\f[R]: \f[V]--runtime-scratch=\f[R]
Takes a boolean value or \f[V]auto\f[R].
Specifies whether to mount extra scratch space to \f[V]/var/tmp\f[R].
If enabled, practically unlimited scratch space is made available under
\f[V]/var/tmp\f[R] when booting the image with \f[V]mkosi qemu\f[R],
\f[V]mkosi boot\f[R] or \f[V]mkosi shell\f[R].
Note that using this feature with \f[V]mkosi qemu\f[R] requires systemd
v254 or newer in the guest.
.TP
\f[V]RuntimeNetwork=\f[R]: \f[V]--runtime-network=\f[R]
Takes one of \f[V]user\f[R], \f[V]interface\f[R] or \f[V]none\f[R].
Defaults to \f[V]user\f[R].
Specifies the networking to set up when booting the image.
\f[V]user\f[R] sets up usermode networking.
\f[V]interface\f[R] sets up a virtual network connection between the
host and the image.
This translates to a veth interface for \f[V]mkosi shell\f[R] and
\f[V]mkosi boot\f[R] and a tap interface for \f[V]mkosi qemu\f[R] and
\f[V]mkosi vmspawn\f[R].
Note that when using \f[V]interface\f[R], mkosi does not automatically
configure the host interface.
It is expected that a recent version of \f[V]systemd-networkd\f[R] is
running on the host which will automatically configure the host
interface of the link.
.TP
\f[V]SshKey=\f[R], \f[V]--ssh-key=\f[R]
Path to the X509 private key in PEM format to use to connect to a
virtual machine started with \f[V]mkosi qemu\f[R] and built with the
\f[V]Ssh=\f[R] option enabled via the \f[V]mkosi ssh\f[R] command.
If not configured and \f[V]mkosi.key\f[R] exists in the working
directory, it will automatically be used for this purpose.
Run \f[V]mkosi genkey\f[R] to automatically generate a key in
\f[V]mkosi.key\f[R].
.TP
\f[V]SshCertificate=\f[R], \f[V]--ssh-certificate=\f[R]
Path to the X509 certificate in PEM format to provision as the SSH
public key in virtual machines started with \f[V]mkosi qemu\f[R].
If not configured and \f[V]mkosi.crt\f[R] exists in the working
directory, it will automatically be used for this purpose.
Run \f[V]mkosi genkey\f[R] to automatically generate a certificate in
\f[V]mkosi.crt\f[R].
.SS Specifiers
.PP
The current value of various settings can be accessed when parsing
configuration files by using specifiers.
To write a literal \f[V]%\f[R] character in a configuration file without
treating it as a specifier, use \f[V]%%\f[R].
The following specifiers are understood:
.PP
.TS
tab(@);
l l.
T{
Setting
T}@T{
Specifier
T}
_
T{
\f[V]Distribution=\f[R]
T}@T{
\f[V]%d\f[R]
T}
T{
\f[V]Release=\f[R]
T}@T{
\f[V]%r\f[R]
T}
T{
\f[V]Architecture=\f[R]
T}@T{
\f[V]%a\f[R]
T}
T{
\f[V]Format=\f[R]
T}@T{
\f[V]%t\f[R]
T}
T{
\f[V]Output=\f[R]
T}@T{
\f[V]%o\f[R]
T}
T{
\f[V]OutputDirectory=\f[R]
T}@T{
\f[V]%O\f[R]
T}
T{
\f[V]ImageId=\f[R]
T}@T{
\f[V]%i\f[R]
T}
T{
\f[V]ImageVersion=\f[R]
T}@T{
\f[V]%v\f[R]
T}
.TE
.SS Supported distributions
.PP
Images may be created containing installations of the following
distributions:
.IP \[bu] 2
\f[I]Fedora Linux\f[R]
.IP \[bu] 2
\f[I]Debian\f[R]
.IP \[bu] 2
\f[I]Ubuntu\f[R]
.IP \[bu] 2
\f[I]Arch Linux\f[R]
.IP \[bu] 2
\f[I]openSUSE\f[R]
.IP \[bu] 2
\f[I]Mageia\f[R]
.IP \[bu] 2
\f[I]CentOS\f[R]
.IP \[bu] 2
\f[I]RHEL\f[R]
.IP \[bu] 2
\f[I]RHEL UBI\f[R]
.IP \[bu] 2
\f[I]OpenMandriva\f[R]
.IP \[bu] 2
\f[I]Rocky Linux\f[R]
.IP \[bu] 2
\f[I]Alma Linux\f[R]
.IP \[bu] 2
\f[I]None\f[R] (\f[B]Requires the user to provide a pre-built
rootfs\f[R])
.PP
In theory, any distribution may be used on the host for building images
containing any other distribution, as long as the necessary tools are
available.
Specifically, any distribution that packages \f[V]apt\f[R] may be used
to build \f[I]Debian\f[R] or \f[I]Ubuntu\f[R] images.
Any distribution that packages \f[V]dnf\f[R] may be used to build images
for any of the rpm-based distributions.
Any distro that packages \f[V]pacman\f[R] may be used to build \f[I]Arch
Linux\f[R] images.
Any distribution that packages \f[V]zypper\f[R] may be used to build
\f[I]openSUSE\f[R] images.
Other distributions and build automation tools for embedded Linux
systems such as Buildroot, OpenEmbedded and Yocto Project may be used by
selecting the \f[V]custom\f[R] distribution, and populating the rootfs
via a combination of base trees, skeleton trees, and prepare scripts.
.PP
Currently, \f[I]Fedora Linux\f[R] packages all relevant tools as of
Fedora 28.
.PP
Note that when not using a custom mirror, \f[V]RHEL\f[R] images can only
be built from a host system with a \f[V]RHEL\f[R] subscription
(established using e.g.\ \f[V]subscription-manager\f[R]).
.SH Execution Flow
.PP
Execution flow for \f[V]mkosi build\f[R].
Default values/calls are shown in parentheses.
When building with \f[V]--incremental\f[R] mkosi creates a cache of the
distribution installation if not already existing and replaces the
distribution installation in consecutive runs with data from the cached
one.
.IP "1." 3
Parse CLI options
.IP "2." 3
Parse configuration files
.IP "3." 3
If we\[cq]re not running as root, unshare the user namespace and map the
subuid range configured in \f[V]/etc/subuid\f[R] and
\f[V]/etc/subgid\f[R] into it.
.IP "4." 3
Unshare the mount namespace
.IP "5." 3
Remount the following directories read-only if they exist:
.RS 4
.IP \[bu] 2
\f[V]/usr\f[R]
.IP \[bu] 2
\f[V]/etc\f[R]
.IP \[bu] 2
\f[V]/opt\f[R]
.IP \[bu] 2
\f[V]/srv\f[R]
.IP \[bu] 2
\f[V]/boot\f[R]
.IP \[bu] 2
\f[V]/efi\f[R]
.IP \[bu] 2
\f[V]/media\f[R]
.IP \[bu] 2
\f[V]/mnt\f[R]
.RE
.PP
Then, for each image, we execute the following steps:
.IP " 1." 4
Copy package manager trees into the workspace
.IP " 2." 4
Sync the package manager repository metadata
.IP " 3." 4
Copy base trees (\f[V]--base-tree=\f[R]) into the image
.IP " 4." 4
Reuse a cached image if one is available
.IP " 5." 4
Copy a snapshot of the package manager repository metadata into the
image
.IP " 6." 4
Copy skeleton trees (\f[V]mkosi.skeleton\f[R]) into image
.IP " 7." 4
Install distribution and packages into image
.IP " 8." 4
Run prepare scripts on image with the \f[V]final\f[R] argument
(\f[V]mkosi.prepare\f[R])
.IP " 9." 4
Install build packages in overlay if any build scripts are configured
.IP "10." 4
Run prepare scripts on overlay with the \f[V]build\f[R] argument if any
build scripts are configured (\f[V]mkosi.prepare\f[R])
.IP "11." 4
Cache the image if configured (\f[V]--incremental\f[R])
.IP "12." 4
Run build scripts on image + overlay if any build scripts are configured
(\f[V]mkosi.build\f[R])
.IP "13." 4
Finalize the build if the output format \f[V]none\f[R] is configured
.IP "14." 4
Copy the build scripts outputs into the image
.IP "15." 4
Copy the extra trees into the image (\f[V]mkosi.extra\f[R])
.IP "16." 4
Run post-install scripts (\f[V]mkosi.postinst\f[R])
.IP "17." 4
Write config files required for \f[V]Ssh=\f[R], \f[V]Autologin=\f[R] and
\f[V]MakeInitrd=\f[R]
.IP "18." 4
Install systemd-boot and configure secure boot if configured
(\f[V]--secure-boot\f[R])
.IP "19." 4
Run \f[V]systemd-sysusers\f[R]
.IP "20." 4
Run \f[V]systemd-tmpfiles\f[R]
.IP "21." 4
Run \f[V]systemctl preset-all\f[R]
.IP "22." 4
Run \f[V]depmod\f[R]
.IP "23." 4
Run \f[V]systemd-firstboot\f[R]
.IP "24." 4
Run \f[V]systemd-hwdb\f[R]
.IP "25." 4
Remove packages and files (\f[V]RemovePackages=\f[R],
\f[V]RemoveFiles=\f[R])
.IP "26." 4
Run SELinux relabel is a SELinux policy is installed
.IP "27." 4
Run finalize scripts (\f[V]mkosi.finalize\f[R])
.IP "28." 4
Generate unified kernel image if configured to do so
.IP "29." 4
Generate final output format
.SH Scripts
.PP
To allow for image customization that cannot be implemented using
mkosi\[cq]s builtin features, mkosi supports running scripts at various
points during the image build process that can customize the image as
needed.
Scripts are executed on the host system as root (either real root or
root within the user namespace that mkosi created when running
unprivileged) with a customized environment to simplify modifying the
image.
For each script, the configured build sources (\f[V]BuildSources=\f[R])
are mounted into the current working directory before running the script
in the current working directory.
\f[V]$SRCDIR\f[R] is set to point to the current working directory.
The following scripts are supported:
.IP \[bu] 2
If \f[B]\f[VB]mkosi.sync\f[B]\f[R] (\f[V]SyncScripts=\f[R]) exists, it
is executed before the image is built.
This script may be used to update various sources that are used to build
the image.
One use case is to run \f[V]git pull\f[R] on various source repositories
before building the image.
Specifically, the \f[V]BuildSourcesEphemeral=\f[R] setting does not
apply to sync scripts, which means sync scripts can be used to update
build sources even if \f[V]BuildSourcesEphemeral=\f[R] is enabled.
.IP \[bu] 2
If \f[B]\f[VB]mkosi.prepare\f[B]\f[R] (\f[V]PrepareScripts=\f[R])
exists, it is first called with the \f[V]final\f[R] argument, right
after the software packages are installed.
It is called a second time with the \f[V]build\f[R] command line
parameter, right after the build packages are installed and the build
overlay mounted on top of the image\[cq]s root directory .
This script has network access and may be used to install packages from
other sources than the distro\[cq]s package manager
(e.g.\ \f[V]pip\f[R], \f[V]npm\f[R], \&...), after all software packages
are installed but before the image is cached (if incremental mode is
enabled).
In contrast to a general purpose installation, it is safe to install
packages to the system (\f[V]pip install\f[R], \f[V]npm install -g\f[R])
instead of in \f[V]$SRCDIR\f[R] itself because the build image is only
used for a single project and can easily be thrown away and rebuilt so
there\[cq]s no risk of conflicting dependencies and no risk of polluting
the host system.
.IP \[bu] 2
If \f[B]\f[VB]mkosi.build\f[B]\f[R] (\f[V]BuildScripts=\f[R]) exists, it
is executed with the build overlay mounted on top of the image\[cq]s
root directory.
When running the build script, \f[V]$DESTDIR\f[R] points to a directory
where the script should place any files generated it would like to end
up in the image.
Note that \f[V]make\f[R]/\f[V]automake\f[R]/\f[V]meson\f[R] based build
systems generally honor \f[V]$DESTDIR\f[R], thus making it very natural
to build \f[I]source\f[R] trees from the build script.
After running the build script, the contents of \f[V]$DESTDIR\f[R] are
copied into the image.
.IP \[bu] 2
If \f[B]\f[VB]mkosi.postinst\f[B]\f[R]
(\f[V]PostInstallationScripts=\f[R]) exists, it is executed after the
(optional) build tree and extra trees have been installed.
This script may be used to alter the images without any restrictions,
after all software packages and built sources have been installed.
.IP \[bu] 2
If \f[B]\f[VB]mkosi.finalize\f[B]\f[R] (\f[V]FinalizeScripts=\f[R])
exists, it is executed as the last step of preparing an image.
.PP
If a script uses the \f[V].chroot\f[R] extension, mkosi will chroot into
the image using \f[V]mkosi-chroot\f[R] (see below) before executing the
script.
For example, if \f[V]mkosi.postinst.chroot\f[R] exists, mkosi will
chroot into the image and execute it as the post-installation script.
.PP
Scripts executed by mkosi receive the following environment variables:
.IP \[bu] 2
\f[V]$ARCHITECTURE\f[R] contains the architecture from the
\f[V]Architecture=\f[R] setting.
If \f[V]Architecture=\f[R] is not set, it will contain the native
architecture of the host machine.
See the documentation of \f[V]Architecture=\f[R] for possible values for
this variable.
.IP \[bu] 2
\f[V]$DISTRIBUTION\f[R] contains the distribution from the
\f[V]Distribution=\f[R] setting.
.IP \[bu] 2
\f[V]$RELEASE\f[R] contains the release from the \f[V]Release=\f[R]
setting.
.IP \[bu] 2
\f[V]$PROFILE\f[R] contains the profile from the \f[V]Profile=\f[R]
setting.
.IP \[bu] 2
\f[V]$CACHED=\f[R] is set to \f[V]1\f[R] if a cached image is available,
\f[V]0\f[R] otherwise.
.IP \[bu] 2
\f[V]$CHROOT_SCRIPT\f[R] contains the path to the running script
relative to the image root directory.
The primary usecase for this variable is in combination with the
\f[V]mkosi-chroot\f[R] script.
See the description of \f[V]mkosi-chroot\f[R] below for more
information.
.IP \[bu] 2
\f[V]$SRCDIR\f[R] contains the path to the directory mkosi was invoked
from, with any configured build sources mounted on top.
\f[V]$CHROOT_SRCDIR\f[R] contains the value that \f[V]$SRCDIR\f[R] will
have after invoking \f[V]mkosi-chroot\f[R].
.IP \[bu] 2
\f[V]$BUILDDIR\f[R] is only defined if \f[V]mkosi.builddir\f[R] exists
and points to the build directory to use.
This is useful for all build systems that support out-of-tree builds to
reuse already built artifacts from previous runs.
\f[V]$CHROOT_BUILDDIR\f[R] contains the value that \f[V]$BUILDDIR\f[R]
will have after invoking \f[V]mkosi-chroot\f[R].
.IP \[bu] 2
\f[V]$DESTDIR\f[R] is a directory into which any installed software
generated by a build script may be placed.
This variable is only set when executing a build script.
\f[V]$CHROOT_DESTDIR\f[R] contains the value that \f[V]$DESTDIR\f[R]
will have after invoking \f[V]mkosi-chroot\f[R].
.IP \[bu] 2
\f[V]$OUTPUTDIR\f[R] points to the staging directory used to store build
artifacts generated during the build.
\f[V]$CHROOT_OUTPUTDIR\f[R] contains the value that \f[V]$OUTPUTDIR\f[R]
will have after invoking \f[V]mkosi-chroot\f[R].
.IP \[bu] 2
\f[V]$PACKAGEDIR\f[R] points to the directory containing the local
package repository.
Build scripts can add more packages to the local repository by writing
the packages to \f[V]$PACKAGEDIR\f[R].
.IP \[bu] 2
\f[V]$BUILDROOT\f[R] is the root directory of the image being built,
optionally with the build overlay mounted on top depending on the script
that\[cq]s being executed.
.IP \[bu] 2
\f[V]$WITH_DOCS\f[R] is either \f[V]0\f[R] or \f[V]1\f[R] depending on
whether a build without or with installed documentation was requested
(\f[V]WithDocs=yes\f[R]).
A build script should suppress installation of any package documentation
to \f[V]$DESTDIR\f[R] in case \f[V]$WITH_DOCS\f[R] is set to
\f[V]0\f[R].
.IP \[bu] 2
\f[V]$WITH_TESTS\f[R] is either \f[V]0\f[R] or \f[V]1\f[R] depending on
whether a build without or with running the test suite was requested
(\f[V]WithTests=no\f[R]).
A build script should avoid running any unit or integration tests in
case \f[V]$WITH_TESTS\f[R] is \f[V]0\f[R].
.IP \[bu] 2
\f[V]$WITH_NETWORK\f[R] is either \f[V]0\f[R] or \f[V]1\f[R] depending
on whether a build without or with networking is being executed
(\f[V]WithNetwork=no\f[R]).
A build script should avoid any network communication in case
\f[V]$WITH_NETWORK\f[R] is \f[V]0\f[R].
.IP \[bu] 2
\f[V]$SOURCE_DATE_EPOCH\f[R] is defined if requested
(\f[V]SourceDateEpoch=TIMESTAMP\f[R],
\f[V]Environment=SOURCE_DATE_EPOCH=TIMESTAMP\f[R] or the host
environment variable \f[V]$SOURCE_DATE_EPOCH\f[R]).
This is useful to make builds reproducible.
See
SOURCE_DATE_EPOCH (https://reproducible-builds.org/specs/source-date-epoch/)
for more information.
.IP \[bu] 2
\f[V]$MKOSI_UID\f[R] and \f[V]$MKOSI_GID\f[R] are the respectively the
uid, gid of the user that invoked mkosi, potentially translated to a uid
in the user namespace that mkosi is running in.
These can be used in combination with \f[V]setpriv\f[R] to run commands
as the user that invoked mkosi (e.g.
\f[V]setpriv --reuid=$MKOSI_UID --regid=$MKOSI_GID --clear-groups <command>\f[R])
.IP \[bu] 2
\f[V]$MKOSI_CONFIG\f[R] is a file containing a json summary of the
settings of the current image.
This file can be parsed inside scripts to gain access to all settings
for the current image.
.PP
Consult this table for which script receives which environment
variables:
.PP
.TS
tab(@);
lw(14.3n) lw(9.5n) lw(11.6n) lw(10.2n) lw(12.2n) lw(12.2n).
T{
Variable
T}@T{
\f[V]mkosi.sync\f[R]
T}@T{
\f[V]mkosi.prepare\f[R]
T}@T{
\f[V]mkosi.build\f[R]
T}@T{
\f[V]mkosi.postinst\f[R]
T}@T{
\f[V]mkosi.finalize\f[R]
T}
_
T{
\f[V]ARCHITECTURE\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]DISTRIBUTION\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]RELEASE\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]PROFILE\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]CACHED\f[R]
T}@T{
X
T}@T{
T}@T{
T}@T{
T}@T{
T}
T{
\f[V]CHROOT_SCRIPT\f[R]
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]SRCDIR\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]CHROOT_SRCDIR\f[R]
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]BUILDDIR\f[R]
T}@T{
T}@T{
T}@T{
X
T}@T{
T}@T{
T}
T{
\f[V]CHROOT_BUILDDIR\f[R]
T}@T{
T}@T{
T}@T{
X
T}@T{
T}@T{
T}
T{
\f[V]DESTDIR\f[R]
T}@T{
T}@T{
T}@T{
X
T}@T{
T}@T{
T}
T{
\f[V]CHROOT_DESTDIR\f[R]
T}@T{
T}@T{
T}@T{
X
T}@T{
T}@T{
T}
T{
\f[V]OUTPUTDIR\f[R]
T}@T{
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]CHROOT_OUTPUTDIR\f[R]
T}@T{
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]BUILDROOT\f[R]
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]WITH_DOCS\f[R]
T}@T{
T}@T{
X
T}@T{
X
T}@T{
T}@T{
T}
T{
\f[V]WITH_TESTS\f[R]
T}@T{
T}@T{
X
T}@T{
X
T}@T{
T}@T{
T}
T{
\f[V]WITH_NETWORK\f[R]
T}@T{
T}@T{
X
T}@T{
X
T}@T{
T}@T{
T}
T{
\f[V]SOURCE_DATE_EPOCH\f[R]
T}@T{
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]MKOSI_UID\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]MKOSI_GID\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
T{
\f[V]MKOSI_CONFIG\f[R]
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}@T{
X
T}
.TE
.PP
Additionally, when a script is executed, a few scripts are made
available via \f[V]$PATH\f[R] to simplify common usecases.
.IP \[bu] 2
\f[V]mkosi-chroot\f[R]: This script will chroot into the image and
execute the given command.
On top of chrooting into the image, it will also mount various files and
directories (\f[V]$SRCDIR\f[R], \f[V]$DESTDIR\f[R], \f[V]$BUILDDIR\f[R],
\f[V]$OUTPUTDIR\f[R], \f[V]$CHROOT_SCRIPT\f[R]) into the image and
modify the corresponding environment variables to point to the locations
inside the image.
It will also mount APIVFS filesystems (\f[V]/proc\f[R], \f[V]/dev\f[R],
\&...)
to make sure scripts and tools executed inside the chroot work properly.
It also propagates \f[V]/etc/resolv.conf\f[R] from the host into the
chroot if requested so that DNS resolution works inside the chroot.
After the mkosi-chroot command exits, various mount points are cleaned
up.
.RS 2
.PP
For example, to invoke \f[V]ls\f[R] inside of the image, use the
following
.IP
.nf
\f[C]
mkosi-chroot ls ...
\f[R]
.fi
.PP
To execute the entire script inside the image, add a \[lq].chroot\[rq]
suffix to the name (\f[V]mkosi.build.chroot\f[R] instead of
\f[V]mkosi.build\f[R], etc.).
.RE
.IP \[bu] 2
For all of the supported package managers except portage (\f[V]dnf\f[R],
\f[V]rpm\f[R], \f[V]apt\f[R], \f[V]pacman\f[R], \f[V]zypper\f[R]),
scripts of the same name are put into \f[V]$PATH\f[R] that make sure
these commands operate on the image\[cq]s root directory with the
configuration supplied by the user instead of on the host system.
This means that from a script, you can do
e.g.\ \f[V]dnf install vim\f[R] to install vim into the image.
.RS 2
.PP
Additionally, \f[V]mkosi-install\f[R], \f[V]mkosi-reinstall\f[R],
\f[V]mkosi-upgrade\f[R] and \f[V]mkosi-remove\f[R] will invoke the
corresponding operation of the package manager being used to built the
image.
.RE
.IP \[bu] 2
\f[V]mkosi-as-caller\f[R]: This script uses \f[V]setpriv\f[R] to switch
from the user \f[V]root\f[R] in the user namespace used for various
build steps back to the original user that called mkosi.
This is useful when we want to invoke build steps which will write to
\f[V]$BUILDDIR\f[R] and we want to have the files owned by the calling
user.
.RS 2
.PP
For example, a complete \f[V]mkosi.build\f[R] script might be the
following:
.IP
.nf
\f[C]
set -ex
mkosi-as-caller meson setup \[dq]$BUILDDIR/build\[dq] \[dq]$SRCDIR\[dq]
mkosi-as-caller meson compile -C \[dq]$BUILDDIR/build\[dq]
meson install -C \[dq]$BUILDDIR/build\[dq] --no-rebuild
\f[R]
.fi
.RE
.IP \[bu] 2
\f[V]git\f[R] is automatically invoked with \f[V]safe.directory=*\f[R]
to avoid permissions errors when running as the root user in a user
namespace.
.IP \[bu] 2
\f[V]useradd\f[R] and \f[V]groupadd\f[R] are automatically invoked with
\f[V]--root=$BUILDROOT\f[R] when executed outside of the image.
.PP
When scripts are executed, any directories that are still writable are
also made read-only (\f[V]/home\f[R], \f[V]/var\f[R], \f[V]/root\f[R],
\&...)
and only the minimal set of directories that need to be writable remain
writable.
This is to ensure that scripts can\[cq]t mess with the host system when
mkosi is running as root.
.PP
Note that when executing scripts, all source directories are made
ephemeral which means all changes made to source directories while
running scripts are thrown away after the scripts finish executing.
Use the output, build or cache directories if you need to persist data
between builds.
.SH Files
.PP
To make it easy to build images for development versions of your
projects, mkosi can read configuration data from the local directory,
under the assumption that it is invoked from a \f[I]source\f[R] tree.
Specifically, the following files are used if they exist in the local
directory:
.IP \[bu] 2
The \f[B]\f[VB]mkosi.skeleton/\f[B]\f[R] directory or
\f[B]\f[VB]mkosi.skeleton.tar\f[B]\f[R] archive may be used to insert
files into the image.
The files are copied \f[I]before\f[R] the distribution packages are
installed into the image.
This allows creation of files that need to be provided early, for
example to configure the package manager or set systemd presets.
.RS 2
.PP
When using the directory, file ownership is not preserved: all files
copied will be owned by root.
To preserve ownership, use a tar archive.
.RE
.IP \[bu] 2
The \f[B]\f[VB]mkosi.extra/\f[B]\f[R] directory or
\f[B]\f[VB]mkosi.extra.tar\f[B]\f[R] archive may be used to insert
additional files into the image, on top of what the distribution
includes in its packages.
They are similar to \f[V]mkosi.skeleton/\f[R] and
\f[V]mkosi.skeleton.tar\f[R], but the files are copied into the
directory tree of the image \f[I]after\f[R] the OS was installed.
.RS 2
.PP
When using the directory, file ownership is not preserved: all files
copied will be owned by root.
To preserve ownership, use a tar archive.
.RE
.IP \[bu] 2
The \f[B]\f[VB]mkosi.nspawn\f[B]\f[R] nspawn settings file will be
copied into the same place as the output image file, if it exists.
This is useful since nspawn looks for settings files next to image files
it boots, for additional container runtime settings.
.IP \[bu] 2
The \f[B]\f[VB]mkosi.cache/\f[B]\f[R] directory, if it exists, is
automatically used as package download cache, in order to speed repeated
runs of the tool.
.IP \[bu] 2
The \f[B]\f[VB]mkosi.builddir/\f[B]\f[R] directory, if it exists, is
automatically used as out-of-tree build directory, if the build commands
in the \f[V]mkosi.build\f[R] scripts support it.
Specifically, this directory will be mounted into the build container,
and the \f[V]$BUILDDIR\f[R] environment variable will be set to it when
the build scripts are invoked.
A build script may then use this directory as build directory, for
automake-style or ninja-style out-of-tree builds.
This speeds up builds considerably, in particular when \f[V]mkosi\f[R]
is used in incremental mode (\f[V]-i\f[R]): not only the image and build
overlay, but also the build tree is reused between subsequent
invocations.
Note that if this directory does not exist the \f[V]$BUILDDIR\f[R]
environment variable is not set, and it is up to the build scripts to
decide whether to do in in-tree or an out-of-tree build, and which build
directory to use.
.IP \[bu] 2
The \f[B]\f[VB]mkosi.rootpw\f[B]\f[R] file can be used to provide the
password for the root user of the image.
If the password is prefixed with \f[V]hashed:\f[R] it is treated as an
already hashed root password.
The password may optionally be followed by a newline character which is
implicitly removed.
The file must have an access mode of 0600 or less.
If this file does not exist, the distribution\[cq]s default root
password is set (which usually means access to the root user is
blocked).
.IP \[bu] 2
The \f[B]\f[VB]mkosi.passphrase\f[B]\f[R] file provides the passphrase
to use when LUKS encryption is selected.
It should contain the passphrase literally, and not end in a newline
character (i.e.\ in the same format as cryptsetup and
\f[V]/etc/crypttab\f[R] expect the passphrase files).
The file must have an access mode of 0600 or less.
.IP \[bu] 2
The \f[B]\f[VB]mkosi.crt\f[B]\f[R] and \f[B]\f[VB]mkosi.key\f[B]\f[R]
files contain an X.509 certificate and PEM private key to use when
signing is required (UEFI SecureBoot, verity, \&...).
.IP \[bu] 2
The \f[B]\f[VB]mkosi.output/\f[B]\f[R] directory is used to store all
build artifacts.
.IP \[bu] 2
The \f[B]\f[VB]mkosi.credentials/\f[B]\f[R] directory is used as a
source of extra credentials similar to the \f[V]Credentials=\f[R]
option.
For each file in the directory, the filename will be used as the
credential name and the file contents become the credential value, or,
if the file is executable, mkosi will execute the file and the
command\[cq]s output to stdout will be used as the credential value.
Output to stderr will be ignored.
Credentials configured with \f[V]Credentials=\f[R] take precedence over
files in \f[V]mkosi.credentials\f[R].
.IP \[bu] 2
The \f[B]\f[VB]mkosi.repart/\f[B]\f[R] directory is used as the source
for systemd-repart partition definition files which are passed to
systemd-repart when building a disk image.
If it does not exist and the \f[V]RepartDirectories=\f[R] setting is not
configured, mkosi will default to the following partition definition
files:
.RS 2
.PP
\f[V]00-esp.conf\f[R] (if we\[cq]re building a bootable image):
.IP
.nf
\f[C]
[Partition]
Type=esp
Format=vfat
CopyFiles=/boot:/
CopyFiles=/efi:/
SizeMinBytes=512M
SizeMaxBytes=512M
\f[R]
.fi
.PP
\f[V]05-bios.conf\f[R] (if we\[cq]re building a BIOS bootable image):
.IP
.nf
\f[C]
[Partition]
# UUID of the grub BIOS boot partition which grubs needs on GPT to
# embed itself into.
Type=21686148-6449-6e6f-744e-656564454649
SizeMinBytes=1M
SizeMaxBytes=1M
\f[R]
.fi
.PP
\f[V]10-root.conf\f[R]:
.IP
.nf
\f[C]
[Partition]
Type=root
Format=<distribution-default-filesystem>
CopyFiles=/
Minimize=guess
\f[R]
.fi
.PP
Note that if either \f[V]mkosi.repart/\f[R] is found or
\f[V]RepartDirectories=\f[R] is used, we will not use any of the default
partition definitions.
.RE
.PP
All these files are optional.
.PP
Note that the location of all these files may also be configured during
invocation via command line switches, and as settings in
\f[V]mkosi.conf\f[R], in case the default settings are not acceptable
for a project.
.SH CACHING
.PP
\f[V]mkosi\f[R] supports three different caches for speeding up
repetitive re-building of images.
Specifically:
.IP "1." 3
The package cache of the distribution package manager may be cached
between builds.
This is configured with the \f[V]--cache-dir=\f[R] option or the
\f[V]mkosi.cache/\f[R] directory.
This form of caching relies on the distribution\[cq]s package manager,
and caches distribution packages (RPM, DEB, \&...)
after they are downloaded, but before they are unpacked.
.IP "2." 3
If the incremental build mode is enabled with \f[V]--incremental\f[R],
cached copies of the final image and build overlay are made immediately
before the build sources are copied in (for the build overlay) or the
artifacts generated by \f[V]mkosi.build\f[R] are copied in (in case of
the final image).
This form of caching allows bypassing the time-consuming package
unpacking step of the distribution package managers, but is only
effective if the list of packages to use remains stable, but the build
sources and its scripts change regularly.
Note that this cache requires manual flushing: whenever the package list
is modified the cached images need to be explicitly removed before the
next re-build, using the \f[V]-f\f[R] switch.
.IP "3." 3
Finally, between multiple builds the build artifact directory may be
shared, using the \f[V]mkosi.builddir/\f[R] directory.
This directory allows build systems such as Meson to reuse already
compiled sources from a previous built, thus speeding up the build
process of a \f[V]mkosi.build\f[R] build script.
.PP
The package cache and incremental mode are unconditionally useful.
The final cache only apply to uses of \f[V]mkosi\f[R] with a source tree
and build script.
When all three are enabled together turn-around times for complete image
builds are minimal, as only changed source files need to be recompiled.
.SH Building multiple images
.PP
If the \f[V]mkosi.images/\f[R] directory exists, mkosi will load
individual image configurations from it and build each of them.
Image configurations can be either directories containing mkosi
configuration files or regular files with the \f[V].conf\f[R] extension.
.PP
When image configurations are found in \f[V]mkosi.images/\f[R], mkosi
will build the configured images and all of their dependencies (or all
of them if no images were explicitly configured using
\f[V]Images=\f[R]).
To add dependencies between images, the \f[V]Dependencies=\f[R] setting
can be used.
.PP
When images are defined, mkosi will first read the global configuration
(configuration outside of the \f[V]mkosi.images/\f[R] directory),
followed by the image specific configuration.
This means that global configuration takes precedence over image
specific configuration.
.PP
Images can refer to outputs of images they depend on.
Specifically, for the following options, mkosi will only check whether
the inputs exist just before building the image:
.IP \[bu] 2
\f[V]BaseTrees=\f[R]
.IP \[bu] 2
\f[V]PackageManagerTrees=\f[R]
.IP \[bu] 2
\f[V]SkeletonTrees=\f[R]
.IP \[bu] 2
\f[V]ExtraTrees=\f[R]
.IP \[bu] 2
\f[V]ToolsTree=\f[R]
.IP \[bu] 2
\f[V]Initrds=\f[R]
.PP
To refer to outputs of a image\[cq]s dependencies, simply configure any
of these options with a relative path to the output to use in the output
directory of the dependency.
Or use the \f[V]%O\f[R] specifier to refer to the output directory.
.PP
A good example on how to build multiple images can be found in the
systemd (https://github.com/systemd/systemd/tree/main/mkosi.images)
repository.
.SH ENVIRONMENT VARIABLES
.IP \[bu] 2
\f[V]$MKOSI_LESS\f[R] overrides options for \f[V]less\f[R] when it is
invoked by \f[V]mkosi\f[R] to page output.
.IP \[bu] 2
\f[V]$MKOSI_DNF\f[R] can be used to override the executable used as
\f[V]dnf\f[R].
This is particularly useful to select between \f[V]dnf\f[R] and
\f[V]dnf5\f[R].
.SH EXAMPLES
.PP
Create and run a raw \f[I]GPT\f[R] image with \f[I]ext4\f[R], as
\f[V]image.raw\f[R]:
.IP
.nf
\f[C]
# mkosi -p systemd --incremental boot
\f[R]
.fi
.PP
Create and run a bootable \f[I]GPT\f[R] image, as \f[V]foobar.raw\f[R]:
.IP
.nf
\f[C]
$ mkosi -d fedora -p kernel-core -p systemd -p systemd-boot -p udev -o foobar.raw
# mkosi --output foobar.raw boot
$ mkosi --output foobar.raw qemu
\f[R]
.fi
.PP
Create and run a \f[I]Fedora Linux\f[R] image in a plain directory:
.IP
.nf
\f[C]
# mkosi --distribution fedora --format directory boot
\f[R]
.fi
.PP
Create a compressed image \f[V]image.raw.xz\f[R] with \f[I]SSH\f[R]
installed and add a checksum file:
.IP
.nf
\f[C]
$ mkosi --distribution fedora --format disk --checksum --compress-output --package=openssh-clients
\f[R]
.fi
.PP
Inside the source directory of an \f[V]automake\f[R]-based project,
configure \f[I]mkosi\f[R] so that simply invoking \f[V]mkosi\f[R]
without any parameters builds an OS image containing a built version of
the project in its current state:
.IP
.nf
\f[C]
$ cat >mkosi.conf <<EOF
[Distribution]
Distribution=fedora
[Output]
Format=disk
[Content]
Packages=kernel,systemd,systemd-udev,openssh-clients,httpd
BuildPackages=make,gcc,libcurl-devel
EOF
$ cat >mkosi.build <<EOF
#!/bin/sh
if [ \[dq]$container\[dq] != \[dq]mkosi\[dq] ]; then
exec mkosi-chroot \[dq]$CHROOT_SCRIPT\[dq] \[dq]$\[at]\[dq]
fi
cd $SRCDIR
\&./autogen.sh
\&./configure --prefix=/usr
make -j \[ga]nproc\[ga]
make install
EOF
$ chmod +x mkosi.build
# mkosi --incremental boot
# systemd-nspawn -bi image.raw
\f[R]
.fi
.SS Different ways to boot with \f[V]qemu\f[R]
.PP
The easiest way to boot a virtual machine is to build an image with the
required components and let \f[V]mkosi\f[R] call \f[V]qemu\f[R] with all
the right options:
.IP
.nf
\f[C]
$ mkosi -d fedora \[rs]
--autologin \[rs]
-p systemd-udev,systemd-boot,kernel-core \[rs]
build
$ mkosi -d fedora qemu
\&...
fedora login: root (automatic login)
[root\[at]fedora \[ti]]#
\f[R]
.fi
.PP
The default is to boot with a text console only.
In this mode, messages from the boot loader, the kernel, and systemd,
and later the getty login prompt and shell all use the same terminal.
It is possible to switch between the qemu console and monitor by
pressing \f[V]Ctrl-a c\f[R].
The qemu monitor may for example be used to inject special keys or shut
down the machine quickly.
.PP
To boot with a graphical window, add \f[V]--qemu-qui\f[R]:
.IP
.nf
\f[C]
$ mkosi -d fedora --qemu-gui qemu
\f[R]
.fi
.PP
A kernel may be booted directly with
\f[V]mkosi qemu -kernel ... -initrd ... -append \[aq]...\[aq]\f[R].
This is a bit faster because no boot loader is used, and it is also
easier to experiment with different kernels and kernel commandlines.
Note that despite the name, qemu\[cq]s \f[V]-append\f[R] option replaces
the default kernel commandline embedded in the kernel and any previous
\f[V]-append\f[R] specifications.
.PP
The UKI is also copied into the output directory and may be booted
directly:
.IP
.nf
\f[C]
$ mkosi qemu -kernel mkosi.output/fedora\[ti]38/image.efi
\f[R]
.fi
.PP
When booting using an external kernel, we don\[cq]t need the kernel
\f[I]in\f[R] the image, but we would still want the kernel modules to be
installed.
.PP
It is also possible to do a \f[I]direct kernel boot\f[R] into a boot
loader, taking advantage of the fact that \f[V]systemd-boot(7)\f[R] is a
valid UEFI binary:
.IP
.nf
\f[C]
$ mkosi qemu -kernel /usr/lib/systemd/boot/efi/systemd-bootx64.efi
\f[R]
.fi
.PP
In this scenario, the kernel is loaded from the ESP in the image by
\f[V]systemd-boot\f[R].
.SH REQUIREMENTS
.PP
mkosi is packaged for various distributions: Debian, Ubuntu, Arch Linux,
Fedora Linux, OpenMandriva, Gentoo.
Note that it has been a while since the last release and the packages
shipped by distributions are very out of date.
We currently recommend running mkosi from git until a new release
happens.
.PP
mkosi currently requires systemd 254 to build bootable disk images.
.PP
When not using distribution packages make sure to install the necessary
dependencies.
For example, on \f[I]Fedora Linux\f[R] you need:
.IP
.nf
\f[C]
# dnf install bubblewrap btrfs-progs apt dosfstools mtools edk2-ovmf e2fsprogs squashfs-tools gnupg python3 tar xfsprogs xz zypper sbsigntools
\f[R]
.fi
.PP
On Debian/Ubuntu it might be necessary to install the
\f[V]ubuntu-keyring\f[R], \f[V]ubuntu-archive-keyring\f[R] and/or
\f[V]debian-archive-keyring\f[R] packages explicitly, in addition to
\f[V]apt\f[R], depending on what kind of distribution images you want to
build.
.PP
Note that the minimum required Python version is 3.9.
.SH Frequently Asked Questions (FAQ)
.IP \[bu] 2
Why does \f[V]mkosi qemu\f[R] with KVM not work on Debian/Ubuntu?
.RS 2
.PP
While other distributions are OK with allowing access to
\f[V]/dev/kvm\f[R], on Debian/Ubuntu this is only allowed for users in
the \f[V]kvm\f[R] group.
Because mkosi unshares a user namespace when running unprivileged, even
if the calling user was in the kvm group, when mkosi unshares the user
namespace to run unprivileged, it loses access to the \f[V]kvm\f[R]
group and by the time we start \f[V]qemu\f[R] we don\[cq]t have access
to \f[V]/dev/kvm\f[R] anymore.
As a workaround, you can change the permissions of the device nodes to
\f[V]0666\f[R] which is sufficient to make KVM work unprivileged.
To persist these settings across reboots, copy
\f[V]/usr/lib/tmpfiles.d/static-nodes-permissions.conf\f[R] to
\f[V]/etc/tmpfiles.d/static-nodes-permissions.conf\f[R] and change the
mode of \f[V]/dev/kvm\f[R] from \f[V]0660\f[R] to \f[V]0666\f[R].
.RE
.IP \[bu] 2
How do I add a regular user to an image?
.RS 2
.PP
You can use the following snippet in a post-installation script:
.IP
.nf
\f[C]
useradd --create-home --user-group $USER --password \[dq]$(openssl passwd -stdin -6 <$USER_PASSWORD_FILE)\[dq]
\f[R]
.fi
.PP
Note that from systemd v256 onwards, if enabled,
\f[V]systemd-homed-firstboot.service\f[R] will prompt to create a
regular user on first boot if there are no regular users.
.RE
.SH REFERENCES
.IP \[bu] 2
Primary mkosi git repository on
GitHub (https://github.com/systemd/mkosi/)
.IP \[bu] 2
mkosi \[em] A Tool for Generating OS
Images (https://0pointer.net/blog/mkosi-a-tool-for-generating-os-images.html)
introductory blog post by Lennart Poettering
.IP \[bu] 2
The mkosi OS generation tool (https://lwn.net/Articles/726655/) story on
LWN
.SH SEE ALSO
.PP
\f[V]systemd-nspawn(1)\f[R], \f[V]dnf(8)\f[R]
|