2019/12/03

PXE preseed_RAID 설정

## rrr very wichtig!!
d-i debconf/priority select critical
debconf debconf/priority select critical
unknown debconf/priority        string critical

### Mirror settings
d-i mirror/country string manual
d-i mirror/protocol string http
d-i mirror/http/hostname string mirror.ip-projects.de
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
d-i mirror/suite string yakkety
d-i mirror/udeb/suite string yakkety
d-i mirror/http/mirror select mirror.ip-projects.de

### Apt setup
d-i apt-setup/restricted boolean true
d-i apt-setup/universe boolean true
#d-i apt-setup/backports boolean true
d-i apt-setup/services-select multiselect security
d-i apt-setup/security_host string security.ubuntu.com
d-i apt-setup/security_path string /ubuntu
#apt-setup-udeb apt-setup/security_host string mirror.ip-projects.de/debian-security

d-i ssh/new_config boolean true
d-i ssh/protocol2_only boolean true
d-i debian-installer/allow_unauthenticated string true
apt-mirror-setup        apt-setup/mirror/error  select  Retry

### Package selection
d-i pkgsel/language-packs multiselect en, de
d-i pkgsel/include string openssh-server mc nano console-data console-setup postfix ntp
tasksel tasksel/first multiselect standard
popularity-contest popularity-contest/participate boolean false

# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# And the same goes for the confirmation to write the lvm partitions.
d-i partman-lvm/confirm boolean true

#Name default volume group vm
d-i partman-auto-lvm/new_vg_name string vg

# You can choose one of the three predefined partitioning recipes:
# - atomic: all files in one partition
# - home: separate /home partition
# - multi: separate /home, /usr, /var, and /tmp partitions
#d-i partman-auto/choose_recipe select expert_recipe

# This command is run immediately before the partitioner starts. It may be
# useful to apply dynamic partitioner preseeding that depends on the state
# of the disks (which may not be visible when preseed/early_command runs).
d-i partman/early_command string modprobe -r usb_storage; \
sh -c 'set -- $(vgs --rows --noheadings | head -n 1); for vg in "$@"; do vgremove -f "$vg"; done; set -- $(pvs --rows --noheadings | head -n 1); for pv in "$@"; do pvremove -f "$pv"; done'; \
cat /proc/cmdline|xargs -n 1|grep raid=|sed -r 's/raid=//g' > /tmp/raidmode; \
cat /proc/cmdline|xargs -n 1|grep boot_disc=|sed -r 's/boot_disc=//g' > /tmp/boot_disc; \
cat /proc/cmdline|xargs -n 1|grep boot_fs=|sed -r 's/boot_fs=//g' > /tmp/boot_fs; \
cat /proc/cmdline|xargs -n 1|grep swap_disc=|sed -r 's/swap_disc=//g' > /tmp/swap_disc; \
cat /proc/cmdline|xargs -n 1|grep root_disc=|sed -r 's/root_disc=//g' > /tmp/root_disc; \
cat /proc/cmdline|xargs -n 1|grep root_fs=|sed -r 's/root_fs=//g' > /tmp/root_fs; \
cat /proc/cmdline|xargs -n 1|grep server_ip=|sed -r 's/server_ip=//g' > /tmp/serverip; \
cat /proc/cmdline|xargs -n 1|grep hostname=|sed -r 's/hostname=//g' > /tmp/hostname; \
cat /proc/cmdline|xargs -n 1|grep domain=|sed -r 's/domain=//g' > /tmp/domain; \
BOOT_DISC=`cat /tmp/boot_disc`; \
BOOT_FS=`cat /tmp/boot_fs`; \
SWAP_DISC=`cat /tmp/swap_disc`; \
ROOT_DISC=`cat /tmp/root_disc`; \
if [ "$ROOT_DISC" = "Rest" ]; then \
ROOT_DISC_SIZE=1000000000; \
else \
ROOT_DISC_SIZE=$((ROOT_DISC * 1024)); \
fi; \
ROOT_FS=`cat /tmp/root_fs`; \
HOSTNAME=`cat /tmp/hostname`; \
DOMAIN=`cat /tmp/domain`; \
SERVERIP=`cat /tmp/serverip`; \
sed -i "s/^127.0.1.1.*/${SERVERIP} ${HOSTNAME}.${DOMAIN} ${HOSTNAME}/g" /etc/hosts; \
sed -i 's/^127.0.0.1.*/127.0.0.1 localhost.localdomain localhost/g' /etc/hosts;  \
echo "${HOSTNAME}.${DOMAIN}" > /etc/hostname; \
echo "${HOSTNAME}.${DOMAIN}" > /etc/mailname; \
RAIDMODE=`cat /tmp/raidmode`; \
DISKA=$(list-devices disk|head -n1);\
DISKB=$(list-devices disk|head -n2|tail -1);\
DISKC=$(list-devices disk|head -n3|tail -1);\
DISKD=$(list-devices disk|head -n4|tail -1);\
if [ "${DISKA#/dev/cciss}" != "$DISKA" ]; then DISKAP="p"; fi;\
if [ "${DISKB#/dev/cciss}" != "$DISKB" ]; then DISKBP="p"; fi;\
if [ "${DISKC#/dev/cciss}" != "$DISKC" ]; then DISKCP="p"; fi;\
if [ "${DISKD#/dev/cciss}" != "$DISKD" ]; then DISKDP="p"; fi;\
if [ "$ROOT_DISC" = "Rest" ] && [ "$RAIDMODE" = "NoRaid" ]; then \
debconf-set grub-installer/bootdev "$DISKA";\
debconf-set partman-auto/disk "$DISKA";\
debconf-set partman-auto/method "lvm"; \
debconf-set partman-auto/expert_recipe "root :: \
                1 1 1 free \$gptonly{ } \$primary{ } method{ biosgrub } . \
                100 ${BOOT_DISC} ${BOOT_DISC} ${BOOT_FS} \$primary{ } \$bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ${BOOT_FS} } mountpoint{ /boot } . \
                100 4000 4000 ext3 \$defaultignore{ } \$primary{ } method{ lvm } vg_name{ vg } . \
                256 ${SWAP_DISC} ${SWAP_DISC} linux-swap \$lvmok{ } lv_name{ swap } in_vg{ vg } method{ swap } format{ } . \
                256 ${ROOT_DISC_SIZE} ${ROOT_DISC_SIZE} ${ROOT_FS} \$lvmok{ } lv_name{ root } in_vg{ vg } method{ format } format{ } use_filesystem{ } filesystem{ ${ROOT_FS} } mountpoint{ / } ."; \
fi; \
##else \
if [ "$ROOT_DISC" != "Rest" ] && [ "$RAIDMODE" = "NoRaid" ]; then \
debconf-set grub-installer/bootdev "$DISKA";\
debconf-set partman-auto/disk "$DISKA";\
debconf-set partman-auto/method "lvm"; \
debconf-set partman-auto/expert_recipe "root :: \
                1 1 1 free \$gptonly{ } \$primary{ } method{ biosgrub } . \
                100 ${BOOT_DISC} ${BOOT_DISC} ${BOOT_FS} \$primary{ } \$bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ${BOOT_FS} } mountpoint{ /boot } . \
                100 4000 4000 ext3 \$defaultignore{ } \$primary{ } method{ lvm } vg_name{ vg } . \
                256 ${SWAP_DISC} ${SWAP_DISC} linux-swap \$lvmok{ } lv_name{ swap } in_vg{ vg } method{ swap } format{ } . \
                256 ${ROOT_DISC_SIZE} ${ROOT_DISC_SIZE} ${ROOT_FS} \$lvmok{ } lv_name{ root } in_vg{ vg } method{ format } format{ } use_filesystem{ } filesystem{ ${ROOT_FS} } mountpoint{ / } . \
1024 1024 1024 ext4 \$defaultignore{ } \$lvmok{ } lv_name{ lv_delete } in_vg{ vg } method{ format } format{ } use_filesystem{ } filesystem{  } ."; \
fi; \
if [ "$ROOT_DISC" = "Rest" ] && [ "$RAIDMODE" = "Raid1" ]; then \
debconf-set grub-installer/bootdev "$DISKA $DISKB";\
debconf-set partman-auto/disk "$DISKA $DISKB";\
debconf-set partman-auto/method "raid"; \
debconf-set partman-auto-raid/recipe "1 2 0 ${BOOT_FS} /boot /dev/sda2#/dev/sdb2 . 1 2 0 lvm - /dev/sda3#/dev/sdb3 ."; \
debconf-set partman-auto/expert_recipe "multiraid :: \
    1 1 1 free \$gptonly{ } \$primary{ } method{ biosgrub } . \
    100 ${BOOT_DISC} ${BOOT_DISC} raid \$lvmignore{ } \$primary{ } method{ raid } . \
    100 4000 4000 raid \$lvmignore{ } \$primary{ } method{ raid } . \
    256 ${SWAP_DISC} ${SWAP_DISC} linux-swap \$defaultignore{ } in_vg{ vg } lv_name{ swap } \$lvmok{ } method{ swap } format{ } . \
    256 ${ROOT_DISC_SIZE} ${ROOT_DISC_SIZE} ${ROOT_FS} \$defaultignore{ } in_vg{ vg } lv_name{ root } \$lvmok{ } method{ format } format{ } use_filesystem{ } filesystem{ ${ROOT_FS} } mountpoint{ / } ."; \
fi; \
if [ "$ROOT_DISC" != "Rest" ] && [ "$RAIDMODE" = "Raid1" ]; then \
#debconf-set grub-installer/bootdev "$DISKA $DISKB";\
debconf-set partman-auto/disk "$DISKA $DISKB";\
debconf-set partman-auto/method "raid"; \
debconf-set partman-auto-raid/recipe "1 2 0 ${BOOT_FS} /boot /dev/sda2#/dev/sdb2 . 1 2 0 lvm - /dev/sda3#/dev/sdb3 ."; \
debconf-set partman-auto/expert_recipe "multiraid :: \
    1 1 1 free \$gptonly{ } \$primary{ } method{ biosgrub } . \
    100 ${BOOT_DISC} ${BOOT_DISC} raid \$lvmignore{ } \$primary{ } method{ raid } . \
    100 4000 4000 raid \$lvmignore{ } \$primary{ } method{ raid } . \
    256 ${SWAP_DISC} ${SWAP_DISC} linux-swap \$defaultignore{ } lv_name{ swap } in_vg{ vg } \$lvmok{ } method{ swap } format{ } . \
    256 ${ROOT_DISC_SIZE} ${ROOT_DISC_SIZE} ${ROOT_FS} \$defaultignore{ } lv_name{ root } in_vg{ vg } \$lvmok{ } method{ format } format{ } use_filesystem{ } filesystem{ ${ROOT_FS} } mountpoint{ / } . \
    1024 1024 1024 ext4 \$defaultignore{ } lv_name{ lv_delete } \$lvmok{ } in_vg{ vg } method{ format } format{ } use_filesystem{ } filesystem{  } ."; \
fi; \
if [ "$ROOT_DISC" = "Rest" ] && [ "$RAIDMODE" = "Raid5" ]; then \
debconf-set grub-installer/bootdev "$DISKA $DISKB $DISKC $DISKD";\
debconf-set partman-auto/disk "$DISKA $DISKB $DISKC $DISKD";\
debconf-set partman-auto/method "raid"; \
debconf-set partman-auto-raid/recipe "1 4 0 ${BOOT_FS} /boot /dev/sda2#/dev/sdb2#/dev/sdc2#/dev/sdd2 . 5 4 0 lvm - /dev/sda3#/dev/sdb3#/dev/sdc3#/dev/sdd3 ."; \
debconf-set partman-auto/expert_recipe "multiraid ::                                                                                                      \
    1 1 1 free \$gptonly{ } \$primary{ } method{ biosgrub } . \
    100 ${BOOT_DISC} ${BOOT_DISC} raid \$lvmignore{ } \$primary{ } method{ raid } . \
    100 4000 4000 raid \$lvmignore{ } \$primary{ } method{ raid } . \
    256 ${SWAP_DISC} ${SWAP_DISC} linux-swap \$defaultignore{ } lv_name{ swap } in_vg{ vg } \$lvmok{ } method{ swap } format{ } . \
    256 ${ROOT_DISC_SIZE} ${ROOT_DISC_SIZE} ${ROOT_FS} \$defaultignore{ } lv_name{ root } in_vg{ vg } \$lvmok{ } method{ format } format{ } use_filesystem{ } filesystem{ ${ROOT_FS} } mountpoint{ / } ."; \
fi; \
if [ "$ROOT_DISC" != "Rest" ] && [ "$RAIDMODE" = "Raid5" ]; then \
debconf-set grub-installer/bootdev "$DISKA $DISKB $DISKC $DISKD";\
debconf-set partman-auto/disk "$DISKA $DISKB $DISKC $DISKD";\
debconf-set partman-auto/method "raid"; \
debconf-set partman-auto-raid/recipe "1 4 0 ${BOOT_FS} /boot /dev/sda2#/dev/sdb2#/dev/sdc2#/dev/sdd2 . 5 4 0 lvm - /dev/sda3#/dev/sdb3#/dev/sdc3#/dev/sdd3 ."; \
debconf-set partman-auto/expert_recipe "multiraid ::                                                                                                      \
    1 1 1 free \$gptonly{ } \$primary{ } method{ biosgrub } . \
    100 ${BOOT_DISC} ${BOOT_DISC} raid \$lvmignore{ } \$primary{ } method{ raid } . \
    100 4000 4000 raid \$lvmignore{ } \$primary{ } method{ raid } . \
    256 ${SWAP_DISC} ${SWAP_DISC} linux-swap \$defaultignore{ } lv_name{ swap } in_vg{ vg } \$lvmok{ } method{ swap } format{ } . \
    256 ${ROOT_DISC_SIZE} ${ROOT_DISC_SIZE} ${ROOT_FS} \$defaultignore{ } lv_name{ root } in_vg{ vg } \$lvmok{ } method{ format } format{ } use_filesystem{ } filesystem{ ${ROOT_FS} } mountpoint{ / } . \
    1024 1024 1024 ext4 \$defaultignore{ } \$lvmok{ } lv_name{ lv_delete } in_vg{ vg } method{ format } format{ } use_filesystem{ } filesystem{  } ."; \
fi; \
if [ "$ROOT_DISC" = "Rest" ] && [ "$RAIDMODE" = "Raid10" ]; then \
debconf-set grub-installer/bootdev "$DISKA $DISKB $DISKC $DISKD";\
debconf-set partman-auto/disk "$DISKA $DISKB $DISKC $DISKD";\
debconf-set partman-auto/method "raid"; \
debconf-set partman-auto-raid/recipe "1 4 0 ${BOOT_FS} /boot /dev/sda2#/dev/sdb2#/dev/sdc2#/dev/sdd2 . 10 4 0 lvm - /dev/sda3#/dev/sdb3#/dev/sdc3#/dev/sdd3 ."; \
debconf-set partman-auto/expert_recipe "multiraid :: \
    1 1 1 free \$gptonly{ } \$primary{ } method{ biosgrub } . \
    100 ${BOOT_DISC} ${BOOT_DISC} raid \$lvmignore{ } \$primary{ } method{ raid } . \
    100 4000 4000 raid \$lvmignore{ } \$primary{ } method{ raid } . \
    256 ${SWAP_DISC} ${SWAP_DISC} linux-swap \$defaultignore{ } lv_name{ swap } in_vg{ vg } \$lvmok{ } method{ swap } format{ } . \
    256 ${ROOT_DISC_SIZE} ${ROOT_DISC_SIZE} ${ROOT_FS} \$defaultignore{ } lv_name{ root } in_vg{ vg } \$lvmok{ } method{ format } format{ } use_filesystem{ } filesystem{ ${ROOT_FS} } mountpoint{ / } ."; \
fi; \
if [ "$ROOT_DISC" != Rest ] && [ "$RAIDMODE"  = "Raid10" ]; then \
debconf-set grub-installer/bootdev "$DISKA $DISKB $DISKC $DISKD";\
debconf-set partman-auto/disk "$DISKA $DISKB $DISKC $DISKD";\
debconf-set partman-auto/method "raid"; \
debconf-set partman-auto-raid/recipe "1 4 0 ${BOOT_FS} /boot /dev/sda2#/dev/sdb2#/dev/sdc2#/dev/sdd2 . 10 4 0 lvm - /dev/sda3#/dev/sdb3#/dev/sdc3#/dev/sdd3 ."; \
debconf-set partman-auto/expert_recipe "multiraid :: \
    1 1 1 free \$gptonly{ } \$primary{ } method{ biosgrub } . \
    100 ${BOOT_DISC} ${BOOT_DISC} raid \$lvmignore{ } \$primary{ } method{ raid } . \
    100 4000 4000 raid \$lvmignore{ } \$primary{ } method{ raid } . \
    256 ${SWAP_DISC} ${SWAP_DISC} linux-swap \$defaultignore{ } lv_name{ swap } in_vg{ vg } \$lvmok{ } method{ swap } format{ } . \
    256 ${ROOT_DISC_SIZE} ${ROOT_DISC_SIZE} ${ROOT_FS} \$defaultignore{ } lv_name{ root } in_vg{ vg } \$lvmok{ } method{ format } format{ } use_filesystem{ } filesystem{ ${ROOT_FS} } mountpoint{ / } . \
    1024 1024 1024 ext4 \$defaultignore{ } \$lvmok{ } lv_name{ lv_delete } in_vg{ vg } method{ format } format{ } use_filesystem{ } filesystem{  } ."; \
fi;

#d-i grub-installer/bootdev string /dev/sda /dev/sdb

d-i passwd/root-login boolean true
d-i passwd/make-user boolean false
d-i passwd/root-password password installer
d-i passwd/root-password-again password installer

# This makes partman automatically repartition without confirmation.
d-i partman-md/confirm boolean true
d-i partman-md/confirm_nooverwrite boolean true

d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true

d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-basicfilesystems/no_mount_point yes

## Controlling how partitions are mounted
# The default is to mount by UUID, but you can also choose "traditional" to
# use traditional device names, or "label" to try filesystem labels before
# falling back to UUIDs.
d-i partman/mount_style select label

d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true

#grub-pc grub2/linux_cmdline_default string quiet splash net.ifnames=0 biosdevname=0

d-i pkgsel/include string ssh zsh curl openssh-server mc nano console-data console-setup php7.0-cli

## finish and reboot
d-i finish-install/reboot_in_progress note

d-i preseed/late_command string cat /proc/cmdline|xargs -n 1|grep nt=|sed -r 's/nt=//g' > /target/tmp/cmdline; \
cat /proc/cmdline|xargs -n 1|grep pw=|sed -r 's/pw=//g' > /target/tmp/rootpass; \
cat /proc/cmdline|xargs -n 1|grep server_ip=|sed -r 's/server_ip=//g' > /target/tmp/serverip; \
cat /proc/cmdline|xargs -n 1|grep root_disc=|sed -r 's/root_disc=//g' > /tmp/root_disc; \
cat /proc/cmdline|xargs -n 1|grep hostname=|sed -r 's/hostname=//g' > /target/tmp/hostname; \
cat /proc/cmdline|xargs -n 1|grep domain=|sed -r 's/domain=//g' > /target/tmp/domain; \
cat /proc/cmdline|xargs -n 1|grep raid=|sed -r 's/raid=//g' > /target/tmp/raidmode; \
RAIDMODE=`cat /target/tmp/raidmode`; \
NOTIFY=`tail -n 1 /target/tmp/cmdline`; \
ROOTPASS=`cat /target/tmp/rootpass`; \
SERVERIP=`cat /target/tmp/serverip`; \
ROOT_DISC=`cat /target/tmp/root_disc`; \
HOSTNAME=`cat /target/tmp/hostname`; \
DOMAIN=`cat /target/tmp/domain`; \
sed -i "s/^127.0.1.1.*/${SERVERIP} ${HOSTNAME}.${DOMAIN} ${HOSTNAME}/g" /etc/hosts; \
sed -i "s/^127.0.1.1.*/${SERVERIP} ${HOSTNAME}.${DOMAIN} ${HOSTNAME}/g" /target/etc/hosts; \
sed -i "s/^127.0.0.1.*/127.0.0.1 localhost.localdomain localhost/g" /etc/hosts; \
sed -i "s/^127.0.0.1.*/127.0.0.1 localhost.localdomain localhost/g" /target/etc/hosts; \
echo "${HOSTNAME}.${DOMAIN}" > /target/etc/hostname; \
echo "${HOSTNAME}.${DOMAIN}" > /etc/hostname; \
echo "${HOSTNAME}.${DOMAIN}" > /target/etc/mailname; \
echo "${HOSTNAME}.${DOMAIN}" > /etc/mailname; \
in-target sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config; \
in-target sh -c "echo root:${ROOTPASS} | chpasswd"; \
in-target sh -c "apt-get update && apt-get -y dist-upgrade"; \
sed -i 's/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash net.ifnames=0 biosdevname=0\"/g' /target/etc/default/grub; \
in-target bash -c 'update-grub'; \
if [ "$RAIDMODE" = "Raid1" ]; then \
in-target sh -c "grub-install --recheck --no-floppy ${DISKB}"; \
fi; \
if [ "$RAIDMODE" = "Raid5" ] || [ "$RAIDMODE" = "Raid10" ]; then \
in-target sh -c "grub-install --recheck --no-floppy ${DISKB}"; \
in-target sh -c "grub-install --recheck --no-floppy ${DISKC}"; \
in-target sh -c "grub-install --recheck --no-floppy ${DISKD}"; \
fi; \
if [ "$ROOT_DISC" = "Rest" ]; then \
in-target wget http://admin.ip-projects.de/n.php?${NOTIFY} -O /dev/null;sync; \
else \
lvremove -f /dev/vg/lv_delete > /dev/null 2>&1; \
in-target wget http://admin.ip-projects.de/n.php?${NOTIFY} -O /dev/null;sync; \
fi;
in-target sh -c "echo '### Install Done..' > /var/log/install_done.log"; \
in-target sh -c "echo '### Rebooting..' >> /var/log/install_done.log";

댓글 없음:

댓글 쓰기