All Products
Search
Document Center

Elastic Compute Service:Persyaratan gambar Alibaba Cloud Linux

Last Updated:Apr 28, 2026

Gambar Linux kustom harus memenuhi persyaratan berikut dan lulus uji kompatibilitas tipe instans ECS sebelum diimpor atau dirilis ke Alibaba Cloud Marketplace.

Partisi disk

Gambar harus memenuhi persyaratan partisi disk berikut:

  • Pengubahan ukuran disk

    • Buat partisi logis berdasarkan partisi fisik. Gunakan partisi logis terakhir pada setiap disk sebagai partisi root untuk mencegah kegagalan partisi disk sistem.

    • Untuk sistem operasi yang mendukung pengubahan ukuran disk secara online, instal paket cloud-utils-growpart dan gunakan growpart untuk memperluas partisi. Lihat Perluas partisi dan sistem file disk pada instance Linux.

  • Partisi swap

    Jangan gunakan partisi swap.

  • Pemasangan disk

    Konfigurasikan UUID pada file /etc/fstab dan GRUB. Lihat Pasang otomatis data disk dengan UUID di /etc/fstab dan Identifikasi partisi disk berdasarkan UUID di GRUB.

    Penting

    Konfigurasi /etc/fstab yang salah dapat menyebabkan instance gagal boot setelah restart.

  • Manajemen LVM

    Jangan gunakan LVM untuk mengelola partisi disk.

  • Ukuran disk

    Tetapkan ukuran disk sistem minimal 20 GiB.

  • Mode boot gambar

    Konfigurasikan mode boot pada gambar on-premises Anda agar sesuai dengan tipe instans target. Tentukan mode boot saat mengimpor gambar.

    Catatan

    Jika gambar on-premises Anda mendukung BIOS dan UEFI, tentukan mode UEFI-Preferred saat mengimpor gambar. Hal ini memungkinkan gambar beradaptasi dengan semua mode boot tipe instans dan mengurangi biaya pembuatan gambar.

Perangkat lunak yang diperlukan

  • Instal driver virtio

    Instal driver virtio dan tambahkan ke initramfs sebelum merilis gambar. Driver virtio memastikan gambar berfungsi pada instance ECS. Lihat Instal driver virtio.

  • Instal driver NVMe

    Famili instance ECS yang lebih baru, seperti ecs.g8i dan ecs.g7se, menggunakan protokol Non-Volatile Memory Express (NVMe) untuk penyambungan disk. Untuk menggunakan gambar Anda dengan famili instance tersebut, instal driver NVMe. Lihat Instal driver NVMe pada gambar kustom. Saat mengimpor gambar, atur NVMe Drive ke Supported. Lihat Ubah properti dan tag gambar.

  • Instal cloud-init

    Instal cloud-init untuk mengaktifkan inisialisasi instance. Lihat Instal cloud-init. Kami merekomendasikan cloud-init versi 23.2.2, yang mendukung akses metadata instans dalam mode penguatan keamanan.

    Catatan

    Untuk menggunakan cloud-init dalam mengubah password, kernel harus mendukung CONFIG_FW_CFG_SYSFS. Kernel komunitas Linux 4.6+ dan kernel CentOS 3.10.0-826.el7+ mendukung fitur ini secara default. Untuk memverifikasi, jalankan grep -nr CONFIG_FW_CFG_SYSFS /boot/config-$(uname -r) pada server sumber. Jika output berisi CONFIG_FW_CFG_SYSFS=y, kernel mendukung CONFIG_FW_CFG_SYSFS.

  • Instal Cloud Assistant

    Instal Cloud Assistant, alat O&M otomatis native untuk ECS. Cloud Assistant memungkinkan Anda menjalankan perintah shell, PowerShell, dan batch secara batch pada instance ECS tanpa password atau jump server. Gunakan untuk O&M otomatis, pemantauan proses, manajemen perangkat lunak, kontrol layanan, dan instalasi patch. Lihat Instal Cloud Assistant Agent.

  • Gunakan Security Center untuk melindungi server sumber gambar

    Gunakan Security Center untuk melindungi server Anda. Security Center menyediakan pemberitahuan peringatan, deteksi dan penghapusan virus, deteksi dan penghapusan webshell, perlindungan client, serta pemindaian gambar untuk server cloud dan on-premises.

Konfigurasi sistem

  • Konfigurasikan jam

    Atur jam perangkat keras ke Coordinated Universal Time (UTC). Contoh perintah:

    cat > /etc/adjtime << EOF
    0.0 0 0.0
    0
    UTC
    EOF
    
    timedatectl set-local-rtc 0

    Lihat Waktu dan zona waktu Linux.

  • Konfigurasikan layanan sshd

    Konfigurasikan layanan sshd untuk akses remote.

    sshd memungkinkan login dan manajemen remote terenkripsi berbasis SSH untuk Linux. Modifikasi /etc/ssh/sshd_config sebagai berikut:

    UseDNS no
    AddressFamily inet 
    SyslogFacility AUTHPRIV 
    PermitRootLogin yes 
    PasswordAuthentication yes 
  • Konfigurasikan layanan chrony atau layanan NTP

    Konfigurasikan layanan chrony atau Network Time Protocol (NTP) untuk sinkronisasi jam.

    chrony dan NTP menyinkronkan jam sistem dengan sumber waktu untuk memastikan akurasi waktu dan mencegah masalah deviasi waktu.

    Contoh perintah untuk mengonfigurasi layanan chrony

    chrony_file=/etc/chrony.conf
    cat >$chrony_file <<EOF
    # Gunakan server NTP Alibaba
    # NTP Publik
    # NTP Alicloud
    
    
    server ntp.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp.aliyun.com minpoll 4 maxpoll 10 iburst
    server ntp1.aliyun.com minpoll 4 maxpoll 10 iburst
    server ntp1.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp10.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp11.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp12.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp2.aliyun.com minpoll 4 maxpoll 10 iburst
    server ntp2.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp3.aliyun.com minpoll 4 maxpoll 10 iburst
    server ntp3.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp4.aliyun.com minpoll 4 maxpoll 10 iburst
    server ntp4.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp5.aliyun.com minpoll 4 maxpoll 10 iburst
    server ntp5.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp6.aliyun.com minpoll 4 maxpoll 10 iburst
    server ntp6.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp7.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp8.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    server ntp9.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
    
    # Abaikan stratum dalam pemilihan sumber.
    stratumweight 0.05
    
    # Catat laju perolehan/kehilangan waktu jam sistem.
    driftfile /var/lib/chrony/drift
    
    # Aktifkan sinkronisasi RTC kernel.
    rtcsync
    
    # Pada tiga pembaruan pertama, langkahi jam sistem alih-alih slew
    # jika penyesuaian lebih dari 10 detik.
    makestep 10 3
    
    # Izinkan akses client NTP dari jaringan lokal.
    #allow 192.168/16
    
    # Dengarkan perintah hanya pada localhost.
    bindcmdaddress 127.0.0.1
    bindcmdaddress ::1
    
    # Nonaktifkan pencatatan akses client.
    noclientlog
    
    # Kirim pesan ke syslog jika penyesuaian jam lebih dari 0,5 detik.
    logchange 0.5
    
    logdir /var/log/chrony
    #log measurements statistics tracking
    EOF

    Contoh perintah untuk mengonfigurasi layanan NTP

    ntp_conf=/etc/ntp.conf
        cat > $ntp_conf << EOF
    driftfile  /var/lib/ntp/drift
    pidfile    /var/run/ntpd.pid
    logfile    /var/log/ntp.log
    
    
    # Dukungan Kontrol Akses
    restrict    default kod nomodify notrap nopeer noquery
    restrict -6 default kod nomodify notrap nopeer noquery
    restrict 127.0.0.1
    restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap nopeer noquery
    restrict 172.16.0.0 mask 255.240.0.0 nomodify notrap nopeer noquery
    restrict 100.64.0.0 mask 255.192.0.0 nomodify notrap nopeer noquery
    restrict 10.0.0.0 mask 255.0.0.0 nomodify notrap nopeer noquery
    
    
    # jam lokal
    server 127.127.1.0
    fudge  127.127.1.0 stratum 10
    
    restrict ntp.aliyun.com nomodify notrap nopeer noquery
    restrict ntp.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp1.aliyun.com nomodify notrap nopeer noquery
    restrict ntp1.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp10.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp11.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp12.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp2.aliyun.com nomodify notrap nopeer noquery
    restrict ntp2.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp3.aliyun.com nomodify notrap nopeer noquery
    restrict ntp3.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp4.aliyun.com nomodify notrap nopeer noquery
    restrict ntp4.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp5.aliyun.com nomodify notrap nopeer noquery
    restrict ntp5.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp6.aliyun.com nomodify notrap nopeer noquery
    restrict ntp6.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp7.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp8.cloud.aliyuncs.com nomodify notrap nopeer noquery
    restrict ntp9.cloud.aliyuncs.com nomodify notrap nopeer noquery
    
    
    server ntp.aliyun.com iburst minpoll 4 maxpoll 10
    server ntp.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp1.aliyun.com iburst minpoll 4 maxpoll 10
    server ntp1.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp10.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp11.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp12.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp2.aliyun.com iburst minpoll 4 maxpoll 10
    server ntp2.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp3.aliyun.com iburst minpoll 4 maxpoll 10
    server ntp3.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp4.aliyun.com iburst minpoll 4 maxpoll 10
    server ntp4.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp5.aliyun.com iburst minpoll 4 maxpoll 10
    server ntp5.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp6.aliyun.com iburst minpoll 4 maxpoll 10
    server ntp6.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp7.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp8.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    server ntp9.cloud.aliyuncs.com iburst minpoll 4 maxpoll 10
    EOF
  • Konfigurasikan layanan MOTD

    Konfigurasikan layanan Message of the Day (MOTD) untuk menampilkan pesan saat pengguna login.

    Contoh perintah:

    echo -e "\nSelamat datang di Alibaba Cloud Elastic Compute Service!  \n" > /etc/motd
  • Nonaktifkan layanan Firewalld

    Nonaktifkan layanan Firewalld. Security group menyediakan perlindungan firewall di cloud, sehingga Firewalld tidak diperlukan. Contoh perintah:

    systemctl stop firewalld
    systemctl disable firewalld
  • Konfigurasikan repositori pip

    Jika pip dikonfigurasi, gunakan repositori pip Alibaba Cloud. Contoh isi file ~/.pip/pip.conf:

    [global]
    index-url=http://mirrors.cloud.aliyuncs.com/pypi/simple/
    
    [install]
    trusted-host=mirrors.cloud.aliyuncs.com
  • Konfigurasikan pengaturan jaringan

    Jika NetworkManager atau layanan jaringan digunakan, konfigurasikan /etc/sysconfig/network-scripts/ifcfg-eth0:

    DEVICE=eth0
    BOOTPROTO=dhcp
    ONBOOT=yes

    Untuk konfigurasi jaringan lainnya, lihat Konfigurasi ENI sekunder.

Konfigurasi parameter kernel

  • Konfigurasikan parameter kernelopt

    Konfigurasikan parameter kernel GRUB untuk memastikan sistem operasi dapat boot dengan benar. Contoh berikut menggunakan sistem operasi Debian.

    1. Pada /etc/default/grub, tambahkan berikut ke baris GRUB_CMDLINE_LINUX=:

      • Arsitektur x86_64

        net.ifnames=0 console=tty0 console=ttyS0,115200n8
      • Arsitektur Arm64

        net.ifnames=0 console=tty0 console=ttyAMA0,115200n8 
    2. Jalankan sudo update-grub2 untuk menerapkan konfigurasi GRUB.

      Catatan

      Lokasi file konfigurasi GRUB dan perintah untuk menerapkan perubahan bervariasi tergantung sistem operasi. Lihat Instal driver NVMe pada gambar kustom.

  • Konfigurasikan parameter sysctl

    Konfigurasikan parameter sysctl untuk mengoptimalkan perilaku runtime kernel Linux.

    1. Tambahkan berikut ke /etc/sysctl.conf:

      vm.swappiness = 0
      kernel.sysrq = 1
      
      net.ipv4.neigh.default.gc_stale_time = 120
      
      net.ipv4.conf.all.rp_filter = 0
      net.ipv4.conf.default.rp_filter = 0
      net.ipv4.conf.default.arp_announce = 2
      net.ipv4.conf.lo.arp_announce = 2
      net.ipv4.conf.all.arp_announce = 2
      
      net.ipv4.tcp_max_tw_buckets = 5000
      net.ipv4.tcp_syncookies = 1
      net.ipv4.tcp_max_syn_backlog = 1024
      net.ipv4.tcp_synack_retries = 2
      net.ipv4.tcp_slow_start_after_idle = 0
    2. Jalankan sudo sysctl -p untuk menerapkan perubahan.

Rekomendasi keamanan sistem

Terapkan langkah-langkah penguatan keamanan berikut sebelum mengimpor gambar kustom:

  • Kunci akun root untuk mencegah login root berbasis password.

  • Atur PasswordAuthentication ke no untuk menonaktifkan login berbasis kata sandi.

    Catatan

    Jika Anda menetapkan kata sandi root saat inisialisasi instance, atur PasswordAuthentication ke yes untuk mengaktifkan login berbasis kata sandi.

Contoh kode:

  dst=/etc/ssh/sshd_config
  sed -i 's/^SyslogFacility.*//' $dst
  sed -i 's/^PermitRootLogin.*//' $dst
  sed -i 's/^PasswordAuthentication.*//' $dst

  echo UseDNS no >> $dst
  echo SyslogFacility AUTHPRIV >> $dst
  echo PasswordAuthentication no >> $dst

  passwd -l root
  sed -i -e 's/root:[^:]*:/root:*:/g' /etc/shadow

Bersihkan informasi gambar

Independent software vendors (ISVs) dapat membersihkan catatan historis dan log sebelum merilis gambar.