オペレーターのイメージを使用してクラウド サーバーをインストールし、ディストリビューション バージョンの Linux システム CentOS8.1 を選択し、クラウド ディスクは 500G、メモリは 16G ですが、システムをインストールした後、ルート ディレクトリが非常に小さいことがわかります。 8G だけ 50G に調整する必要があります. それでは、調整プロセスを記録しましょう .
基本的な考え方
PV (物理ボリューム) - 物理ボリューム 物理ボリューム
は論理ボリューム管理の最下部にあり、実際の物理ハードディスク上のパーティション、物理ハードディスク全体、または RAID デバイスの場合があります。 .
VG (ボリューム グループ) - ボリューム グループ ボリューム グループは
物理ボリューム上に確立され、ボリューム グループには少なくとも 1 つの物理ボリュームが含まれている必要があります. ボリューム グループが確立された後、物理ボリュームをボリューム グループに動的に追加できます. 論理ボリューム管理システム プロジェクトは、1 つのボリューム グループまたは複数のボリューム グループを持つことができます。
LV(Logical Volume) - 論理
ボリューム 論理ボリュームはボリューム グループ上に確立され、ボリューム グループ内の未割り当て領域を使用して新しい論理ボリュームを作成できます。論理ボリュームが確立された後、領域を動的に拡張および縮小できます。システム内の複数の論理ボリュームは、同じボリューム グループまたは異なるボリューム グループに属することができます。
CentOS8.1 中国語を英語に変更
#vim /etc/locale.conf
LANG="zh_CN.UTF-8"
修改为
LANG=en_US.UTF-8
#reboot
再起動して有効にする
CentOS8.1 イメージ ブートをキャラクター マルチユーザーに変更
[root@centos8 etc]# more inittab
# inittab is no longer used.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target
#
# systemd uses 'targets' instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#
# To view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
[root@centos8 etc]# systemctl set-default multi-user.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/multi-user.target.
[root@centos8 etc]# reboot
再起動して有効にする
CentOS8.1 システムディスク/ルートディレクトリ拡張
1. ディスクサイズと残り容量を確認する
[root@centos8 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs tmpfs 7.8G 8.9M 7.8G 1% /run
tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/mapper/cl-root xfs 8.0G 4.1G 3.9G 52% /
/dev/vda1 ext4 976M 143M 766M 16% /boot
tmpfs tmpfs 1.6G 4.0K 1.6G 1% /run/user/0
2. ハードディスクとパーティションの数を表示する
[root@centos8 ~]# fdisk -l
Disk /dev/vda: 540 GiB, 579820584960 bytes, 1132462080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1cdf0571
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 2099199 2097152 1G 83 Linux
/dev/vda2 2099200 20971519 18872320 9G 8e Linux LVM
Disk /dev/mapper/cl-root: 8 GiB, 8585740288 bytes, 16769024 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/cl-swap: 1 GiB, 1073741824 bytes, 2097152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
3. 未割り当てディスクを分割します
[root@centos8 ~]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (20971520-1132462079, default 20971520):
Last sector, +sectors or +size{
K,M,G,T,P} (20971520-1132462079, default 1132462079): +42GB
Created a new partition 3 of type 'Linux' and of size 39.1 GiB.
Command (m for help): P
P: unknown command
Command (m for help): p
Disk /dev/vda: 540 GiB, 579820584960 bytes, 1132462080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1cdf0571
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 2099199 2097152 1G 83 Linux
/dev/vda2 2099200 20971519 18872320 9G 8e Linux LVM
/dev/vda3 20971520 103002111 82030592 39.1G 83 Linux
Command (m for help): w
The partition table has been altered.
Syncing disks.
4. ディスク パーティション テーブルの変更情報をカーネルに通知し、システムがパーティション テーブルをリロードします。
[root@centos8 ~]# partprobe -s
/dev/vda: msdos partitions 1 2 3
5.物理ボリュームを作成する
[root@centos8 ~]# pvcreate /dev/vda3
Physical volume "/dev/vda3" successfully created.
6. lvm ボリュームを表示する
[root@centos8 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/vda2
VG Name cl
PV Size <9.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 2303
Free PE 0
Allocated PE 2303
PV UUID bJ39om-je2X-7eVI-99cr-ieNt-Qlkm-LfqOBM
"/dev/vda3" is a new physical volume of "<39.12 GiB"
--- NEW Physical volume ---
PV Name /dev/vda3
VG Name
PV Size <39.12 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID fhAswC-ab3g-qgdN-5hoW-iIFE-rzKI-FFg9GC
7.ボリュームグループを表示します。ボリュームグループの名前は「cl」です(一部のシステムのデフォルトは「centos」です。変更に注意してください)
vgdisplay
8. 新しいボリュームを元の「cl」ボリューム グループに拡張します。
[root@centos8 ~]# vgextend cl /dev/vda3
Volume group "cl" successfully extended
9. 論理ボリュームの拡張
[root@centos8 ~]# lvextend -l +100%free /dev/mapper/cl-root
Size of logical volume cl/root changed from <8.00 GiB (2047 extents) to <47.11 GiB (12060 extents).
Logical volume cl/root successfully resized.
### 查看逻辑卷文件系统类型
[root@centos8 ~]# blkid /dev/mapper/cl-root
/dev/mapper/cl-root: UUID="b67bbb1c-3845-4fe5-9906-9902394816e2" TYPE="xfs"
10. ファイル システムを拡張するには、ext タイプのパーティションの場合は resize2fs コマンドを使用します。
[root@centos8 ~]# xfs_growfs /
meta-data=/dev/mapper/cl-root isize=512 agcount=4, agsize=524032 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=2096128, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 2096128 to 12349440
[root@centos8 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs tmpfs 7.8G 8.9M 7.8G 1% /run
tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/mapper/cl-root xfs 48G 4.4G 43G 10% /
/dev/vda1 ext4 976M 143M 766M 16% /boot
tmpfs tmpfs 1.6G 4.0K 1.6G 1% /run/user/0