範例:
安裝目標 sda3
分割區標籤 FSYS
系統版本 27
# Install Fedora
TARGET=sda3
LABEL=FSYS
OSVER=27
RUN_IN_CHROOT="chroot /mnt /bin/bash -c"
USERNAME="fedora"
TIMEZONE=Asia/Taipei
HOSTNAME="localhosts"
SET_LANG=zh_TW
PASSWD="0000"
# Format
mkfs.ext4 -F /dev/$TARGET
# Add Label
e2label /dev/$TARGET $LABEL
# Mount Target
mount /dev/$TARGET /mnt
# Install Base System
dnf -y --releasever=$OSVER --installroot=/mnt install @core @standard
echo 'nameserver 192.168.1.1' > /mnt/etc/resolv.conf
mount --bind /dev /mnt/dev
mount --bind /run /mnt/run
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
# Install genfstab
if [ ! -f "/usr/local/bin/genfstab" ]; then
wget https://github.com/Mint-Fans/linux-package/raw/master/genfstab
cp genfstab /usr/local/bin/
chmod 755 /usr/local/bin/genfstab
fi
cp /usr/local/bin/genfstab /mnt/usr/local/bin/
chmod 755 /mnt/usr/local/bin/genfstab
# Install rpmfusion repos
$RUN_IN_CHROOT "dnf -y install http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-"$OSVER".noarch.rpm"
# Install All System Packages
KERNEL='kernel kernel-devel kernel-modules-extra'
FIRMWARE='atmel-firmware b43-fwcutter b43-openfwwf ipw2100-firmware ipw2200-firmware iwl100-firmware iwl1000-firmware iwl105-firmware iwl135-firmware iwl2000-firmware iwl2030-firmware iwl3160-firmware iwl3945-firmware iwl4965-firmware iwl5000-firmware iwl5150-firmware iwl6000-firmware iwl6000g2a-firmware iwl6000g2b-firmware iwl6050-firmware iwl7260-firmware libertas-usb8388-firmware usb_modeswitch zd1211-firmware'
GRUB='grub2-tools efibootmgr os-prober grub2-pc grub2-tools-efi grub2-efi-x64-modules'
XORG='xorg-x11-drv-ati xorg-x11-drv-evdev xorg-x11-drv-fbdev xorg-x11-drv-intel xorg-x11-drv-libinput xorg-x11-drv-nouveau xorg-x11-drv-openchrome xorg-x11-drv-qxl xorg-x11-drv-vesa xorg-x11-drv-vmware xorg-x11-drv-wacom xorg-x11-font-utils xorg-x11-fonts-ISO8859-1-100dpi.noarch xorg-x11-resutils xorg-x11-server-Xorg xorg-x11-server-common xorg-x11-server-utils xorg-x11-utils xorg-x11-xauth xorg-x11-xinit xorg-x11-xkb-utils'
NETWORK='dhcp-client dnsmasq iptables network-manager-applet nm-connection-editor ModemManager NetworkManager NetworkManager-adsl NetworkManager-bluetooth NetworkManager-fortisslvpn NetworkManager-fortisslvpn-gnome NetworkManager-glib NetworkManager-iodine NetworkManager-iodine-gnome NetworkManager-l2tp NetworkManager-l2tp-gnome NetworkManager-libnm NetworkManager-libreswan NetworkManager-libreswan-gnome NetworkManager-openconnect NetworkManager-openconnect-gnome NetworkManager-openvpn NetworkManager-openvpn-gnome NetworkManager-pptp NetworkManager-pptp-gnome NetworkManager-ssh NetworkManager-ssh-gnome NetworkManager-sstp NetworkManager-sstp-gnome NetworkManager-strongswan NetworkManager-strongswan-gnome NetworkManager-team NetworkManager-vpnc NetworkManager-vpnc-gnome NetworkManager-wifi NetworkManager-wwan'
SYSUTIL="rpm-build gvfs lvm2 keybinder hostapd xterm aircrack-ng macchanger reaver busybox zenity xbacklight squashfs-tools git subversion inxi genisoimage xorriso pcsc-tools pcsc-perl"
COMPRESS='xz-lzma-compat arj lzip ncompress sharutils p7zip-plugins'
XFCE='xfce-polkit xfce4-about xfce4-appfinder xfce4-battery-plugin xfce4-clipman-plugin xfce4-cpugraph-plugin xfce4-datetime-plugin xfce4-dict xfce4-dict-plugin xfce4-diskperf-plugin xfce4-eyes-plugin xfce4-fsguard-plugin xfce4-genmon-plugin xfce4-mailwatch-plugin xfce4-mount-plugin xfce4-netload-plugin xfce4-notifyd xfce4-panel xfce4-places-plugin xfce4-power-manager xfce4-pulseaudio-plugin xfce4-screenshooter xfce4-screenshooter-plugin xfce4-session xfce4-session-engines xfce4-settings xfce4-systemload-plugin xfce4-taskmanager xfce4-terminal xfce4-time-out-plugin xfce4-verve-plugin xfce4-weather-plugin xfce4-whiskermenu-plugin xfce4-xkb-plugin tumbler tumbler-extras Thunar thunar-volman thunar-media-tags-plugin thunar-archive-plugin xfconf xfdesktop xfsprogs xfwm4'
FONTS='dejavu-sans-fonts dejavu-sans-mono-fonts dejavu-lgc-serif-fonts wqy-microhei-fonts google-noto-sans-fonts google-droid-sans-fonts liberation-fonts'
XDG='xdg-user-dirs-gtk'
DM='lightdm lightdm-gtk'
AUDIO='alsa-utils alsa-plugins-pulseaudio alsa-ucm pulseaudio-module-bluetooth'
QT="qt5-qtbase-gui qt-at-spi"
THEMES='fedora-logos plymouth-system-theme gnome-icon-theme gtk-murrine-engine'
BASEAPP='firefox leafpad gparted vlc gucharmap gnome-calculator gnome-font-viewer thunderbird brasero catfish gimp'
MEDIA='PackageKit-gstreamer-plugin gstreamer1-plugins-base gstreamer1-plugins-bad-free gstreamer1-plugins-good gstreamer1-plugins-ugly-free gstreamer1-libav'
XAPP='pix xplayer xreader xviewer xviewer-plugins'
IME='fcitx fcitx-configtool fcitx-gtk2 fcitx-gtk3 fcitx-chewing fcitx-anthy'
PROXY='tor proxychains-ng'
$RUN_IN_CHROOT "dnf -y install $KERNEL $FIRMWARE $GRUB $XORG $NETWORK $SYSUTIL $COMPRESS $XFCE $FONTS $XDG $DM $AUDIO $QT $THEMES $BASEAPP $MEDIA $XAPP $IME $PROXY"
# Config System
echo $HOSTNAME > /mnt/etc/hostname
$RUN_IN_CHROOT "ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime"
$RUN_IN_CHROOT "hwclock --systohc --localtime"
echo 'LANG="SET_LANG.UTF-8"' > /mnt/etc/locale.conf
sed -i s/SET_LANG/$SET_LANG/g /mnt/etc/locale.conf
$RUN_IN_CHROOT "localectl set-locale LANG=$SET_LANG"
$RUN_IN_CHROOT "localectl set-x11-keymap us"
$RUN_IN_CHROOT "adduser $USERNAME"
echo $USERNAME:$PASSWD > /mnt/pw.txt
echo root:$PASSWD >> /mnt/pw.txt
$RUN_IN_CHROOT "chpasswd < /pw.txt"
rm -f /mnt/pw.txt
echo 'UPDATEDEFAULT=yes' > /mnt/etc/sysconfig/kernel
echo 'DEFAULTKERNEL=kernel-core' >> /mnt/etc/sysconfig/kernel
# configure relabel on first boot
touch /mnt/.autorelabel
# Initialization
$RUN_IN_CHROOT "authconfig --updateall"
# Install Customize Packages
$RUN_IN_CHROOT "dnf -y install https://github.com/Mint-Fans/linux-package/raw/fedora/engrampa-1.19.1-1.fc27.x86_64.rpm"
$RUN_IN_CHROOT "dnf -y install https://github.com/Mint-Fans/linux-package/raw/fedora/pa-applet-17.33-1.fc27.x86_64.rpm"
$RUN_IN_CHROOT "dnf -y install https://github.com/Mint-Fans/linux-package/raw/fedora/xfce4-volumed-pulse-0.2.0-1.fc27.x86_64.rpm"
$RUN_IN_CHROOT "dnf -y install https://github.com/Mint-Fans/linux-package/raw/fedora/gnome-theme-mint-2018-2.fc27.noarch.rpm"
$RUN_IN_CHROOT "dnf -y install https://github.com/Mint-Fans/linux-package/raw/fedora/create-ap-0.2-5.fc27.noarch.rpm"
$RUN_IN_CHROOT "dnf -y install https://github.com/Mint-Fans/linux-package/raw/fedora/aircrack-ng-cli-1.2-2.fc27.noarch.rpm"
$RUN_IN_CHROOT "dnf -y install https://github.com/Mint-Fans/linux-package/raw/fedora/fedora-adjust-xfce-2018-1.fc27.noarch.rpm"
# Generate initramfs
chroot /mnt /bin/bash <<'ENDCHROOT'
KERNELVRA=$(rpm -q kernel --qf %{V}-%{R}.%{ARCH})
dracut --kver $KERNELVRA --force -v
ENDCHROOT
# Install Grub2
DISK=$(lsblk | grep /mnt$ | sed 's/.*sd/sd/g' | awk '{print $1}' | sed s/[0-9]//g)
# BIOS
$RUN_IN_CHROOT "grub2-install /dev/$DISK"
# EFI
rm -rf /mnt/boot/efi
mkdir -p /mnt/boot/efi
mount /dev/"$DISK"1 /mnt/boot/efi
$RUN_IN_CHROOT "grub2-install --target=x86_64-efi /dev/$DISK"
mkdir -p /mnt/boot/efi/EFI/boot
cp /mnt/boot/efi/EFI/*/grubx64.efi /mnt/boot/efi/EFI/boot/bootx64.efi
# Config Grub2
$RUN_IN_CHROOT "grub2-mkconfig -o /boot/grub2/grub.cfg"
# Rebuild fstab
/usr/local/bin/genfstab -U /mnt > /mnt/etc/fstab
# Clean Cache
$RUN_IN_CHROOT "dnf clean all"
$RUN_IN_CHROOT "dnf autoremove"
rm -rf /mnt/var/cache/dnf/*
# umount & exit
umount /mnt/run
umount /mnt/dev
umount /mnt/proc
umount /mnt/sys
umount -l /mnt
完成圖