Anforderungen an das Erstellen benutzerdefinierter Images
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Linux
Es kann vorkommen, dass Sie für Ihre Anwendungen ein eigenes Betriebssystem oder einen benutzerdefinierten Kernel erstellen müssen. Achten Sie dabei darauf, dass die benutzerdefinierten Kernel bzw. Betriebssysteme Ihrer VMs die in diesem Dokument erläuterten Anforderungen erfüllen.
ISA-Bridge: Intel 82371AB/EB/MB PIIX4 ISA (rev 03)
Ethernet-Controller:
Virtio-Net Ethernet Adapter
gVNIC ist für die zweite Generation von Tau T2A sowie für alle Maschinenserien der dritten Generation und höher erforderlich.
Außerdem ist gVNIC erforderlich oder wird empfohlen, wenn Sie GPUs für Folgendes verwenden:
N1-Maschinentypen für allgemeine Zwecke
Beschleunigungsoptimierte Maschinentypen A4, A3, A2 oder G2
Anbieter = 0x1AF4 (Qumranet/Red Hat)
Geräte-ID = 0x1000. Subsystem-ID = 0x1
Prüfsummenabladung wird unterstützt
TSO v4 wird unterstützt
GRO v4 wird unterstützt
SCSI Storage Controller:
Virtio-SCSI Storage Controller
Anbieter = 0x1AF4 (Qumranet/Red Hat)
Geräte-ID = 0x1004, Subsystem-ID = 0x8
SCSI Primary Commands 4 und SCSI Block Commands 3 werden unterstützt
Nur eine Anfragewarteschlange wird unterstützt
Nichtflüchtiger Speicher hat physische Sektoren mit 4 KiB bzw. logische Sektoren mit 512 Byte
Nur Blockgeräte (Laufwerke) werden unterstützt
Feature Bit "Hotplug/Events" wird unterstützt
Serielle Ports:
Vier 16550A-Ports
ttyS0 auf IRQ 4
ttyS1 auf IRQ 3
ttyS2 auf IRQ 6
ttyS3 auf IRQ 7
Erforderliche Build-Optionen für Linux-Kernel
Sie müssen den Betriebssystem-Kernel mit den folgenden Optionen erstellen:
CONFIG_KVM_GUEST=y
Die Paravirtualisierungsfunktion aktivieren.
CONFIG_KVM_CLOCK=y
Die paravirtualisierte Uhr aktivieren (falls auf Ihre Kernel-Version zutreffend).
CONFIG_VIRTIO_PCI=y
Paravirtualisierte PCI-Geräte aktivieren.
CONFIG_SCSI_VIRTIO=y
Den Zugriff auf paravirtualisierte Festplatten aktivieren.
CONFIG_VIRTIO_NET=y
Den Zugang zum Netzwerk aktivieren.
CONFIG_PCI_MSI=y
Die Hochleistungs-Interruptübertragung aktivieren, die für lokale SSD-Geräte erforderlich ist.
Kernel-Build-Optionen für die Sicherheit
Verwenden Sie in den Kernel-Build-Optionen folgende empfohlene Sicherheitseinstellungen:
CONFIG_STRICT_DEVMEM=y
/dev/mem nur Zugriff auf den PCI-Bereich, den BIOS-Code und die Speicherorte für Daten gewähren.
CONFIG_DEVKMEM=n
/dev/kmem-Unterstützung deaktivieren.
Den Zugriff auf den Kernel-Speicher blockieren.
CONFIG_DEFAULT_MMAP_MIN_ADDR=65536
Einen geringen virtuellen Speicher einrichten, der nicht vom Userspace genutzt wird.
CONFIG_DEBUG_RODATA=y
Die schreibgeschützten Kernel-Daten in den Seitentabellen entsprechend kennzeichnen, um unbeabsichtigte (und falsche) Schreibvorgänge für solche const-Daten zu verhindern. Diese Option kann sich in geringem Umfang auf die Leistung auswirken, da ein Teil des Kernel-Codes nicht mehr von dem 2-MB-TLB abgedeckt ist.
CONFIG_DEBUG_SET_MODULE_RONX=y
Diese Option schützt vor unbeabsichtigten Änderungen am Text und an schreibgeschützten Daten des ladbaren Kernel-Moduls. Sie verhindert außerdem das Ausführen von Moduldaten.
CONFIG_CC_STACKPROTECTOR=y
Diese Option aktiviert das GCC-Element -fstack-protector. Damit wird wichtigen Funktionen auf dem Stack vor der Rücksprungadresse ein Canary-Wert vorangestellt. Vor dem Rücksprung wird dieser Wert geprüft. Dies führt außerdem dazu, dass Stack-basierte Pufferüberläufe, welche diese Rücksprungadresse überschreiben müssen, den Canary-Wert überschreiben. Dies wird erkannt und der Angriff wird mit einer Kernel-Panic neutralisiert.
CONFIG_COMPAT_VDSO=n
Diese Option sorgt dafür, dass sich das VDSO nicht unter einer vorhersehbaren Adresse befindet, und stärkt dadurch die ASLR. Wenn die Funktion aktiviert ist, verknüpft sie das VDSO mit der vorhersehbaren alten Adresse, wodurch ein Angriffspunkt für Exploit-Code entsteht.
Wählen Sie N aus, wenn Sie eine ausreichend aktuelle glibc-Version (ab 2.3.3) ausführen, um die festgelegte VDSO-Zuordnung aufzuheben und ausschließlich eine zufällige VDSO-Zuordnung zu verwenden.
CONFIG_COMPAT_BRK=n
Deaktivieren Sie die Heap-Randomisierung nicht.
CONFIG_X86_PAE=y
Richten Sie diese Option für einen 32-Bit-Kernel ein, da PAE für die NX-Unterstützung erforderlich ist.
Dies ermöglicht auch eine bessere Unterstützung des Auslagerungsspeichers für Nicht-Overcommit-Zwecke.
CONFIG_SYN_COOKIES=y
Bietet einen gewissen Schutz vor SYN-Floods.
CONFIG_SECURITY_YAMA=y
Damit wird Yama aktiviert, um die DAC-Unterstützung um weitere systemweite Sicherheitseinstellungen zu ergänzen, die über die regulären Linux-Zugriffskontrollen hinausgehen.
Aktuell lautet die Einstellung "ptrace scope restriction".
CONFIG_SECURITY_YAMA_STACKED=y
Diese Option zwingt Yama zum Stapeln mit der ausgewählten primären LSM, wenn Yama verfügbar ist.
Kernel-Sicherheitseinstellungen
Sie können die Sicherheit des Kernels über die Kernel-Einstellungsdatei weiter erhöhen. Fügen Sie der Datei /etc/sysctl.conf die folgenden empfohlenen Sicherheitseinstellungen hinzu:
Installieren Sie das Betriebssystem auf einem Bootlaufwerk und importieren Sie das Image manuell als benutzerdefiniertes Image in Compute Engine.
Wenn Sie das Betriebssystem bereits als benutzerdefiniertes Image importiert haben, konfigurieren Sie weitere Einstellungen auf dem Image, damit es in der Compute Engine-Umgebung optimal funktioniert.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eBuilding custom operating systems or compiling custom kernels is an advanced task mainly for applications with specific kernel requirements, with most users able to use public images or import existing ones.\u003c/p\u003e\n"],["\u003cp\u003eCustom kernels must support specific hardware devices including PCI Bridge, ISA bridge, Virtio-Net or gVNIC Ethernet controller, Virtio-SCSI storage controller (or NVMe for newer machine series), and four 16550A serial ports.\u003c/p\u003e\n"],["\u003cp\u003eRequired Linux kernel build options include enabling paravirtualization, PCI devices, disks, and networking, as well as enabling high-performance interrupt delivery, which is needed for local SSD devices.\u003c/p\u003e\n"],["\u003cp\u003eRecommended kernel security settings involve restricting \u003ccode\u003e/dev/mem\u003c/code\u003e, disabling \u003ccode\u003e/dev/kmem\u003c/code\u003e, setting low virtual memory protection, using read-only protection for kernel data, enabling stack protection, and randomizing memory addresses.\u003c/p\u003e\n"],["\u003cp\u003eKernel security can also be hardened by editing \u003ccode\u003e/etc/sysctl.conf\u003c/code\u003e to include settings for syn flood protection, ignoring source-routed packets and ICMP redirects, preventing traffic routing, enabling reverse path filtering, and randomizing addresses.\u003c/p\u003e\n"]]],[],null,["# Requirements to build custom images\n\nLinux\n\n*** ** * ** ***\n\nIn some situations, your applications might require you to build your own\noperating system or compile a custom kernel. If you compile custom kernels or\ncreate custom operating systems for your VMs, ensure that they meet the\nrequirements in this document.\n\n[Building a custom operating system](/compute/docs/images/create-custom) is an\nadvanced task for users with applications that specifically require a custom\nkernel. Most users can create VMs from one of the available\n[public images](/compute/docs/images#os-compute-support), use the automated\n[virtual disk import tool](/compute/docs/import/importing-virtual-disks) to\nimport disks into Compute Engine from other environments, or\n[manually import a custom image](/compute/docs/import/import-existing-image)\nfrom a system with a common stock Linux distribution.\n\nHardware support requirements\n-----------------------------\n\nYour kernel must support the following devices:\n\n- PCI Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)\n- ISA bridge: Intel 82371AB/EB/MB PIIX4 ISA (rev 03)\n- Ethernet controller:\n\n - Virtio-Net Ethernet Adapter.\n - gVNIC is required for second generation\n [Tau T2A](/compute/docs/general-purpose-machines#t2a_machines),\n and all third generation and later machine series.\n\n Additionally, gVNIC is required or recommended if you use GPUs on any of\n the following:\n - General-purpose N1 machine types\n - Accelerator-optimized [A4](/compute/docs/accelerator-optimized-machines#a4-vms), [A3](/compute/docs/accelerator-optimized-machines#a3-vms), [A2](/compute/docs/accelerator-optimized-machines#a2-vms), or [G2](/compute/docs/accelerator-optimized-machines#g2-vms) machine types\n - vendor = 0x1AF4 (Qumranet/Red Hat)\n\n - device id = 0x1000. Subsystem ID 0x1\n\n - Checksum offload is supported\n\n - TSO v4 is supported\n\n - GRO v4 is supported\n\n- SCSI Storage Controller:\n\n - Virtio-SCSI Storage Controller\n - vendor = 0x1AF4 (Qumranet/Red Hat)\n - device id = 0x1004. Subsystem ID 0x8.\n - SCSI Primary Commands 4 and SCSI Block Commands 3 are supported\n - Only one request queue is supported\n - Persistent disks report 4 KiB physical sectors / 512 byte logical sectors\n - Only block devices (disks) are supported\n - The Hotplug / Events feature bit is supported\n\n| **Note:** For second generation Tau T2A and G2, and all third generation and later machine series, you must use an NVMe storage controller instead.\n\n- Serial Ports:\n - Four 16550A ports\n - ttyS0 on IRQ 4\n - ttyS1 on IRQ 3\n - ttyS2 on IRQ 6\n - ttyS3 on IRQ 7\n\nRequired Linux kernel build options\n-----------------------------------\n\nYou must build the operating system kernel with the following options:\n\n- `CONFIG_KVM_GUEST=y`\n - Enable paravirtualization functionality.\n- `CONFIG_KVM_CLOCK=y`\n - Enable the paravirtualized clock (if applies to your kernel version).\n- `CONFIG_VIRTIO_PCI=y`\n - Enable paravirtualized PCI devices.\n- `CONFIG_SCSI_VIRTIO=y`\n - Enable access to paravirtualized disks.\n- `CONFIG_VIRTIO_NET=y`\n - Enable access to networking.\n- `CONFIG_PCI_MSI=y`\n - Enable high-performance interrupt delivery, which is required for local SSD devices.\n\n### Kernel build options for security\n\nUse the recommended security settings in your kernel build options:\n\n- `CONFIG_STRICT_DEVMEM=y`\n - Restrict `/dev/mem` to allow access to only PCI space, BIOS code, and data regions.\n- `CONFIG_DEVKMEM=n`\n - Disable support for `/dev/kmem`.\n - Block access to kernel memory.\n- `CONFIG_DEFAULT_MMAP_MIN_ADDR=65536`\n - Set low virtual memory that is protected from userspace allocation.\n- `CONFIG_DEBUG_RODATA=y`\n - Mark the kernel read-only data as write-protected in the pagetables, to catch accidental (and incorrect) writes to such `const` data. This option can have a slight performance impact because a portion of the kernel code won't be covered by a 2 MB TLB anymore.\n- `CONFIG_DEBUG_SET_MODULE_RONX=y`\n - Catches unintended modifications to loadable kernel module's text and read-only data. This option also prevents execution of module data.\n- `CONFIG_CC_STACKPROTECTOR=y`\n - Enables the `-fstack-protector` GCC feature. This feature puts a canary value at the beginning of critical functions, on the stack before the return address, and validates the value before actually returning. This also causes stack-based buffer overflows (that need to overwrite this return address) to overwrite the canary, which gets detected and the attack is then neutralized using a kernel panic.\n- `CONFIG_COMPAT_VDSO=n`\n - Ensures the VDSO isn't at a predictable address to strengthen ASLR. If enabled, this feature maps the VDSO to the predictable old-style address, providing a predictable location for exploit code to jump to. Say `N` here if you are running a sufficiently recent `glibc` version (2.3.3 or later), to remove the high-mapped VDSO mapping and to exclusively use the randomized VDSO.\n- `CONFIG_COMPAT_BRK=n`\n - Don't disable heap randomization.\n- `CONFIG_X86_PAE=y`\n - Set this option for a 32-bit kernel because PAE is required for NX support. This also enables larger swapspace support for non-overcommit purposes.\n- `CONFIG_SYN_COOKIES=y`\n - Provides some protection against SYN flooding.\n- `CONFIG_SECURITY_YAMA=y`\n - This selects Yama, which extends DAC support with additional system-wide security settings beyond regular Linux discretionary access controls. Currently, the setting is ptrace scope restriction.\n- `CONFIG_SECURITY_YAMA_STACKED=y`\n - This option forces Yama to stack with the selected primary LSM when Yama is available.\n\n### Kernel security settings\n\nYou can also harden the security of the kernel through the kernel settings\nfile. Edit the `/etc/sysctl.conf` file to include the following recommended\nsecurity settings: \n\n # Enable syn flood protection\n net.ipv4.tcp_syncookies = 1\n\n # Ignore source-routed packets\n net.ipv4.conf.all.accept_source_route = 0\n\n # Ignore source-routed packets\n net.ipv4.conf.default.accept_source_route = 0\n\n # Ignore ICMP redirects\n net.ipv4.conf.all.accept_redirects = 0\n\n # Ignore ICMP redirects\n net.ipv4.conf.default.accept_redirects = 0\n\n # Ignore ICMP redirects from non-GW hosts\n net.ipv4.conf.all.secure_redirects = 1\n\n # Ignore ICMP redirects from non-GW hosts\n net.ipv4.conf.default.secure_redirects = 1\n\n # Don't allow traffic between networks or act as a router\n net.ipv4.ip_forward = 0\n\n # Don't allow traffic between networks or act as a router\n net.ipv4.conf.all.send_redirects = 0\n\n # Don't allow traffic between networks or act as a router\n net.ipv4.conf.default.send_redirects = 0\n\n # Reverse path filtering—IP spoofing protection\n net.ipv4.conf.all.rp_filter = 1\n\n # Reverse path filtering—IP spoofing protection\n net.ipv4.conf.default.rp_filter = 1\n\n # Ignore ICMP broadcasts to avoid participating in Smurf attacks\n net.ipv4.icmp_echo_ignore_broadcasts = 1\n\n # Ignore bad ICMP errors\n net.ipv4.icmp_ignore_bogus_error_responses = 1\n\n # Log spoofed, source-routed, and redirect packets\n net.ipv4.conf.all.log_martians = 1\n\n # Log spoofed, source-routed, and redirect packets\n net.ipv4.conf.default.log_martians = 1\n\n # Randomize addresses of mmap base, heap, stack and VDSO page\n kernel.randomize_va_space = 2\n\n # Provide protection from ToCToU races\n fs.protected_hardlinks=1\n\n # Provide protection from ToCToU races\n fs.protected_symlinks=1\n\n # Make locating kernel addresses more difficult\n kernel.kptr_restrict=1\n\n # Set ptrace protections\n kernel.yama.ptrace_scope=1\n\n # Set perf only available to root\n kernel.perf_event_paranoid=2\n\nWhat's next\n-----------\n\n- Install the operating system to a boot disk and [manually import the image](/compute/docs/import/import-existing-image) to Compute Engine as a custom image.\n- If you have already imported your operating system as a custom image, [configure non-kernel settings](/compute/docs/import/configuring-imported-images) on the image so that it can functional optimally within the Compute Engine environment."]]