{"id":299839,"date":"2020-03-08T03:00:21","date_gmt":"2020-03-08T03:00:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=299839"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=299839","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0435\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 \u0441 \u0447\u0438\u0441\u0442\u044b\u043c CentOS 8.1 \u0432 \u043e\u0431\u043b\u0430\u043a\u0435 Amazon"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/491510\/\">\n<p>\u0414\u0430\u043d\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f &quot;\u0444\u043e\u0440\u043a\u043e\u043c&quot; \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u043e\u0439 <a href=\"https:\/\/habr.com\/ru\/company\/epam_systems\/blog\/169331\/\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u043f\u0440\u043e CentOS 5.9,<br \/>  \u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u043e\u0432\u043e\u0439 OS. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 AWS Marketplace \u043d\u0435\u0442 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 Centos8 \u043e\u0442 centos.org.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 \u043e\u0431\u043b\u0430\u043a\u0435 Amazon \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432 (\u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 <a href=\"https:\/\/docs.aws.amazon.com\/AWSEC2\/latest\/UserGuide\/AMIs.html\" rel=\"nofollow\">AMI<\/a>). Amazon \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438\u0445 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e, \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u044b, \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u043d\u0435\u0441\u0451\u0442. \u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d \u043e\u0431\u0440\u0430\u0437 \u0447\u0438\u0441\u0442\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432.<br \/>  \u0422\u043e\u0433\u0434\u0430 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0432\u044b\u0445\u043e\u0434 \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 AMI.<\/p>\n<p>  <\/p>\n<p>\u0412 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043e\u043f\u0438\u0441\u0430\u043d <a href=\"https:\/\/docs.aws.amazon.com\/AWSEC2\/latest\/UserGuide\/AMIs.html\" rel=\"nofollow\">\u0441\u043f\u043e\u0441\u043e\u0431<\/a> \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u00abinstance store-backed AMI\u00bb.<br \/>  \u041c\u0438\u043d\u0443\u0441 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0435\u0449\u0451 \u0438 \u0441\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u00abEBS-backed AMI\u00bb. \u0422\u0430\u043a \u0436\u0435, \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c Cockpit Image Builder. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0437\u044b, \u0432 <a href=\"https:\/\/docs.centos.org\/en-US\/centos\/install-guide\/Composer\/\" rel=\"nofollow\">CLI<\/a> \u0438\u043b\u0438 WEB <a href=\"https:\/\/developers.redhat.com\/blog\/2019\/05\/08\/red-hat-enterprise-linux-8-image-builder-building-custom-system-images\/\" rel=\"nofollow\">GUI<\/a> \u0440\u0435\u0436\u0438\u043c\u0435, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 Centos 8.<br \/>  \u041e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 EBS-backed AMI \u0432 \u043e\u0431\u043b\u0430\u043a\u0435 Amazon \u0431\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0448\u0430\u0433\u043e\u0432, \u043f\u043e\u0439\u0434\u0451\u0442 \u0440\u0435\u0447\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>  <\/p>\n<h1 id=\"plan-deystviy\">\u041f\u043b\u0430\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439:<\/h1>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435<\/li>\n<li>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0447\u0438\u0441\u0442\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438<\/li>\n<li>\u0421\u0434\u0435\u043b\u0430\u0442\u044c snapshot (\u0441\u043b\u0435\u043f\u043e\u043a) \u0434\u0438\u0441\u043a\u0430<\/li>\n<li>\u0417\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c AMI<\/li>\n<\/ul>\n<p>  <\/p>\n<h2 id=\"podgotovka-okruzheniya\">\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0448\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u043b\u044e\u0431\u043e\u0439 <a href=\"https:\/\/wiki.centos.org\/Cloud\/AWS\" rel=\"nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 Centos 7<\/a> \u043b\u044e\u0431\u043e\u0433\u043e \u0448\u0435\u0439\u043f\u0430, \u0445\u043e\u0442\u044c t2.micro. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 CLI:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">aws ec2 run-instances \\   --image-id ami-4bf3d731 \\   --region us-east-1 \\   --key-name alpha \\   --instance-type t2.micro \\   --subnet-id subnet-240a8618 \\   --associate-public-ip-address \\   --block-device-mappings DeviceName=\/dev\/sda1,Ebs={VolumeSize=8} \\   --block-device-mappings DeviceName=\/dev\/sdb,Ebs={VolumeSize=4}<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e\u0434\u043d\u0438\u043c\u0435\u0442 \u0438\u043d\u0442\u0441\u0442\u0430\u043d\u0441 \u0432 VPC, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u044b\u0439 subnet-id. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u0434\u0441\u0435\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u0430\u044f, \u0438 SG &#8216;default&#8217; \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u0432\u0441\u0435.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u043c\u0441\u044f \u043d\u0430 \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u043f\u043e ssh, \u043e\u0431\u043d\u043e\u0432\u0438\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c <code>dnf<\/code> \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c\u0441\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">sudo update -y &amp;&amp; sudo yum install -y dnf &amp;&amp; sudo reboot<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0442 <code>root<\/code>.<\/p>\n<p>  <\/p>\n<h2 id=\"ustanovka-chistogo-centos-81\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0447\u0438\u0441\u0442\u043e\u0433\u043e Centos 8.1<\/h2>\n<p>  <\/p>\n<h3 id=\"razmetka-faylovoy-sistemy-i-montirovanie-razdelov\">\u0420\u0430\u0437\u043c\u0435\u0442\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432<\/h3>\n<p>  <\/p>\n<pre><code class=\"plaintext\">DEVICE=\/dev\/xvdb ROOTFS=\/rootfs parted -s ${DEVICE} mktable gpt parted -s ${DEVICE} mkpart primary ext2 1 2 parted -s ${DEVICE} set 1 bios_grub on parted -s ${DEVICE} mkpart primary xfs 2 100%  mkfs.xfs -L root ${DEVICE}2 mkdir -p $ROOTFS mount ${DEVICE}2 $ROOTFS  mkdir $ROOTFS\/{proc,sys,dev,run} mount --bind \/proc $ROOTFS\/proc mount --bind \/sys $ROOTFS\/sys mount --bind \/dev $ROOTFS\/dev mount --bind \/run $ROOTFS\/run<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"sozdanie-dereva-katalogov\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432<\/h3>\n<p>  <\/p>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 RPM \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043b\u0435\u0433\u043a\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u043e\u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u0439 \u041e\u0421:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">PKGSURL=http:\/\/mirror.centos.org\/centos\/8\/BaseOS\/x86_64\/os\/Packages rpm --root=$ROOTFS --initdb rpm --root=$ROOTFS -ivh \\   $PKGSURL\/centos-release-8.1-1.1911.0.8.el8.x86_64.rpm \\   $PKGSURL\/centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm \\   $PKGSURL\/centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm  dnf --installroot=$ROOTFS --nogpgcheck --setopt=install_weak_deps=False \\    -y install audit authselect basesystem bash biosdevname coreutils \\    cronie curl dnf dnf-plugins-core dnf-plugin-spacewalk dracut-config-generic \\    dracut-config-rescue e2fsprogs filesystem firewalld glibc grub2 grubby hostname \\    initscripts iproute iprutils iputils irqbalance kbd kernel kernel-tools \\    kexec-tools less linux-firmware lshw lsscsi ncurses network-scripts \\    openssh-clients openssh-server passwd plymouth policycoreutils prefixdevname \\    procps-ng  rng-tools rootfiles rpm rsyslog selinux-policy-targeted setup \\    shadow-utils sssd-kcm sudo systemd util-linux vim-minimal xfsprogs \\    chrony cloud-init <\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u043e\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432, \u0438 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u043a\u0435\u0442\u044b.<br \/>  \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">dnf --installroot=$ROOTFS groupinstall base core \\     --excludepkgs &quot;NetworkManager*&quot; \\      -e &quot;i*-firmware&quot;<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 <code>yum<\/code> \u043d\u0435\u0442 <code>--excludepkgs<\/code>, \u0438 \u0440\u0430\u043d\u044c\u0448\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0433\u0440\u0443\u043f\u043f\u044b, \u0438 \u043f\u043e\u0442\u043e\u043c \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u044b.<br \/>  \u0421\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u043a\u0435\u0442\u043e\u0432 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0433\u0440\u0443\u043f\u043f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>dnf group info core<\/code> \u0434\u043b\u044f \u0433\u0440\u0443\u043f\u043f\u044b <code>core<\/code>.<\/p>\n<p>  <\/p>\n<h3 id=\"kstomazaciya-faylov-os\">\u041a\u0441\u0442\u043e\u043c\u0430\u0437\u0430\u0446\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u041e\u0421<\/h3>\n<p>  <\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0434\u043b\u044f \u0441\u0435\u0442\u0438, fstab, grub2 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0430\u043b\u044c\u043d\u044b\u0435 169.254 \u0430\u0434\u0440\u0435\u0441\u0430 AWS \u0434\u043b\u044f DNS \u0438 NTP.<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">cat &gt; $ROOTFS\/etc\/resolv.conf &lt;&lt; HABR nameserver 169.254.169.253 HABR  cat &gt; $ROOTFS\/etc\/sysconfig\/network &lt;&lt; HABR NETWORKING=yes NOZEROCONF=yes HABR  cat &gt; $ROOTFS\/etc\/sysconfig\/network-scripts\/ifcfg-eth0  &lt;&lt; HABR DEVICE=eth0 ONBOOT=yes BOOTPROTO=dhcp HABR  cat &gt; $ROOTFS\/etc\/fstab &lt;&lt; HABR LABEL=root \/ xfs defaults,relatime 1 1 HABR  sed -i  &quot;s\/cloud-user\/centos\/&quot; $ROOTFS\/etc\/cloud\/cloud.cfg echo &quot;server 169.254.169.123 prefer iburst minpoll 4 maxpoll 4&quot; &gt;&gt; $ROOTFS\/etc\/chrony.conf sed -i &quot;\/^pool \/d&quot; $ROOTFS\/etc\/chrony.conf sed -i &quot;s\/^AcceptEnv\/# \\0\/&quot; $ROOTFS\/etc\/ssh\/sshd_config  cat &gt; $ROOTFS\/etc\/default\/grub &lt;&lt; HABR GRUB_TIMEOUT=1 GRUB_DISTRIBUTOR=&quot;$(sed 's, release .*$,,g' \/etc\/system-release)&quot; GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT=&quot;console&quot; GRUB_CMDLINE_LINUX=&quot;crashkernel=auto console=ttyS0,115200n8 console=tty0 net.ifnames=0 biosdevname=0&quot; GRUB_DISABLE_RECOVERY=&quot;true&quot; GRUB_ENABLE_BLSCFG=true HABR<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0443\u0442, \u0432 GRUB_CMDLINE_LINUX \u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c selinux=0, \u0434\u043b\u044f \u0442\u0435\u0445 \u043a\u0442\u043e \u0432\u0441\u0435 \u0449\u0435 \u0431\u043e\u0438\u0442\u0441\u044f SELinux.<\/p>\n<p>  <\/p>\n<h3 id=\"peresborka-initramfs-v-chroot\">\u041f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0430 initramfs \u0432 chroot<\/h3>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0430\u0432\u043a\u0438 \u0444\u0430\u043b\u043e\u0432 grub, fstab \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u0431\u043e\u0440\u043a\u0443.<br \/>  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">KERNEL=$(ls $ROOTFS\/lib\/modules\/)  chroot $ROOTFS dracut -f -v \/boot\/initramfs-$KERNEL.img $KERNEL chroot $ROOTFS grub2-mkconfig -o \/boot\/grub2\/grub.cfg chroot $ROOTFS grub2-install $DEVICE chroot $ROOTFS update-crypto-policies --set FUTURE<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0443\u0442 <code>update-crypto-policies<\/code> \u2014 \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e, \u0434\u043b\u044f \u043f\u0430\u0440\u0430\u043d\u043e\u0438\u043a\u043e\u0432 \ud83d\ude42<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f &quot;\u043f\u0440\u043e\u0434\u0430&quot;, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">chroot $ROOTFS fips-mode-setup --enable chroot $ROOTFS grub2-mkconfig -o \/boot\/grub2\/grub.cfg chroot $ROOTFS grub2-install $DEVICE<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u041e\u0421, \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>update-crypto-policies --show<\/code> \u0432\u044b\u0434\u0430\u0441\u0442 FIPS.<\/p>\n<p>  <\/p>\n<h3 id=\"avtozapusk-i-chistka-musora\">\u0410\u0432\u0442\u043e\u0437\u0430\u043f\u0443\u0441\u043a \u0438 \u0427\u0438\u0441\u0442\u043a\u0430 \u043c\u0443\u0441\u043e\u0440\u0430<\/h3>\n<p>  <\/p>\n<pre><code class=\"plaintext\">chroot $ROOTFS systemctl enable network.service chroot $ROOTFS systemctl enable sshd.service chroot $ROOTFS systemctl enable cloud-init.service chroot $ROOTFS systemctl mask tmp.mount<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"plaintext\">dnf --installroot=$ROOTFS clean all truncate -c -s 0 $ROOTFS\/var\/log\/*.log rm -rf var\/lib\/dnf\/* touch $ROOTFS\/.autorelabel<\/code><\/pre>\n<p>  <\/p>\n<p><code>autorelabel<\/code> \u2014 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 SELinux \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0440\u0443\u0435\u043c \u0434\u0438\u0441\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">sync umount $ROOTFS\/{proc,sys,dev,run} umount $ROOTFS<\/code><\/pre>\n<p>  <\/p>\n<h3 id=\"registraciya-ami\">\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f AMI<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 ebs-\u0434\u0438\u0441\u043a\u0430 ami, \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043d\u0430\u043f\u0448\u043e\u0442 \u0434\u0438\u0441\u043a\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">aws ec2 create-snapshot \\     --volume-id vol-09f26eba4c50da110  --region us-east-1 \\     --description 'centos-release-8.1-1.1911.0.8 4.18.0-147.5.1 01'<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c. \u041f\u0440\u043e\u0432\u0435\u0440\u0435\u043c \u0441\u0442\u0430\u0442\u0443\u0441 \u043f\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e\u043c\u0443 SnapshotId:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">aws ec2   describe-snapshots  --region us-east-1 --snapshot-ids snap-0b665542fc59e58ed<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c <code>&quot;State&quot;: &quot;completed&quot;<\/code>, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c AMI \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">aws ec2 register-image \\     --region us-east-1 \\     --name 'CentOS-8.1-1.1911.0.8-minimal' \\     --description 'centos-release-8.1-1.1911.0.8 4.18.0-147.5.1 01' \\     --virtualization-type hvm --root-device-name \/dev\/sda1 \\     --block-device-mappings '[{&quot;DeviceName&quot;:&quot;\/dev\/sda1&quot;,&quot;Ebs&quot;: { &quot;SnapshotId&quot;: &quot;snap-0b665542fc59e58ed&quot;, &quot;VolumeSize&quot;:4,  &quot;DeleteOnTermination&quot;: true, &quot;VolumeType&quot;: &quot;gp2&quot;}}]' \\     --architecture x86_64 --sriov-net-support simple --ena-support  aws ec2 modify-image-attribute \\     --region us-east-1 \\     --image-id ami-011ed2a37dc89e206 \\     --launch-permission 'Add=[{Group=all}]' <\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0432\u0441\u0435. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u044b.<br \/>  \u0422\u0430\u043a\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0437, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0441 \u043b\u044e\u0431\u044b\u043c Linux-\u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432\u043e\u043c. \u041f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u0442\u043e\u0447\u043d\u043e Debian (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f debootstrap \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0447\u0438\u0441\u0442\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b) \u0438 RHEL-\u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/491510\/\"> https:\/\/habr.com\/ru\/post\/491510\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/491510\/\">\n<p>\u0414\u0430\u043d\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f &quot;\u0444\u043e\u0440\u043a\u043e\u043c&quot; \u043e\u0434\u043d\u043e\u0438\u043c\u0435\u043d\u043d\u043e\u0439 <a href=\"https:\/\/habr.com\/ru\/company\/epam_systems\/blog\/169331\/\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a> \u043f\u0440\u043e CentOS 5.9,<br \/>  \u0438 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u043e\u0432\u043e\u0439 OS. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 AWS Marketplace \u043d\u0435\u0442 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0437\u0430 Centos8 \u043e\u0442 centos.org.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-299839","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299839"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/299839\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}