Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Linux
In alcuni casi, le applicazioni potrebbero richiedere di creare il proprio sistema operativo
o compilare un kernel personalizzato. Se compili kernel personalizzati o
crei sistemi operativi personalizzati per le tue VM, assicurati che soddisfino i
requisiti riportati in questo documento.
Bridge ISA: Intel 82371AB/EB/MB PIIX4 ISA (rev 03)
Controller Ethernet:
Adattatore Ethernet Virtio-Net.
La gVNIC è obbligatoria per
Tau T2A
di seconda generazione e per tutte le serie di macchine di terza generazione e successive.
Inoltre, la gVNIC è obbligatoria o consigliata se utilizzi GPU su uno
dei seguenti elementi:
Tipi di macchine N1 per uso generico
Tipi di macchine
A4,
A3,
A2 o
G2 ottimizzati per l'acceleratore
vendor = 0x1AF4 (Qumranet/Red Hat)
device id = 0x1000. ID sottosistema 0x1
Il trasferimento del checksum è supportato
TSO v4 è supportato
GRO v4 è supportato
Controller di archiviazione SCSI:
Controller dello spazio di archiviazione Virtio-SCSI
vendor = 0x1AF4 (Qumranet/Red Hat)
ID dispositivo = 0x1004. ID sottosistema 0x8.
Sono supportati i comandi principali SCSI 4 e i comandi di blocco SCSI 3
È supportata una sola coda di richieste
I dischi permanenti registrano settori fisici di 4 KiB / settori logici di 512 byte
Sono supportati solo i dispositivi a blocchi (dischi)
Il bit della funzionalità Hotplug / Eventi è supportato
Porte seriali:
Quattro porte 16550A
ttyS0 su IRQ 4
ttyS1 su IRQ 3
ttyS2 su IRQ 6
ttyS3 su IRQ 7
Opzioni per la creazione del kernel Linux obbligatorie
Devi creare il kernel del sistema operativo con le seguenti opzioni:
CONFIG_KVM_GUEST=y
Attiva la funzionalità di paravirtualizzazione.
CONFIG_KVM_CLOCK=y
Attiva l'orologio paravirtualizzato (se applicabile alla tua versione kernel).
CONFIG_VIRTIO_PCI=y
Attiva i dispositivi PCI paravirtualizzati.
CONFIG_SCSI_VIRTIO=y
Attiva l'accesso ai dischi paravirtualizzati.
CONFIG_VIRTIO_NET=y
Attiva l'accesso alla rete.
CONFIG_PCI_MSI=y
Attiva l'invio di interruzioni ad alte prestazioni, che è obbligatorio per i dispositivi
SSD locali.
Opzioni per la creazione del kernel per la sicurezza
Utilizza le impostazioni di sicurezza consigliate nelle opzioni per la creazione del kernel:
CONFIG_STRICT_DEVMEM=y
Limita /dev/mem in modo da consentire l'accesso solo allo spazio PCI, al codice BIOS e
alle regioni di dati.
CONFIG_DEVKMEM=n
Disattiva il supporto di /dev/kmem.
Blocca l'accesso alla memoria del kernel.
CONFIG_DEFAULT_MMAP_MIN_ADDR=65536
Imposta una memoria virtuale ridotta protetta dall'allocazione nello spazio utente.
CONFIG_DEBUG_RODATA=y
Contrassegna i dati di sola lettura del kernel come protetti dalla scrittura nelle tabelle di pagine
per rilevare le scritture accidentali (ed errate) a questi dati const. Questa
opzione può avere un lieve impatto sulle prestazioni perché una parte del codice
del kernel non sarà più coperta da una TLB di 2 MB.
CONFIG_DEBUG_SET_MODULE_RONX=y
Rileva le modifiche indesiderate al testo e
ai dati di sola lettura del modulo kernel caricabile. Questa opzione impedisce anche l'esecuzione dei dati del modulo.
CONFIG_CC_STACKPROTECTOR=y
Attiva la funzionalità GCC di -fstack-protector. Questa funzionalità inserisce un valore canary
all'inizio delle funzioni critiche, nello stack prima
dell'indirizzo di ritorno, e convalida il valore prima di eseguire effettivamente
il ritorno. Questo fa sì che gli overflow del buffer basati sullo stack (che devono sovrascrivere
questo indirizzo di ritorno) sovrascrivano il canary, il quale
viene rilevato, perciò l'attacco viene neutralizzato tramite un kernel panic.
CONFIG_COMPAT_VDSO=n
Garantisce che il VDSO non si trovi in un indirizzo prevedibile per rafforzare l'ASLR. Se
attivata, questa caratteristica mappa il VDSO all'indirizzo old-style
previsto, fornendo una posizione prevedibile per il salto del codice di exploit.
Inserisci N qui se stai utilizzando una versione glibc sufficientemente recente
(2.3.3 o successiva) per rimuovere la mappatura VDSO con mappatura elevata e
utilizzare esclusivamente il VDSO randomizzato.
CONFIG_COMPAT_BRK=n
Non disattivare la randomizzazione dell'heap.
CONFIG_X86_PAE=y
Imposta questa opzione per un kernel a 32 bit perché è necessario il PAE per il supporto di NX.
Ciò consente anche di supportare uno spazio di scambio più grande per scopi non di overcommit.
CONFIG_SYN_COOKIES=y
Fornisce una certa protezione contro gli attacchi SYN flood.
CONFIG_SECURITY_YAMA=y
Viene selezionato Yama, che estende il supporto del DAC con impostazioni di sicurezza aggiuntive a livello di sistema
oltre ai normali controlli di accesso discrezionale di Linux.
Al momento, l'impostazione è la limitazione dell'ambito di ptrace.
CONFIG_SECURITY_YAMA_STACKED=y
Questa opzione obbliga Yama a fare lo stack con l'LSM principale selezionato quando Yama
è disponibile.
Impostazioni di sicurezza del kernel
Puoi anche rafforzare la sicurezza del kernel tramite il file delle impostazioni
del kernel. Modifica il file /etc/sysctl.conf per includere le seguenti impostazioni di
sicurezza consigliate:
Installa il sistema operativo su un disco di avvio e
importa manualmente l'immagine in
Compute Engine come immagine personalizzata.
Se hai già importato il sistema operativo come immagine personalizzata,
configura le impostazioni non del kernel
sull'immagine in modo che possa funzionare in modo ottimale nell'ambiente
Compute Engine.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-06-30 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."]]