Mục Tiêu Chương 9
Tải ISO Linux
Tải Fedora Workstation/Server và RHEL từ nguồn chính thức. Verify checksum SHA256 để xác minh tính toàn vẹn.
Tạo Boot Media
Tạo USB bootable với dd hoặc Rufus. Boot từ USB, DVD, hoặc PXE network boot cho môi trường doanh nghiệp.
Anaconda Installer
Điều hướng GUI installer Anaconda: chọn ngôn ngữ, timezone, keyboard, network, và software selection.
Phân vùng ổ đĩa
Hiểu partition layout: /boot, /boot/efi, swap, / (root), /home. Dùng LVM, standard partition, hoặc Btrfs subvolumes.
Filesystem Types
So sánh ext4 (stable), xfs (scalable, default RHEL), btrfs (snapshots, compression). Biết khi nào dùng loại nào.
Kickstart Automation
Cài đặt tự động không cần tương tác với file Kickstart. Dùng cho deployment hàng loạt trong doanh nghiệp.
Lý Thuyết: Cài đặt Linux
1. Tải và Verify ISO
# Tải Fedora Workstation (ví dụ):
$ wget https://download.fedoraproject.org/pub/fedora/linux/releases/41/Workstation/x86_64/iso/Fedora-Workstation-Live-41.iso
# Verify SHA256 checksum:
$ sha256sum Fedora-Workstation-Live-41.iso
abc123... Fedora-Workstation-Live-41.iso
# So sánh với checksum từ trang web chính thức
# Tạo USB bootable với dd:
$ sudo dd if=Fedora-Workstation-Live-41.iso of=/dev/sdb bs=4M status=progress oflag=sync
# CẢNH BÁO: Thay /dev/sdb bằng đúng device USB của bạn!
2. Anaconda Installer – Các bước cài đặt
Anaconda là GUI installer của Fedora/RHEL. Sau khi boot từ USB, bạn sẽ thấy GRUB menu → chọn "Install Fedora" → giao diện Anaconda.
Các màn hình cấu hình trong Anaconda:
Language Selection
Chọn ngôn ngữ hiển thị và ngôn ngữ hệ thống (English US được khuyến nghị cho server)
Date & Time
Chọn timezone (Asia/Ho_Chi_Minh), bật NTP để đồng bộ thời gian tự động
Software Selection
Server với GUI, Minimal Install, Workstation, Custom. Minimal cho VM/container host
Installation Destination
Chọn ổ đĩa và cấu hình phân vùng (tự động hoặc thủ công)
Network & Hostname
Đặt hostname, cấu hình network interface (DHCP hoặc static IP)
Root Password & User
Set root password (hoặc lock root), tạo user đầu tiên với quyền admin (wheel)
3. Phân vùng ổ đĩa – Partition Layout
Cấu hình phân vùng tốt đảm bảo hiệu suất, bảo mật và dễ quản lý. Khuyến nghị cho server production:
| Mount Point | Kích thước đề xuất | Filesystem | Mục đích |
|---|---|---|---|
| /boot/efi | 600 MB | FAT32 (vfat) | UEFI bootloader files |
| /boot | 1 GB | ext4 hoặc xfs | Kernel và initrd images |
| swap | = RAM (max 8GB) | swap | Virtual memory, hibernation |
| / | 20-50 GB | xfs (RHEL default) | Root filesystem, OS files |
| /home | Phần còn lại | xfs hoặc ext4 | User data, dễ backup riêng |
4. Filesystem Types: ext4, xfs, btrfs
ext4
- ✓ Rất ổn định, battle-tested
- ✓ Hỗ trợ rộng rãi
- ✓ Max file: 16 TB
- ✓ Max volume: 1 EB
- ✗ Không có checksums
- ✗ Ít tính năng nâng cao
- Dùng cho: /boot, desktop
xfs
- ✓ Tốt với file lớn
- ✓ Hiệu suất cao (parallel I/O)
- ✓ Max file: 8 EB
- ✓ Default RHEL/Fedora
- ✗ Không shrink volume
- ✗ Không có snapshots tích hợp
- Dùng cho: / và /home server
btrfs
- ✓ Snapshots tích hợp
- ✓ Compression (zstd)
- ✓ Checksums tự động
- ✓ Subvolumes linh hoạt
- ✗ Phức tạp hơn
- ✗ RAID5/6 không ổn định
- Dùng cho: Fedora desktop (default)
Kickstart – Cài đặt Tự động
5. Kickstart File Format
Kickstart cho phép cài đặt Linux hoàn toàn tự động, không cần tương tác. File Kickstart được trỏ đến qua boot parameter inst.ks=.
# Installation method
text
url --url="https://mirror.fedoraproject.org/fedora/linux/releases/41/Everything/x86_64/os/"
# System settings
lang en_US.UTF-8
keyboard us
timezone Asia/Ho_Chi_Minh --utc
# Network
network --bootproto=dhcp --device=eth0 --onboot=yes --hostname=myserver
# Security
rootpw --iscrypted $6$rounds=500000$hashed_password_here
selinux --enforcing
firewall --enabled --ssh
# Disk partitioning
zerombr
clearpart --all --initlabel
part /boot --fstype=xfs --size=1024
part /boot/efi --fstype=efi --size=600
part swap --size=4096
part / --fstype=xfs --size=20480 --grow
# Software packages
%packages
@^minimal-environment
openssh-server
vim-enhanced
%end
# Post-install scripts
%post
useradd -m -G wheel admin
echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/admin
systemctl enable sshd
%end
reboot
6. Post-installation Steps
# 1. Update hệ thống ngay sau cài đặt:
$ sudo dnf update -y
# 2. Kiểm tra SELinux status:
$ sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
Current mode: enforcing
# 3. Cấu hình firewall:
$ sudo systemctl status firewalld
$ sudo firewall-cmd --list-all
# 4. Kiểm tra networking:
$ ip addr show
$ ip route
# 5. Check disk usage:
$ df -h
$ lsblk
Lab Thực Hành – Chapter 9
Tải và Verify ISO Fedora
$ curl -LO https://download.fedoraproject.org/pub/fedora/linux/releases/41/Server/x86_64/iso/Fedora-Server-dvd-x86_64-41-1.6.iso
$ sha256sum Fedora-Server-dvd-x86_64-41-1.6.iso
abc123def456... Fedora-Server-dvd-x86_64-41-1.6.iso
# So sánh với giá trị trên trang download chính thức
$ file Fedora-Server-dvd-x86_64-41-1.6.iso
Fedora-Server-dvd-x86_64-41-1.6.iso: ISO 9660 CD-ROM filesystem
Tạo USB Bootable
# Xác định device USB:
$ lsblk
sdb 8:16 1 14.9G 0 disk # USB drive
# Tạo USB bootable (CẢNH BÁO: xóa hết dữ liệu USB):
$ sudo dd if=Fedora-Server-dvd-x86_64-41-1.6.iso \
of=/dev/sdb bs=4M status=progress oflag=sync
1073741824 bytes (1.1 GB) copied, 45.3 s, 23.7 MB/s
$ sync
# Đảm bảo dữ liệu đã được flush sang USB
Kiểm tra Partition và Filesystem (Post-install)
$ lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINTS
sda
├─sda1 vfat F2A4-... /boot/efi
├─sda2 xfs abc1-... /boot
└─sda3 LVM2_member
├─rl-root xfs /
├─rl-swap swap [SWAP]
└─rl-home xfs /home
$ cat /etc/fstab
UUID=abc1-... /boot xfs defaults 0 0
UUID=def2-... / xfs defaults 0 0
Tạo Kickstart file đơn giản
# Sau khi cài bằng Anaconda, file ks.cfg được lưu tại:
$ ls /root/anaconda-ks.cfg
/root/anaconda-ks.cfg
$ cat /root/anaconda-ks.cfg
# Đây là file Kickstart được tạo tự động từ lần cài trước
# Validate kickstart file:
$ sudo dnf install pykickstart -y
$ ksvalidator /root/anaconda-ks.cfg
No errors found in kickstart file.
Post-install Configuration Checklist
$ sudo dnf update -y && sudo dnf autoremove -y
$ sudo hostnamectl set-hostname myserver.example.com
$ timedatectl set-timezone Asia/Ho_Chi_Minh
$ timedatectl set-ntp true
$ sudo systemctl enable --now sshd firewalld
$ sudo firewall-cmd --permanent --add-service=ssh && sudo firewall-cmd --reload
$ cat /etc/os-release
NAME="Fedora Linux" VERSION="41 (Server Edition)"
Cài Linux trong VirtualBox/VMware
Quy trình tạo VM để thực hành cài đặt Linux:
- 1Tạo VM mới: New → Linux → Fedora (64-bit), RAM ≥ 2GB, Disk ≥ 20GB
- 2Settings → Storage → Mount ISO file vào CD/DVD drive
- 3Start VM → Boot từ ISO → GRUB menu → "Install Fedora"
- 4Anaconda: chọn Language → configure Timezone → Software → Disk
- 5Disk Configuration: dùng "Automatic" hoặc "Custom" để tạo partitions
- 6Begin Installation → Set root password → Create user → Wait → Reboot
Câu Hỏi Ôn Tập – Chapter 9
Anaconda là gì và nó được dùng ở đâu?
Tại sao cần verify SHA256 checksum của file ISO?
sha256sum file.iso và so sánh với giá trị trên trang official.Sự khác nhau giữa ext4 và xfs? RHEL dùng mặc định loại nào và tại sao?
Kickstart file là gì? Dùng khi nào?
inst.ks=http://server/ks.cfg hoặc từ USB: inst.ks=hd:sdb1:/ks.cfg.Tại sao cần phân vùng /boot riêng không đặt trong LVM?
Lệnh dd dùng để tạo USB bootable như thế nào? Nguy hiểm nào cần tránh?
sudo dd if=linux.iso of=/dev/sdX bs=4M status=progress oflag=sync. Nguy hiểm chính: chỉ định sai device sẽ xóa dữ liệu ổ đĩa hệ thống! Kiểm tra kỹ /dev/sdX bằng lsblk trước. Không có dấu số (sdb không phải sdb1). oflag=sync đảm bảo dữ liệu flush xuống USB trước khi kết thúc. Ngoài dd có thể dùng Balena Etcher (GUI, an toàn hơn).Sau khi cài Linux xong, 3 bước quan trọng nhất cần làm ngay là gì?
sudo dnf update -y: cập nhật toàn bộ packages để vá security vulnerabilities. 2. Cấu hình firewall: sudo firewall-cmd --list-all, chỉ mở ports cần thiết. 3. Tạo user admin với sudo và disable/limit root login trực tiếp. Ngoài ra: set timezone, hostname, enable SSH key authentication, tắt password auth nếu có thể.btrfs có ưu điểm gì so với ext4 và xfs mà Fedora chọn làm mặc định?