这里是操作的ssh全部记录:
- [root@aioCloud ~]# lsblk #查看硬盘容量
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- sda 8:0 0 40G 0 disk
- ├─sda1 8:1 0 1G 0 part /boot
- └─sda2 8:2 0 19G 0 part
- ├─centos-root 253:0 0 17G 0 lvm /
- └─centos-swap 253:1 0 2G 0 lvm [SWAP]
- sr0 11:0 1 918M 0 rom
- [root@aioCloud ~]# df -Th #查看目录容量和文件系统类型
- Filesystem Type Size Used Avail Use% Mounted on
- /dev/mapper/centos-root xfs 17G 1.8G 16G 11% /
- devtmpfs devtmpfs 898M 0 898M 0% /dev
- tmpfs tmpfs 910M 0 910M 0% /dev/shm
- tmpfs tmpfs 910M 9.6M 901M 2% /run
- tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
- /dev/sda1 xfs 1014M 146M 869M 15% /boot
- tmpfs tmpfs 182M 0 182M 0% /run/user/0
- [root@aioCloud ~]# fdisk /dev/sda #操作sda这块硬盘
- Welcome to fdisk (util-linux 2.23.2).
- Changes will remain in memory only, until you decide to write them.
- Be careful before using the write command.
- Command (m for help): p #打印分区
- Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 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 label type: dos
- Disk identifier: 0x000a814e
- Device Boot Start End Blocks Id System
- /dev/sda1 * 2048 2099199 1048576 83 Linux
- /dev/sda2 2099200 41943039 19921920 8e Linux LVM
- Command (m for help): n #新建分区
- Partition type:
- p primary (2 primary, 0 extended, 2 free) #主分区
- e extended
- Select (default p): p #选择主分区
- Partition number (3,4, default 3): #默认第3个
- First sector (41943040-83886079, default 41943040): #默认开始41943040
- Using default value 41943040
- Last sector, +sectors or +size{K,M,G} (41943040-83886079, default 83886079): #默认结束83886079
- Using default value 83886079
- Partition 3 of type Linux and of size 20 GiB is set #设置了第3个分区20G
- Command (m for help): p #再次打印分区
- Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 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 label type: dos
- Disk identifier: 0x000a814e
- Device Boot Start End Blocks Id System
- /dev/sda1 * 2048 2099199 1048576 83 Linux
- /dev/sda2 2099200 41943039 19921920 8e Linux LVM
- /dev/sda3 41943040 83886079 20971520 83 Linux #创建了第3个分区
- Command (m for help): w #保存所有设置
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
- The kernel still uses the old table. The new table will be used at
- the next reboot or after you run partprobe(8) or kpartx(8)
- Syncing disks.
- [root@aioCloud ~]# partprobe /dev/sda #刷新硬盘分区
- [root@aioCloud ~]# pvcreate /dev/sda3 #创建物理卷
- Physical volume "/dev/sda3" successfully created.
- [root@aioCloud ~]# vgdisplay #查看卷组名
- --- Volume group ---
- VG Name centos #卷组名为centos
- System ID
- Format lvm2
- Metadata Areas 1
- Metadata Sequence No 3
- VG Access read/write
- VG Status resizable
- MAX LV 0
- Cur LV 2
- Open LV 2
- Max PV 0
- Cur PV 1
- Act PV 1
- VG Size <19.00 GiB
- PE Size 4.00 MiB
- Total PE 4863
- Alloc PE / Size 4863 / <19.00 GiB
- Free PE / Size 0 / 0
- VG UUID h3zcWq-c7sW-TYfu-LOaG-qBO0-FcYR-ffiRUK
-
- [root@aioCloud ~]# vgextend centos /dev/sda3 #将物理卷添加到卷组
- Volume group "centos" successfully extended
- [root@aioCloud ~]# lvdisplay #查看逻辑卷组名
- --- Logical volume ---
- LV Path /dev/centos/swap
- LV Name swap
- VG Name centos
- LV UUID X1U0Aj-HN1N-xFFx-uUmg-olLD-GmSc-Z6cdd9
- LV Write Access read/write
- LV Creation host, time aioCloud, 2021-01-25 18:20:01 +0800
- LV Status available
- # open 2
- LV Size 2.00 GiB
- Current LE 512
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 8192
- Block device 253:1
-
- --- Logical volume ---
- LV Path /dev/centos/root #这个就是我们需要扩容的目录卷组名
- LV Name root
- VG Name centos
- LV UUID BLUfI9-1SEK-5Lbc-sDN8-iCmt-kJMM-B7cGYT
- LV Write Access read/write
- LV Creation host, time aioCloud, 2021-01-25 18:20:01 +0800
- LV Status available
- # open 1
- LV Size <17.00 GiB
- Current LE 4351
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 8192
- Block device 253:0
-
- [root@aioCloud ~]# lvextend -l +100%FREE /dev/centos/root #扩容所有空闲容量到/dev/centos/root
- Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to 36.99 GiB (9470 extents).
- Logical volume centos/root successfully resized.
- [root@aioCloud ~]# df -Th #查看目录容量
- Filesystem Type Size Used Avail Use% Mounted on
- /dev/mapper/centos-root xfs 17G 1.8G 16G 11% /
- devtmpfs devtmpfs 898M 0 898M 0% /dev
- tmpfs tmpfs 910M 0 910M 0% /dev/shm
- tmpfs tmpfs 910M 9.6M 901M 2% /run
- tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
- /dev/sda1 xfs 1014M 146M 869M 15% /boot
- tmpfs tmpfs 182M 0 182M 0% /run/user/0
- [root@aioCloud ~]# xfs_growfs /dev/centos/root #更新根目录容量
- meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=1113856 blks
- = sectsz=512 attr=2, projid32bit=1
- = crc=1 finobt=0 spinodes=0
- data = bsize=4096 blocks=4455424, imaxpct=25
- = sunit=0 swidth=0 blks
- naming =version 2 bsize=4096 ascii-ci=0 ftype=1
- log =internal 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 4455424 to 9697280
- [root@aioCloud ~]# df -Th #再次查看目录容量
- Filesystem Type Size Used Avail Use% Mounted on
- /dev/mapper/centos-root xfs 37G 1.8G 36G 5% /
- devtmpfs devtmpfs 898M 0 898M 0% /dev
- tmpfs tmpfs 910M 0 910M 0% /dev/shm
- tmpfs tmpfs 910M 9.6M 901M 2% /run
- tmpfs tmpfs 910M 0 910M 0% /sys/fs/cgroup
- /dev/sda1 xfs 1014M 146M 869M 15% /boot
- tmpfs tmpfs 182M 0 182M 0% /run/user/0
- [root@aioCloud ~]# lsblk #再次查看分区状态
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- sda 8:0 0 40G 0 disk
- ├─sda1 8:1 0 1G 0 part /boot
- ├─sda2 8:2 0 19G 0 part
- │ ├─centos-root 253:0 0 37G 0 lvm /
- │ └─centos-swap 253:1 0 2G 0 lvm [SWAP]
- └─sda3 8:3 0 20G 0 part
- └─centos-root 253:0 0 37G 0 lvm /
- sr0 11:0 1 918M 0 rom
- [root@aioCloud ~]# reboot #重启后再测试
复制代码
|