使用dnf 從頭安裝 Fedora 系統 [論壇 - Ubuntu 哈啦]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊



使用dnf 從頭安裝 Fedora 系統
會員二級
註冊日期:
2017/3/23 10:15
所屬群組:
已註冊使用者
等級: 4
HP : 0 / 87
MP : 11 / 339
EXP: 50
離線
#######################################
### 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 install --disablerepo=* --enablerepo=fedora $KERNEL $FIRMWARE"
$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



完成圖:



3/6 13:26:24
應用擴展 工具箱
回覆: 使用dnf 從頭安裝 Fedora 系統
會員三級
註冊日期:
2016/4/18 12:29
所屬群組:
已註冊使用者
等級: 9
HP : 0 / 206
MP : 35 / 1360
EXP: 25
離線
hi,
不太懂dnf,但看到您的安裝方式,想跟您請教一下

我在網路上尋結果,dnf因該類似apt-get的工具,請問ubuntu也可以用apt-get裝嗎?

從您的步驟來看,您會先安裝所謂的Base System
這個Base是否等於kernel + FHS + fedora desktop的總和?
其中
echo 'nameserver 192.168.1.1' > /mnt/etc/resolv.conf

這行指令看起來是將nameserver 寫入到指定的resolv.conf,可是您寫入的是內網區段,請問這個用意是?
修改interface為dhcp不可行嗎?

一些初淺的問題,希望多多指教
謝謝

3/7 12:25:39
應用擴展 工具箱
回覆: 使用dnf 從頭安裝 Fedora 系統
會員二級
註冊日期:
2017/3/23 10:15
所屬群組:
已註冊使用者
等級: 4
HP : 0 / 87
MP : 11 / 339
EXP: 50
離線
ubuntu_net2016 寫到:
hi,
不太懂dnf,但看到您的安裝方式,想跟您請教一下

我在網路上尋結果,dnf因該類似apt-get的工具,請問ubuntu也可以用apt-get裝嗎?

從您的步驟來看,您會先安裝所謂的Base System
這個Base是否等於kernel + FHS + fedora desktop的總和?
其中
echo 'nameserver 192.168.1.1' > /mnt/etc/resolv.conf

這行指令看起來是將nameserver 寫入到指定的resolv.conf,可是您寫入的是內網區段,請問這個用意是?
修改interface為dhcp不可行嗎?

一些初淺的問題,希望多多指教
謝謝


可以阿,用 debootstrap 安裝 Base System,然後再 chroot 用 apt 安裝套件

Unix 系統大都可以這樣, 只是 Linux 或 BSD 系的很多發行板都幫你安裝好了。但是有些發行版預裝的套件可能不是你想要的,這就需要從頭裝起
其實在 Mac OS X 底下也可以這樣玩,只是沒有現成的套件,很多要自己編譯。

眾多類Unix系統其實都大同小異

3/8 10:04:28
應用擴展 工具箱


 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.