随笔 - 262  文章 - 1  评论 - 22  阅读 - 27万

Linux系统给root扩容

https://blog.csdn.net/aben_sky/article/details/121515322

可适用于给其他分区扩容

1,查看分区情况

[root@pxe ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_pxe-lv_root
66G 32G 30G 52% /
tmpfs 1004M 76K 1003M 1% /dev/shm
/dev/sda1 477M 41M 411M 10% /boot
/dev/mapper/vg_pxe-lv_home
29G 21G 7.2G 74% /home
/dev/sr0 4.1G 4.1G 0 100% /media/Kylin-Server-10
1
2
3
4
5
6
7
8
9
2,我这里是虚拟机,原先硬盘大小是100G,已经满了,直接重新分配为150G.
3, 查看磁盘情况

[root@pxe ~]# fdisk -l

Disk /dev/sda: 161.1 GB, 161061273600 bytes
255 heads, 63 sectors/track, 19581 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004d2e5

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM

1
2
3
4
5
6
7
8
9
10
11
12
13
14
4,首选给新增加的容量,重新分区

[root@pxe ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): n
Command action
e extended
p primary partition (1-4)
op^H
Invalid partition number for type `o'
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (13055-19581, default 13055): 13055
Last cylinder, +cylinders or +size{K,M,G} (13055-19581, default 19581): 19581

Command (m for help): p

Disk /dev/sda: 161.1 GB, 161061273600 bytes
255 heads, 63 sectors/track, 19581 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004d2e5

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 19581 52426782+ 83 Linux

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
5 格式化新分区mkfs.ext4 /dev/sda3

[root@pxe ~]# mkfs.ext4 /dev/sda3
mke2fs 1.41.12 (17-May-2010)
1
2
6 创建PV >>>>>这一步没理解是什么意思,我没使用,直接进行的第七步

[root@localhost ~]# pvcreate /dev/sdb1
WARNING: ext4 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/sdb1.
Physical volume "/dev/sdb1" successfully created.
1
2
3
4
7, 查看vgs ,使用vgextend命令,扩展vg

[root@pxe ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_pxe 2 3 0 wz--n- 149.50g 1020.00m
[root@pxe ~]# vgextend vg_pxe /dev/sda3

1
2
3
4
5
8 看下lv组, 使用lvextend来扩展lv

[root@pxe ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv_home vg_pxe -wi-ao---- 29.30g
lv_root vg_pxe -wi-ao---- 115.27g
lv_swap vg_pxe -wi-ao---- 3.94g
[root@pxe ~]# lvextend -L +50G /dev/mapper/vg_pxe-lv_root
1
2
3
4
5
6
9 ,此时查看分区还没有变化,需要重新读取分区,添加的是xfs系统文件,就使用xfs_growfs(只支持增大) ,如果是ext文件系统,就使用resize2fs(增大和减小都支持),我这边使用的是ext文件,所以使用:

[root@pxe ~]# resize2fs /dev/mapper/vg_pxe-lv_root
1
10 查看分区状态,df -h.已经扩容完成

[root@pxe ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_pxe-lv_root
114G 53G 56G 49% /
tmpfs 1004M 224K 1003M 1% /dev/shm
/dev/sda1 477M 41M 411M 10% /boot
/dev/mapper/vg_pxe-lv_home
29G 21G 7.2G 74% /home
/dev/sr0 4.1G 4.1G 0 100% /media/Kylin-Server-10
————————————————
版权声明:本文为CSDN博主「无用的忙碌」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_46061526/article/details/126497837

 

posted on   独上兰舟1  阅读(730)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示