ESXI虚拟机磁盘原有是40G现扩容到240G。
df -Th 这是参数连着写。相当于df -T -h
-T:代表type类型,可以查看到磁盘的类型。
-h:代表human人类,就是以人们熟悉的单位来表示磁盘大小,如K、M、G。如果不加这个参数,默认以KB字节单位显示,可读性差。
查询结果含义:size代表磁盘总大小,used代表已使用的空间,avail代表剩余可用空间。我们重点关注根目录的磁盘使用情况即可。
[root@localhost ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 890M 0 890M 0% /dev tmpfs tmpfs 908M 0 908M 0% /dev/shm tmpfs tmpfs 908M 8.7M 900M 1% /run tmpfs tmpfs 908M 0 908M 0% /sys/fs/cgroup /dev/mapper/rl-root xfs 37G 15G 23G 40% / /dev/sda2 xfs 1014M 208M 807M 21% /boot /dev/sda1 vfat 599M 5.8M 594M 1% /boot/efi tmpfs tmpfs 182M 0 182M 0% /run/user/0
lsblk命令的英文是“list block”,即用于列出所有可用块设备的信息,而且还能显示他们之间的依赖关系。
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 240G 0 disk ├─sda1 8:1 0 600M 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 38.4G 0 part ├─rl-root 253:0 0 36.4G 0 lvm / └─rl-swap 253:1 0 2.1G 0 lvm [SWAP] sr0 11:0 1 1024M 0 rom
fdisk -l //查看磁盘分区情况
[root@localhost ~]# fdisk -l
GPT PMBR size mismatch (83886079 != 503316479) will be corrected by write.
Disk /dev/sda: 240 GiB, 257698037760 bytes, 503316480 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: gpt
Disk identifier: 98C577F9-5440-4CA8-B519-8E54635464D4
Device Start End Sectors Size Type
/dev/sda1 2048 1230847 1228800 600M EFI System
/dev/sda2 1230848 3327999 2097152 1G Linux filesystem
/dev/sda3 3328000 83884031 80556032 38.4G Linux LVM
Disk /dev/mapper/rl-root: 36.4 GiB, 39036387328 bytes, 76242944 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/rl-swap: 2.1 GiB, 2206203904 bytes, 4308992 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
fdisk/dev/sda 创建分区
[root@localhost ~]# fdisk /dev/sda
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.
GPT PMBR size mismatch (83886079 != 503316479) will be corrected by write.
打印分区表
Command (m for help): p
Disk /dev/sda: 240 GiB, 257698037760 bytes, 503316480 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: gpt
Disk identifier: 98C577F9-5440-4CA8-B519-8E54635464D4
Device Start End Sectors Size Type
/dev/sda1 2048 1230847 1228800 600M EFI System
/dev/sda2 1230848 3327999 2097152 1G Linux filesystem
/dev/sda3 3328000 83884031 80556032 38.4G Linux LVM
打印菜单
Command (m for help): m
Help:
GPT
M enter protective/hybrid MBR
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
创建一个新分区
Command (m for help): n
Partition number (4-128, default 4):
First sector (83884032-503316446, default 83884032):
Last sector, +sectors or +size{K,M,G,T,P} (83884032-503316446, default 503316446):
Created a new partition 4 of type 'Linux filesystem' and of size 200 GiB.
Command (m for help): t
Partition number (1-4, default 4):
Partition type (type L to list all types): 31
Changed type of partition 'Linux filesystem' to 'Linux LVM'.
写入分区并退出
Command (m for help): w
The partition table has been altered.
Syncing disks.
[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 240G 0 disk ├─sda1 8:1 0 600M 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot ├─sda3 8:3 0 38.4G 0 part │ ├─rl-root 253:0 0 36.4G 0 lvm / │ └─rl-swap 253:1 0 2.1G 0 lvm [SWAP] └─sda4 8:4 0 200G 0 part sr0 11:0 1 1024M 0 rom
格式化新建的分区 mkfs.ext4 /dev/sda4
[root@localhost ~]# mkfs.ext4 /dev/sda4 mke2fs 1.45.6 (20-Mar-2020) Discarding device blocks: done Creating filesystem with 52428800 4k blocks and 13132800 inodes Filesystem UUID: 9fa537ed-7990-4173-999d-653a7a225761 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: done Writing inode tables: done Creating journal (262144 blocks): done Writing superblocks and filesystem accounting information: done
逻辑卷管理器LVM
[root@localhost ~]# lvm
创建物理卷 pvcreate
lvm> pvcreate /dev/sda4 WARNING: ext4 signature detected on /dev/sda4 at offset 1080. Wipe it? [y/n]: y Wiping ext4 signature on /dev/sda4. Physical volume "/dev/sda4" successfully created. lvm> vgextend rl /dev/sda4 Volume group "rl" successfully extended
显示物理卷属性 pvdisplay
lvm> vgdisplay -v
--- Volume group --- VG Name rl System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size <238.41 GiB PE Size 4.00 MiB Total PE 61032 Alloc PE / Size 9833 / 38.41 GiB Free PE / Size 51199 / <200.00 GiB VG UUID 1rRNwf-Hn1K-Gm1M-tkZW-2V86-zIFC-hIdRWZ --- Logical volume --- LV Path /dev/rl/root LV Name root VG Name rl LV UUID B46CgP-AocJ-uDGF-AAZw-I2mS-wLtt-k8haf1 LV Write Access read/write LV Creation host, time localhost.localdomain, 2024-05-31 14:33:21 +0800 LV Status available # open 1 LV Size <36.36 GiB Current LE 9307 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Logical volume --- LV Path /dev/rl/swap LV Name swap VG Name rl LV UUID x04tXm-Nv8M-z3QL-HFZr-NQjB-YCbr-SbEC8y LV Write Access read/write LV Creation host, time localhost.localdomain, 2024-05-31 14:33:21 +0800 LV Status available # open 2 LV Size 2.05 GiB Current LE 526 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Physical volumes --- PV Name /dev/sda3 PV UUID qA408B-lu9c-okAP-Ll3Z-aUOj-bjfM-ntse1u PV Status allocatable Total PE / Free PE 9833 / 0 PV Name /dev/sda4 PV UUID EMTUp0-7wcX-vkdd-45jo-qtES-Wapb-kk2ijC PV Status allocatable Total PE / Free PE 51199 / 51199
扩展逻辑卷的大小 lvextend
lvextend -L +扩容大小 -r 逻辑卷 //扩展逻辑卷
-r 立刻刷新文件系统
lvm> lvextend -l+51199 /dev/mapper/rl-root Size of logical volume rl/root changed from <36.36 GiB (9307 extents) to 236.35 GiB (60506 extents). Logical volume rl/root successfully resized. lvm> quit Exiting.
使用xfs_growfs命令增加 XFS 文件系统的大小。必须挂载 XFS 文件系统,并且底层设备上必须有可用空间。xfs_growfs 实用程序最常用于逻辑卷。
xfs_growfs 命令的语法如下: xfs_growfs [options] mount-point
[root@localhost ~]# xfs_growfs /dev/mapper/rl-root meta-data=/dev/mapper/rl-root isize=512 agcount=4, agsize=2382592 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=9530368, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=4653, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 9530368 to 61958144
查看磁盘信息,分区已扩容成功。
[root@localhost ~]# df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 890M 0 890M 0% /dev tmpfs tmpfs 908M 0 908M 0% /dev/shm tmpfs tmpfs 908M 8.7M 900M 1% /run tmpfs tmpfs 908M 0 908M 0% /sys/fs/cgroup /dev/mapper/rl-root xfs 237G 16G 221G 7% / /dev/sda2 xfs 1014M 208M 807M 21% /boot /dev/sda1 vfat 599M 5.8M 594M 1% /boot/efi tmpfs tmpfs 182M 0 182M 0% /run/user/0
标签:tmpfs,ESXi,虚拟机,bytes,dev,rl,512,root,分区 From: https://www.cnblogs.com/niewd/p/18672527