Created
March 12, 2017 08:17
-
-
Save tetsuyainfra/5eb1fee40cdb9144e4720647de9d8ffa to your computer and use it in GitHub Desktop.
centos7 kickstart + liveimg メモ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
VM_NAME=centos7mini | |
VM_RAM=1024 | |
VM_CPU=1 | |
# VM削除 動作怪しいぞ | |
#virsh undefine ${VM_NAME} --remove-all-storage --delete-snapshots | |
# VMインストール | |
virt-install \ | |
--name ${VM_NAME} \ | |
--hvm \ | |
--virt-type kvm \ | |
--ram ${VM_RAM} \ | |
--vcpus ${VM_CPU} \ | |
--arch x86_64 \ | |
--os-type linux \ | |
--os-variant rhel7 \ | |
--boot hd \ | |
--disk pool=zfsimages,size=20,format=qcow2 \ | |
--network network=default,model=virtio \ | |
--network bridge=br0,model=virtio \ | |
--graphics none \ | |
--serial pty \ | |
--console pty \ | |
--location /ztank/libvirt/media/CentOS-7-x86_64-Minimal-1611.iso \ | |
--initrd-inject centos7.ks.cfg \ | |
--extra-args "inst.ks=file:/centos7.ks.cfg console=tty0 console=ttyS0,115200n8" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
# chroot するディレクトリを作成 | |
mkdir -p rootfs/ | |
# yum リポジトリの設定ファイルをコピー | |
rsync /etc/yum.repos.d/CentOS* rootfs/ -Rav | |
# resolv.conf をコピー | |
cp /etc/resolv.conf rootfs/etc/resolv.conf | |
# 主要なパッケージをインストール | |
#yum -y --installroot="$PWD/rootfs/" --releasever=7 install @core kernel grub2 authconfig mdadm lvm2 | |
yum -y --installroot="$PWD/rootfs/" --releasever=7 install @core kernel grub2 authconfig iputils | |
# chroot で中に入っていろいろ弄る | |
cp ./initialize.sh ./rootfs | |
chroot rootfs/ ./initialize.sh | |
rm ./rootfs/initialize.sh | |
# fast but lesser compression | |
GZIP="-1v" tar czvf ./rootfs.tgz --directory rootfs/ . | |
# default | |
#GZIP="-6v" tar czvf ./rootfs.tgz --directory rootfs/ . | |
# slow but most compress | |
#GZIP="-9v"" tar czvf ./rootfs.tgz --directory rootfs/ . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
# ipv6 disable | |
tee /etc/sysctl.d/ipv6-disable.conf <<'EOS' | |
net.ipv6.conf.all.disable_ipv6 = 1 | |
net.ipv6.conf.default.disable_ipv6 = 1 | |
EOS | |
# sshd_config | |
sed -i '/UseDNS /c UseDNS no' /etc/ssh/sshd_config | |
#sed -i '/PermitRootLogin /c PermitRootLogin without-password' /etc/ssh/sshd_config | |
sed -i '/AddressFamily /c AddressFamily inet' /etc/ssh/sshd_config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment