컀λ κ΄λ¦¬
컀λ κ΄λ¦¬¶
νμ΅ λͺ©ν¶
μ΄ λ¬Έμλ₯Ό ν΅ν΄ λ€μμ νμ΅ν©λλ€:
- Linux 컀λ ꡬ쑰μ λ²μ κ΄λ¦¬
- 컀λ λͺ¨λ κ΄λ¦¬ (λ‘λ, μΈλ‘λ, μ€μ )
- 컀λ μ»΄νμΌκ³Ό μ€μΉ
- GRUB λΆνΈλ‘λ μ€μ
λμ΄λ: ββββ (κ³ κΈ)
λͺ©μ°¨¶
- 컀λ κ°μ
- 컀λ λ²μ κ΄λ¦¬
- 컀λ λͺ¨λ
- DKMS
- 컀λ μ»΄νμΌ
- GRUB λΆνΈλ‘λ
- 컀λ νλΌλ―Έν°
1. 컀λ κ°μ¶
컀λμ μν ¶
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β μ¬μ©μ κ³΅κ° β
β βββββββββββ βββββββββββ βββββββββββ βββββββββββ β
β β μ ν리μΌμ΄μ
β β μ β β μλΉμ€ β β GUI β β
β ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ β
β β β β β β
βββββββββ΄βββββββββββββ΄βββββββββββββ΄βββββββββββββ΄βββββββββββββββ€
β μμ€ν
νΈμΆ μΈν°νμ΄μ€ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 컀λ κ³΅κ° β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β νλ‘μΈμ€ κ΄λ¦¬ β λ©λͺ¨λ¦¬ κ΄λ¦¬ β νμΌμμ€ν
β λ€νΈμν¬ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β λλ°μ΄μ€ λλΌμ΄λ² (λͺ¨λ) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β νλμ¨μ΄ β
β CPU β λ©λͺ¨λ¦¬ β λμ€ν¬ β λ€νΈμν¬ μΉ΄λ β κΈ°ν μ₯μΉ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
컀λ κ΅¬μ± μμ¶
| κ΅¬μ± μμ | μν |
|---|---|
| νλ‘μΈμ€ κ΄λ¦¬ | νλ‘μΈμ€ μμ±, μ€μΌμ€λ§, μ’ λ£ |
| λ©λͺ¨λ¦¬ κ΄λ¦¬ | κ°μ λ©λͺ¨λ¦¬, νμ΄μ§, μΊμ± |
| νμΌμμ€ν | VFS, ext4, XFS, NFS λ± |
| λ€νΈμνΉ | TCP/IP μ€ν, μμΌ, λΌμ°ν |
| λλ°μ΄μ€ λλΌμ΄λ² | νλμ¨μ΄ μΆμν, λͺ¨λ |
| μμ€ν νΈμΆ | μ¬μ©μ 곡κ°κ³Ό 컀λ μΈν°νμ΄μ€ |
2. 컀λ λ²μ κ΄λ¦¬¶
νμ¬ μ»€λ μ 보¶
# 컀λ λ²μ νμΈ
uname -r
# μ: 5.15.0-91-generic
# μμΈ μ 보
uname -a
# Linux hostname 5.15.0-91-generic #101-Ubuntu SMP x86_64 GNU/Linux
# 컀λ μ€μ μ 보
cat /proc/version
# 컀λ λΉλ μ€μ (μ€μ μΌλ‘ μ»΄νμΌλ κ²½μ°)
cat /boot/config-$(uname -r) | head -20
컀λ λ²μ 체곶
5.15.0-91-generic
β β β β βββββββββ λ°°ν¬ν νΉμ μ΄λ¦
β β β βββββββββββ ABI λ²μ (λ°°ν¬ν ν¨μΉ)
β β βββββββββββββ ν¨μΉ λ 벨
β ββββββββββββββββ λ§μ΄λ λ²μ
ββββββββββββββββββ λ©μ΄μ λ²μ
μ€μΉλ 컀λ λͺ©λ‘¶
# Ubuntu/Debian
dpkg --list | grep linux-image
# RHEL/CentOS
rpm -qa | grep kernel
# λλ /boot νμΈ
ls -la /boot/vmlinuz-*
컀λ μ λ°μ΄νΈ¶
# Ubuntu/Debian
sudo apt update
sudo apt upgrade linux-image-generic
# νΉμ λ²μ μ€μΉ
sudo apt install linux-image-5.15.0-92-generic
# RHEL/CentOS
sudo yum update kernel
# νΉμ λ²μ μ€μΉ
sudo yum install kernel-5.14.0-362.el9
μ΄μ 컀λ μ κ±°¶
# Ubuntu - μλ μ κ±°
sudo apt autoremove
# Ubuntu - νΉμ λ²μ μ κ±°
sudo apt remove linux-image-5.15.0-88-generic
# νμ¬ μ»€λ μ μΈνκ³ μ΄μ 컀λ μ κ±°
sudo apt purge $(dpkg --list | grep -E 'linux-(image|headers|modules)' | \
grep -v $(uname -r | sed 's/-generic//') | awk '{print $2}')
# RHEL/CentOS - μ€λλ 컀λ μ κ±° (2κ° μ μ§)
sudo dnf remove $(dnf repoquery --installonly --latest-limit=-2 -q)
3. 컀λ λͺ¨λ¶
λͺ¨λ μ 보 νμΈ¶
# λ‘λλ λͺ¨λ λͺ©λ‘
lsmod
# νΉμ λͺ¨λ μ 보
modinfo ext4
modinfo nvidia
# λͺ¨λ μμ‘΄μ± νμΈ
modprobe --show-depends ext4
# λͺ¨λ νμΌ μμΉ
ls /lib/modules/$(uname -r)/kernel/
λͺ¨λ λ‘λ/μΈλ‘λ¶
# λͺ¨λ λ‘λ
sudo modprobe nouveau
sudo modprobe snd-hda-intel
# λͺ¨λ μΈλ‘λ
sudo modprobe -r nouveau
sudo rmmod nouveau
# κ°μ μΈλ‘λ (μν)
sudo rmmod -f nouveau
# μμ‘΄μ± ν¬ν¨ λ‘λ
sudo modprobe -v nvidia
λͺ¨λ νλΌλ―Έν°¶
# λͺ¨λ νλΌλ―Έν° νμΈ
modinfo -p e1000e
# νμ¬ μ μ©λ νλΌλ―Έν°
cat /sys/module/e1000e/parameters/IntMode
# νλΌλ―Έν°μ ν¨κ» λ‘λ
sudo modprobe e1000e IntMode=2
# /etc/modprobe.d/ μ€μ νμΌ
echo "options e1000e IntMode=2" | sudo tee /etc/modprobe.d/e1000e.conf
λͺ¨λ μλ λ‘λ μ€μ ¶
# λΆν
μ μλ λ‘λ
echo "vhost_net" | sudo tee /etc/modules-load.d/vhost_net.conf
# λͺ¨λ λΈλ리μ€νΈ (λ‘λ λ°©μ§)
echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
echo "options nouveau modeset=0" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
# initramfs μ¬μμ± νμ
sudo update-initramfs -u # Ubuntu/Debian
sudo dracut -f # RHEL/CentOS
λͺ¨λ λ³μΉ¶
# λ³μΉ νμΈ
modprobe --show-depends -a pci:v00008086d00001502sv*sd*bc*sc*i*
# νλμ¨μ΄ IDλ‘ λͺ¨λ μ°ΎκΈ°
lspci -nn # PCI μ₯μΉμ ID νμΈ
lspci -k # μ¬μ© μ€μΈ λͺ¨λ νμΈ
# USB μ₯μΉ
lsusb
lsusb -t # νΈλ¦¬ νν
4. DKMS¶
DKMS κ°μ¶
DKMS (Dynamic Kernel Module Support)λ 컀λ μ λ°μ΄νΈ μ μΈλΆ λͺ¨λμ μλμΌλ‘ μ¬λΉλν©λλ€.
# DKMS μ€μΉ
sudo apt install dkms # Ubuntu/Debian
sudo yum install dkms # RHEL/CentOS
DKMS μν νμΈ¶
# λ±λ‘λ λͺ¨λ λͺ©λ‘
dkms status
# μμ μΆλ ₯:
# nvidia/535.154.05, 5.15.0-91-generic, x86_64: installed
# nvidia/535.154.05, 5.15.0-92-generic, x86_64: installed
# virtualbox/7.0.12_Ubuntu, 5.15.0-91-generic, x86_64: installed
DKMS λͺ¨λ κ΄λ¦¬¶
# λͺ¨λ μΆκ°
sudo dkms add -m module-name -v version
# λͺ¨λ λΉλ
sudo dkms build -m module-name -v version
# λͺ¨λ μ€μΉ
sudo dkms install -m module-name -v version
# λͺ¨λ μ κ±°
sudo dkms remove -m module-name -v version --all
# λͺ¨λ 컀λμ λν΄ μ¬λΉλ
sudo dkms autoinstall
DKMS λͺ¨λ μμ± μμ¶
# λͺ¨λ λλ ν 리 ꡬ쑰
/usr/src/mymodule-1.0/
βββ dkms.conf
βββ Makefile
βββ mymodule.c
# dkms.conf μμ
PACKAGE_NAME="mymodule"
PACKAGE_VERSION="1.0"
BUILT_MODULE_NAME[0]="mymodule"
DEST_MODULE_LOCATION[0]="/kernel/drivers/misc"
AUTOINSTALL="yes"
# Makefile μμ
obj-m := mymodule.o
KVERSION := $(shell uname -r)
KDIR := /lib/modules/$(KVERSION)/build
all:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
# DKMSμ λ±λ‘
sudo dkms add -m mymodule -v 1.0
sudo dkms build -m mymodule -v 1.0
sudo dkms install -m mymodule -v 1.0
5. 컀λ μ»΄νμΌ¶
μμ€ λ€μ΄λ‘λ¶
# kernel.orgμμ λ€μ΄λ‘λ
cd /usr/src
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.7.tar.xz
tar -xvf linux-6.7.tar.xz
cd linux-6.7
# λλ gitμΌλ‘
git clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
cd linux
git checkout v6.7
λΉλ μμ‘΄μ± μ€μΉ¶
# Ubuntu/Debian
sudo apt install build-essential libncurses-dev bison flex \
libssl-dev libelf-dev bc dwarves
# RHEL/CentOS
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-devel bison flex elfutils-libelf-devel \
openssl-devel bc dwarves
컀λ μ€μ ¶
# νμ¬ μ»€λ μ€μ 볡μ¬
cp /boot/config-$(uname -r) .config
# λ©λ΄ κΈ°λ° μ€μ
make menuconfig
# λλ κ·Έλν½ μ€μ (X11 νμ)
make xconfig
# λλ ν
μ€νΈ μ§μ λ°©μ
make config
# κΈ°μ‘΄ μ€μ κΈ°λ°μΌλ‘ μ μ΅μ
λ§ μ§μ
make oldconfig
# κΈ°λ³Έκ°μΌλ‘ μ μ΅μ
μ€μ
make olddefconfig
μ£Όμ μ€μ μ΅μ ¶
General setup --->
Local version - append to kernel release: -custom
[*] Automatically append version information
Processor type and features --->
Processor family (Core 2/newer Xeon) --->
[*] Symmetric multi-processing support
Device Drivers --->
[M] Network device support --->
[M] SCSI device support --->
File systems --->
<*> Ext4 POSIX Access Control Lists
<M> XFS filesystem support
<M> Btrfs filesystem support
μ»΄νμΌ λ° μ€μΉ¶
# μ»΄νμΌ (λ³λ ¬ λΉλ)
make -j$(nproc)
# λͺ¨λ μ»΄νμΌ
make modules
# λͺ¨λ μ€μΉ
sudo make modules_install
# 컀λ μ€μΉ
sudo make install
# initramfs μμ± (μλμΌλ‘ λμ§ μμ κ²½μ°)
sudo update-initramfs -c -k 6.7.0-custom
# GRUB μ
λ°μ΄νΈ
sudo update-grub
λΉ λ₯Έ ν μ€νΈ λΉλ¶
# μ΅μ μ€μ μΌλ‘ μμ
make tinyconfig
# λλ νμ¬ νλμ¨μ΄μ λ§λ μ΅μ μ€μ
make localmodconfig
# λΉλ
make -j$(nproc)
6. GRUB λΆνΈλ‘λ¶
GRUB μ€μ νμΌ¶
# λ©μΈ μ€μ (μμ νμ§ μμ)
/boot/grub/grub.cfg
# μ¬μ©μ μ€μ (μ΄κ²μ μμ )
/etc/default/grub
# 컀μ€ν
μ€ν¬λ¦½νΈ
/etc/grub.d/
/etc/default/grub μ€μ ¶
# /etc/default/grub
# κΈ°λ³Έ λΆν
νλͺ© (0λΆν° μμ, λλ "saved")
GRUB_DEFAULT=0
# λ©λ΄ νμ μκ° (μ΄)
GRUB_TIMEOUT=5
# λ©λ΄ μ¨κΉ (λΆν
λΉ λ₯΄κ²)
GRUB_TIMEOUT_STYLE=menu # menu, countdown, hidden
# 컀λ νλΌλ―Έν°
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
# ν΄μλ
GRUB_GFXMODE=1920x1080
# 볡ꡬ λͺ¨λ νλͺ© λΉνμ±ν
GRUB_DISABLE_RECOVERY="false"
# OS νλ‘λ² (λ€λ₯Έ OS κ°μ§)
GRUB_DISABLE_OS_PROBER=false
GRUB μ λ°μ΄νΈ¶
# μ€μ λ³κ²½ ν μ μ©
sudo update-grub # Ubuntu/Debian
sudo grub2-mkconfig -o /boot/grub2/grub.cfg # RHEL/CentOS
# BIOS μμ€ν
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# UEFI μμ€ν
sudo grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
GRUB μ¬μ€μΉ¶
# BIOS μμ€ν
sudo grub-install /dev/sda
sudo update-grub
# UEFI μμ€ν
sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi
sudo update-grub
λΆν νλͺ© μλ μΆκ°¶
# /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
menuentry "Custom Kernel" {
set root='hd0,msdos1'
linux /boot/vmlinuz-6.7.0-custom root=/dev/sda2 ro quiet
initrd /boot/initrd.img-6.7.0-custom
}
menuentry "Recovery Mode" {
set root='hd0,msdos1'
linux /boot/vmlinuz-6.7.0-custom root=/dev/sda2 ro single
initrd /boot/initrd.img-6.7.0-custom
}
κΈ°λ³Έ λΆν 컀λ λ³κ²½¶
# μ¬μ© κ°λ₯ν λ©λ΄ νλͺ© νμΈ
grep -E "^menuentry|^submenu" /boot/grub/grub.cfg
# κΈ°λ³Έκ° μ€μ (μΈλ±μ€)
sudo grub-set-default 2
# κΈ°λ³Έκ° μ€μ (μ΄λ¦)
sudo grub-set-default "Ubuntu, with Linux 5.15.0-92-generic"
# μΌνμ± λΆν
μ ν
sudo grub-reboot "Ubuntu, with Linux 5.15.0-91-generic"
# /etc/default/grubμμ GRUB_DEFAULT μ€μ
GRUB_DEFAULT="1>2" # μλΈλ©λ΄ 1λ²μ 3λ²μ§Έ νλͺ©
7. 컀λ νλΌλ―Έν°¶
λΆν μ νλΌλ―Έν°¶
# /etc/default/grubμμ μ€μ
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root"
# λλ GRUB λ©λ΄μμ 'e'λ₯Ό λλ¬ μΌμμ νΈμ§
linux /boot/vmlinuz-... root=... quiet splash nouveau.modeset=0
μΌλ°μ μΈ μ»€λ νλΌλ―Έν°¶
| νλΌλ―Έν° | μ€λͺ |
|---|---|
quiet |
λΆν λ©μμ§ μ΅μν |
splash |
κ·Έλν½ μ€νλμ νλ©΄ |
single |
λ¨μΌ μ¬μ©μ λͺ¨λ |
init=/bin/bash |
μ§μ μλ‘ λΆν |
nomodeset |
λΉλμ€ λͺ¨λ μ€μ λΉνμ±ν |
acpi=off |
ACPI λΉνμ±ν |
noapic |
APIC λΉνμ±ν |
mem=4G |
μ¬μ© λ©λͺ¨λ¦¬ μ ν |
maxcpus=2 |
CPU μ μ ν |
λ°νμ νλΌλ―Έν° (sysctl)¶
# νμ¬ κ° νμΈ
sysctl -a
sysctl net.ipv4.ip_forward
# μμ λ³κ²½
sudo sysctl -w net.ipv4.ip_forward=1
# μꡬ μ€μ
echo "net.ipv4.ip_forward = 1" | sudo tee /etc/sysctl.d/99-custom.conf
sudo sysctl -p /etc/sysctl.d/99-custom.conf
# λλ /etc/sysctl.conf νΈμ§ ν
sudo sysctl -p
μ£Όμ sysctl νλΌλ―Έν°¶
# /etc/sysctl.d/99-custom.conf
# λ€νΈμν¬
net.ipv4.ip_forward = 1
net.ipv4.tcp_syncookies = 1
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
# λ©λͺ¨λ¦¬
vm.swappiness = 10
vm.dirty_ratio = 40
vm.dirty_background_ratio = 10
# νμΌ μμ€ν
fs.file-max = 2097152
fs.inotify.max_user_watches = 524288
# 보μ
kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2
initramfs κ΄λ¦¬¶
# νμ¬ μ»€λμ initramfs μ¬μμ±
sudo update-initramfs -u
# νΉμ 컀λ λ²μ
sudo update-initramfs -u -k 5.15.0-92-generic
# μλ‘ μμ±
sudo update-initramfs -c -k 5.15.0-92-generic
# RHEL/CentOS (dracut)
sudo dracut -f
sudo dracut -f /boot/initramfs-$(uname -r).img $(uname -r)
# λ΄μ© νμΈ
lsinitramfs /boot/initrd.img-$(uname -r) | head -50
μ°μ΅ λ¬Έμ ¶
λ¬Έμ 1: λͺ¨λ κ΄λ¦¬¶
nouveauλλΌμ΄λ²λ₯Ό λΈλ리μ€νΈμ μΆκ°νκ³ νμΈνμΈμ.- NVIDIA λ μ λλΌμ΄λ² μ¬μ© μλ리μ€λ₯Ό κ°μ ν©λλ€.
λ¬Έμ 2: GRUB μ€μ ¶
λ€μ μꡬμ¬νμ λ§μ‘±νλ GRUB μ€μ μ μμ±νμΈμ: - λΆν νμμμ 10μ΄ - κΈ°λ³Έ 컀λ: λ λ²μ§Έ νλͺ© - λ©λͺ¨λ¦¬ 4GB μ ν - μ‘°μ©ν λΆν
λ¬Έμ 3: sysctl μ€μ ¶
μΉ μλ²μ μ΅μ νλ sysctl μ€μ μ μμ±νμΈμ: - μ°κ²° λ°±λ‘κ·Έ μ¦κ° - νμΌ λμ€ν¬λ¦½ν° μ ν μ¦κ° - TCP νλ
μ λ΅¶
λ¬Έμ 1 μ λ΅¶
# nouveau λΈλ리μ€νΈ
echo "blacklist nouveau" | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
echo "options nouveau modeset=0" | sudo tee -a /etc/modprobe.d/blacklist-nouveau.conf
# initramfs μ
λ°μ΄νΈ
sudo update-initramfs -u # Ubuntu
sudo dracut -f # RHEL
# νμΈ
cat /etc/modprobe.d/blacklist-nouveau.conf
# μ¬λΆν
ν νμΈ
lsmod | grep nouveau # μΆλ ₯ μμ΄μΌ ν¨
λ¬Έμ 2 μ λ΅¶
# /etc/default/grub
GRUB_DEFAULT=1
GRUB_TIMEOUT=10
GRUB_TIMEOUT_STYLE=menu
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem=4G"
GRUB_CMDLINE_LINUX=""
# μ μ©
sudo update-grub
λ¬Έμ 3 μ λ΅¶
# /etc/sysctl.d/99-webserver.conf
# μ°κ²° λ°±λ‘κ·Έ
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
# νμΌ λμ€ν¬λ¦½ν°
fs.file-max = 2097152
# TCP νλ
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 5
net.ipv4.tcp_keepalive_intvl = 15
# λ©λͺ¨λ¦¬ λ²νΌ
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 12582912 16777216
net.ipv4.tcp_wmem = 4096 12582912 16777216
# μ μ©
sudo sysctl -p /etc/sysctl.d/99-webserver.conf
λ€μ λ¨κ³¶
- 21_Virtualization_KVM.md - libvirt, virsh, VM κ΄λ¦¬
μ°Έκ³ μλ£¶
- The Linux Kernel Archives
- Kernel Documentation
- GRUB Manual
man modprobe,man dkms,man sysctl