Ubuntu 24.04 Server 版安裝及配置
文章目錄
- Ubuntu 24.04 Server 版安裝及配置
- 一、獲取安裝文件
- 二、虛擬機配置
- 三、安裝界面
- 四、配置網絡
- 五、擴容根分區
一、獲取安裝文件
二、虛擬機配置
三、安裝界面
選擇English(US)
問是否升級內核
配置鍵盤
手動配置ipv4網絡(可選)
子網、IP、網關、DNS
是否配置靜像源
系統使用默認靜像源
使用默認磁盤分區
設置服務器用戶及賬號信息
不升級,默認的LTS版本維護周期5年
安裝SSH服務!!按空格選擇它
不安裝系統應用
系統安裝中
一定要等到這個狀態,才算安裝完成
系統重啟時,提示這個,敲回車,確認卸載光盤
四、配置網絡
[root@master01:/etc/netplan]# vi /etc/netplan/50-cloud-init.yaml
`這個是原先在安裝界面時,配置好的IP地址,打開配置文件顯示的內容`
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:ethernets:ens33:addresses:- 192.168.100.10/24nameservers:addresses:- 8.8.8.8search: []routes:- to: defaultvia: 192.168.100.2version: 2
? 推薦手動配置網絡
`在安裝界面未配置IP時,可按視頻教程手動配置以下內容`
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:ethernets:ens33:dhcp4: noaddresses:此外冒號后不要有空格- 192.168.100.10/24routes:- to: defaultvia: 192.168.100.2nameservers:addresses: [119.29.29.29,8.8.8.8,114.114.114.114]version: 2
[root@master01:/etc/netplan]# netplan apply
五、擴容根分區
🚨 為什么只用了 49G?不是應該用滿 100G 嗎?
這是因為:
? Ubuntu 安裝程序默認設置有限制
-
默認只給根分區分配 48~50G 左右(取決于版本和安裝選項)
-
即使你給了 100G 磁盤,它也不會自動把全部空間都用掉
-
除非你手動調整分區大小
? 如何解決?擴展根分區到 100G?
你可以通過以下步驟 擴大邏輯卷并擴容文件系統:
🔧 步驟一:檢查當前 LVM 結構
sudo lvdisplay
🔧 步驟二:擴展邏輯卷(LV)
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
-l +100%FREE
表示使用剩余所有空間(這里是 49G)
🔧 步驟三:擴展文件系統(ext4)
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
注意:如果提示不支持,可能是文件系統類型不同,但 Ubuntu 默認是 ext4。
? 驗證結果
df -h