linux修改磁盘分区容量大小#yyds干货盘点#
Posted lqbyz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux修改磁盘分区容量大小#yyds干货盘点#相关的知识,希望对你有一定的参考价值。
由于默认的是
1、lsblk查看分区情况
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 512M 0 part /boot
└─sda3 8:3 0 1.8T 0 part
├─centos-root 253:0 0 105.5G 0 lvm /
├─centos-swap 253:1 0 32G 0 lvm
├─centos-mnt_paas 253:2 0 100G 0 lvm /mnt/paas
├─centos-var_lib_docker 253:3 0 500G 0 lvm /var/lib/docker
├─centos-var_log 253:4 0 1T 0 lvm
└─centos-var_paas_sys_log 253:5 0 100G 0 lvm /var/paas/sys/log
sr0 11:0 1 1024M 0 rom
2、卸载分区
# umount /dev/centos/var_log /var/log
umount: /var/log:目标忙。
(有些情况下通过 lsof(8) 或 fuser(1) 可以
找到有关使用该设备的进程的有用信息)
umount: /var/log:目标忙。
(有些情况下通过 lsof(8) 或 fuser(1) 可以
找到有关使用该设备的进程的有用信息)
3、卸载分区出现报错,通过命令查看那些进程往里边写
#fuser -mv /dev/centos/var_log
用户 进程号 权限 命令
/dev/dm-4: root kernel mount /var/log
root 375158 F...m rsyslogd
root 375163 F...m systemd-journal
4、停止相关的进程
systemctl stop systemd-journald.socket
systemctl status systemd-journald.service
fuser -mv /dev/centos/var_log
systemctl status rsyslogd
systemctl status rsyslog
systemctl stop rsyslog
systemctl status rsyslog
5、成功umount
umount /dev/centos/var_log /var/log
6、再次lsblk查看
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 512M 0 part /boot
└─sda3 8:3 0 1.8T 0 part
├─centos-root 253:0 0 105.5G 0 lvm /
├─centos-swap 253:1 0 32G 0 lvm
├─centos-mnt_paas 253:2 0 100G 0 lvm /mnt/paas
├─centos-var_lib_docker 253:3 0 500G 0 lvm /var/lib/docker
├─centos-var_log 253:4 0 1T 0 lvm
└─centos-var_paas_sys_log 253:5 0 100G 0 lvm /var/paas/sys/log
sr0 11:0 1 1024M 0 rom
7、删除分区
lvremove /dev/centos/var_log
Do you really want to remove active logical volume centos/var_log? [y/n]: y
Logical volume "var_log" successfully removed
8、扩展/的逻辑分区
lvextend -l +100%FREE /dev/centos/root
Size of logical volume centos/root changed from <105.50 GiB (27007 extents) to 1.10 TiB (289151 extents).
Logical volume centos/root successfully resized.
9、查看逻辑卷的情况:pvdisplay
lvdisplay
--- Logical volume ---
LV Path /dev/centos/root ###这个路径需要文件系统的扩容
LV Name root
VG Name centos
LV UUID vz11wm-tfB0-dLSG-Qki7-yAyy-XeSI-3Vmlks
LV Write Access read/write
LV Creation host, time 10-255-91-45-93, 2021-10-28 16:40:15 +0800
LV Status available
# open 1
LV Size 1.10 TiB
Current LE 289151
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
10、扩容文件系统 (文件系统是ext命令:resize2fs /dev/centos/root xfs命令:xfs_growfs /dev/centos/root )
resize2fs /dev/centos/root
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/centos/root is mounted on /; on-line resizing required
old_desc_blocks = 14, new_desc_blocks = 142
The filesystem on /dev/centos/root is now 296090624 blocks long.
df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 32G 0 32G 0% /dev
tmpfs 32G 12K 32G 1% /dev/shm
tmpfs 32G 2.6M 32G 1% /run
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/mapper/centos-root 1.1T 9.2G 1.1T 1% /
/dev/sda2 488M 157M 296M 35% /boot
/dev/mapper/centos-mnt_paas 99G 61M 94G 1% /mnt/paas
/dev/mapper/centos-var_lib_docker 493G 73M 467G 1% /var/lib/docker
/dev/mapper/centos-var_paas_sys_log 99G 61M 94G 1% /var/paas/sys/log
以上是关于linux修改磁盘分区容量大小#yyds干货盘点#的主要内容,如果未能解决你的问题,请参考以下文章
#yyds干货盘点#Linux的磁盘分区物理设备和文件系统一
#yyds干货盘点#windows server 2012 R2分区样式:MBR与GPT