linux_dist
Markdown

Part 10 First Boot and Testing

Part 10: First Boot and Post-Installation

Overview

Boot your LFS system for the first time, verify functionality, and perform post-installation tasks.

First Boot Procedure

1. Power On / Reboot

After following Part 9 and unmounting all filesystems:

# From host system
shutdown -r now

Or in a virtual machine, simply reboot.

2. GRUB Boot Menu

You should see:

GNU GRUB version 2.12

GNU/Linux, Linux 6.16.1-lfs-12.4
GNU/Linux, Linux 6.16.1-lfs-12.4 (recovery mode)

Use ↑ and ↓ to select which entry is highlighted.
Press enter to boot the selected OS, 'e' to edit the
commands before booting or 'c' for a command-line.

Press Enter to boot the default entry.

3. Boot Messages

You'll see kernel boot messages scrolling. Watch for:

[    0.000000] Linux version 6.16.1-lfs-12.4
[    0.000000] Command line: root=/dev/sda2 ro
...
[    2.345678] EXT4-fs (sda2): mounted filesystem with ordered data mode
...
[  OK  ] Started Create Volatile Files and Directories
[  OK  ] Started Network Time Synchronization
[  OK  ] Reached target Multi-User System

4. Login Prompt

After boot completes, you'll see:

Linux From Scratch 12.4 lfs tty1

lfs login:

Login as root with the password you set in Part 8.

login: root
Password: [your-password]

Initial System Verification

1. Verify System is Running

# Check kernel version
uname -a
# Should show: Linux lfs 6.16.1-lfs-12.4 ...

# Check distribution
cat /etc/lsb-release
cat /etc/os-release

# Check hostname
hostname
hostnamectl  # (if using systemd)

# Check uptime
uptime

2. Verify Filesystems

# Check mounted filesystems
df -h

# Expected output similar to:
# Filesystem      Size  Used Avail Use% Mounted on
# /dev/sda2        28G  4.2G   22G  16% /
# devtmpfs        485M     0  485M   0% /dev
# tmpfs           493M     0  493M   0% /dev/shm

# Verify fstab
cat /etc/fstab

# Check filesystem integrity
mount | grep "^/dev"

3. Test Network Connectivity

# Check network interfaces
ip addr show
# or
ifconfig -a

# Check if interface is up
ip link show eth0

# Bring up interface if down
ip link set eth0 up

# Test DHCP (if configured)
dhclient eth0  # or
dhcpcd eth0

# Test connectivity
ping -c 4 google.com

# If ping fails, check:
cat /etc/resolv.conf
cat /etc/sysconfig/ifconfig.eth0

4. Test Package Management

# Check GCC
gcc --version

# Check Bash
bash --version

# Check Python
python3 --version

# Test compilation
echo 'int main() { return 0; }' > test.c
gcc test.c -o test
./test
echo $?  # Should output: 0
rm test test.c

5. Verify System Services

For SysVinit:

# Check running init
ps -p 1

# Check runlevel
runlevel
# Should show: N 3 (or N 5)

For Systemd:

# Check systemd status
systemctl status

# List failed services
systemctl --failed

# List enabled services
systemctl list-unit-files --state=enabled

Post-Installation Configuration

1. Create Regular User Account

# Add a regular user (replace 'john' with your username)
useradd -m -G users,wheel,audio,video -s /bin/bash john

# Set user password
passwd john

# Test sudo access (if sudo installed)
su - john
sudo echo "test"
exit

2. Configure Time and Date

# Check current time
date

# Set timezone (if not already set)
ln -sfv /usr/share/zoneinfo/America/New_York /etc/localtime

# For systemd, use timedatectl
timedatectl set-timezone America/New_York
timedatectl set-ntp true

# Verify
timedatectl status

3. Update System Clock from Internet

For SysVinit:

# Install and configure NTP (if available)
# Or manually sync
ntpdate pool.ntp.org

For Systemd:

# Enable time sync
systemctl enable systemd-timesyncd
systemctl start systemd-timesyncd

# Check status
timedatectl status

4. Configure SSH (if needed)

If you built OpenSSH:

# Generate host keys
ssh-keygen -A

# Start SSH daemon
/usr/sbin/sshd

# Or with systemd
systemctl enable sshd
systemctl start sshd

# Check status
systemctl status sshd

5. Set up Firewall (Optional)

If you built iptables:

# Basic firewall rules
cat > /etc/iptables.rules << "EOF"
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -p tcp --dport 22 -j ACCEPT
COMMIT
EOF

# Apply rules
iptables-restore < /etc/iptables.rules

# Save for boot
# Add to /etc/rc.d/init.d/iptables or systemd service

System Testing

1. Reboot Test

# Reboot the system
reboot

# After reboot, verify:
# - System boots successfully
# - Network comes up automatically
# - Services start correctly
# - Time is correct

2. Shutdown Test

# Test clean shutdown
shutdown -h now

# System should:
# - Stop all services gracefully
# - Unmount filesystems properly
# - Power off cleanly

3. Multi-User Test

# Login as regular user
# Verify user environment works
whoami
pwd
ls -la ~

4. Stress Test (Optional)

# CPU test
dd if=/dev/zero of=/dev/null &
# Watch with top, then kill when done
killall dd

# Disk test
dd if=/dev/zero of=/tmp/testfile bs=1M count=1024
rm /tmp/testfile

# Memory test
free -h

Troubleshooting Common Issues

Issue: No Network Connectivity

Solutions:

# Check interface name
ip addr show

# Bring up interface
ip link set eth0 up

# Get DHCP address
dhclient eth0

# Check routes
ip route show

# Add default route manually
ip route add default via 192.168.1.1

# Test DNS
ping 8.8.8.8  # IP works but domain doesn't?
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
ping google.com

Issue: Cannot Login as Root

Solutions:

  1. Reboot into single-user mode:

    • At GRUB menu, press 'e'
    • Add single to kernel line
    • Boot with Ctrl+X
    • Reset password: passwd root
  2. Or add init=/bin/bash to kernel line:

    • Mount root: mount -o remount,rw /
    • Reset password: passwd root
    • Reboot: exec /sbin/init

Issue: Services Won't Start

For SysVinit:

# Check service scripts
ls -l /etc/rc.d/init.d/

# Start manually
/etc/rc.d/init.d/network start

# Check logs
dmesg | tail
tail /var/log/messages

For Systemd:

# Check failed services
systemctl --failed

# Check specific service
systemctl status network.service

# View logs
journalctl -xe
journalctl -u network.service

Issue: Kernel Panic on Boot

Solutions:

  1. Boot with recovery kernel (if you made one)
  2. Check GRUB configuration:
    • Ensure root= points to correct partition
    • Verify partition exists: ls (hd0,2)/ in GRUB
  3. Rebuild initramfs if using one
  4. Check kernel has required drivers compiled in

Beyond LFS: Next Steps

1. Install Additional Software (BLFS)

Beyond Linux From Scratch (BLFS) provides instructions for:

  • X Window System (graphical interface)
  • Desktop environments (GNOME, KDE, XFCE)
  • Web browsers (Firefox, Chromium)
  • Office software (LibreOffice)
  • Media players
  • Development tools

BLFS Website: https://www.linuxfromscratch.org/blfs/

2. Create Automated Package Management

Consider implementing:

  • Package tracking system
  • Build scripts for common software
  • Dependency management
  • Update mechanism

3. System Hardening

  • Configure SELinux or AppArmor
  • Set up firewall rules
  • Enable audit logging
  • Configure automatic security updates

4. Backup Strategy

# Create system backup
tar -czpf /backup/lfs-system-$(date +%Y%m%d).tar.gz \
    --exclude=/proc \
    --exclude=/sys \
    --exclude=/dev \
    --exclude=/tmp \
    --exclude=/backup \
    /

# Create kernel config backup
cp /boot/config-6.16.1 /backup/

# Backup important configs
tar -czf /backup/etc-backup-$(date +%Y%m%d).tar.gz /etc

5. Document Your System

Create documentation for:

  • Installed packages list
  • Custom configurations
  • Kernel configuration choices
  • Network setup
  • User accounts and permissions
# Generate package list
cat > /root/package-list.txt << "EOF"
LFS 12.4 Installed Packages:
- Linux Kernel 6.16.1
- Glibc 2.42
- GCC 15.2.0
- Binutils 2.45
...
EOF

Performance Tuning

1. Optimize Boot Time

# Analyze boot time (systemd)
systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain

# Disable unnecessary services
systemctl disable <service-name>

2. Filesystem Optimization

# Tune ext4 filesystem
tune2fs -l /dev/sda2

# Enable journaling optimizations
tune2fs -O dir_index /dev/sda2

3. Kernel Optimization

Rebuild kernel with optimizations:

  • Enable only needed drivers
  • Compile for specific CPU (CONFIG_MCORE2, etc.)
  • Enable compiler optimizations

Congratulations!

You have successfully built Linux From Scratch 12.4!

What you've accomplished:

  • ✅ Built a complete Linux system from source
  • ✅ Learned how Linux systems work internally
  • ✅ Compiled ~102 packages totaling 900+ MB
  • ✅ Configured system services and network
  • ✅ Installed kernel and bootloader
  • ✅ Created a working, bootable operating system

Final Checklist

  • System boots successfully
  • Root login works
  • Network is configured and working
  • Time and timezone are correct
  • Regular user account created
  • System services are running
  • Filesystem is clean and organized
  • Backup created
  • Documentation written

Resources

Share Your Success!

Consider sharing your experience:

  • LFS mailing list
  • Online forums
  • Social media with #LinuxFromScratch
  • Blog about your journey

Enjoy your custom-built Linux system! 🎉🐧