Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Linux
Dalam beberapa situasi, aplikasi Anda mungkin mengharuskan Anda membuat sistem operasi sendiri atau mengompilasi kernel kustom. Jika Anda mengompilasi kernel kustom atau membuat sistem operasi kustom untuk VM, pastikan sistem operasi tersebut memenuhi persyaratan dalam dokumen ini.
Membuat sistem operasi kustom adalah
tugas lanjutan bagi pengguna dengan aplikasi yang secara khusus memerlukan kernel
kustom. Sebagian besar pengguna dapat membuat VM dari salah satu image publik yang tersedia, menggunakan alat impor disk virtual otomatis untuk mengimpor disk ke Compute Engine dari lingkungan lain, atau mengimpor image kustom secara manual dari sistem dengan distribusi Linux standar umum.
Anda harus membuat kernel sistem operasi dengan opsi berikut:
CONFIG_KVM_GUEST=y
Aktifkan fungsi paravirtualisasi.
CONFIG_KVM_CLOCK=y
Aktifkan clock paravirtual (jika berlaku untuk versi kernel Anda).
CONFIG_VIRTIO_PCI=y
Aktifkan perangkat PCI yang diparavirtualisasi.
CONFIG_SCSI_VIRTIO=y
Aktifkan akses ke disk paravirtual.
CONFIG_VIRTIO_NET=y
Aktifkan akses ke jaringan.
CONFIG_PCI_MSI=y
Aktifkan pengiriman interupsi berperforma tinggi, yang diperlukan untuk perangkat SSD lokal.
Opsi build kernel untuk keamanan
Gunakan setelan keamanan yang direkomendasikan dalam opsi build kernel Anda:
CONFIG_STRICT_DEVMEM=y
Batasi /dev/mem untuk mengizinkan akses hanya ke ruang PCI, kode BIOS, dan
wilayah data.
CONFIG_DEVKMEM=n
Nonaktifkan dukungan untuk /dev/kmem.
Memblokir akses ke memori kernel.
CONFIG_DEFAULT_MMAP_MIN_ADDR=65536
Menetapkan memori virtual rendah yang dilindungi dari alokasi ruang pengguna.
CONFIG_DEBUG_RODATA=y
Tandai data hanya baca kernel sebagai dilindungi dari penulisan dalam tabel halaman,
untuk menangkap penulisan yang tidak disengaja (dan salah) ke data const tersebut. Opsi ini dapat sedikit memengaruhi performa karena sebagian kode kernel tidak akan lagi tercakup oleh TLB 2 MB.
CONFIG_DEBUG_SET_MODULE_RONX=y
Mendeteksi modifikasi yang tidak diinginkan pada teks modul kernel yang dapat dimuat dan data hanya baca. Opsi ini juga mencegah eksekusi data modul.
CONFIG_CC_STACKPROTECTOR=y
Mengaktifkan fitur GCC -fstack-protector. Fitur ini menempatkan nilai canary
di awal fungsi penting, pada stack sebelum
alamat kembali, dan memvalidasi nilai sebelum benar-benar
dikembalikan. Hal ini juga menyebabkan buffer overflow berbasis stack (yang perlu
mengganti alamat kembali ini) mengganti canary, yang akan
terdeteksi dan serangan kemudian dinetralkan menggunakan kernel panic.
CONFIG_COMPAT_VDSO=n
Memastikan VDSO tidak berada di alamat yang dapat diprediksi untuk memperkuat ASLR. Jika diaktifkan, fitur ini memetakan VDSO ke alamat gaya lama yang dapat diprediksi, sehingga menyediakan lokasi yang dapat diprediksi untuk kode eksploitasi agar dapat melompat ke sana.
Ucapkan N di sini jika Anda menjalankan versi glibc yang cukup baru
(2.3.3 atau yang lebih baru), untuk menghapus pemetaan VDSO yang dipetakan tinggi dan
menggunakan VDSO acak secara eksklusif.
CONFIG_COMPAT_BRK=n
Jangan menonaktifkan pengacakan heap.
CONFIG_X86_PAE=y
Tetapkan opsi ini untuk kernel 32-bit karena PAE diperlukan untuk dukungan NX.
Hal ini juga memungkinkan dukungan swapspace yang lebih besar untuk tujuan non-overcommit.
CONFIG_SYN_COOKIES=y
Memberikan perlindungan terhadap serangan SYN flooding.
CONFIG_SECURITY_YAMA=y
Opsi ini memilih Yama, yang memperluas dukungan DAC dengan setelan keamanan tambahan di seluruh sistem di luar kontrol akses diskresi Linux biasa.
Saat ini, setelannya adalah pembatasan cakupan ptrace.
CONFIG_SECURITY_YAMA_STACKED=y
Opsi ini memaksa Yama untuk ditumpuk dengan LSM utama yang dipilih saat Yama tersedia.
Setelan keamanan kernel
Anda juga dapat memperkuat keamanan kernel melalui file setelan kernel. Edit file /etc/sysctl.conf untuk menyertakan setelan keamanan
yang direkomendasikan berikut:
Instal sistem operasi ke boot disk dan impor image secara manual ke Compute Engine sebagai image kustom.
Jika Anda telah mengimpor sistem operasi sebagai image kustom, konfigurasi setelan non-kernel pada image agar dapat berfungsi secara optimal dalam lingkungan Compute Engine.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-08-18 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."]]