系统目录扩容

阅读: 评论:0

系统目录扩容

系统目录扩容

系统目录扩容

前提:机器的之前就是在LVM上创建的系统。如果不是的话,就不能进行动态扩容,可采用挂载到指定目录的方式。若想移除,则考虑新加一块硬盘进行数据迁移,确保数据安全迁移之后再进行移除。

  1. 查看初始磁盘状态
(base) [root@automlgpu1 ~]# lsblk 
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  223G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0  222G  0 part ├─centos-root 253:0    0  100G  0 lvm  /├─centos-swap 253:1    0    4G  0 lvm  └─centos-home 253:2    0  118G  0 lvm  /home
sdb               8:16   0  223G  0 disk 
sdc               8:32   0  3.7T  0 disk 
sdd               8:48   0 14.9G  0 disk 
  1. 需要扩容的硬盘超过2T需要更改为gpt分区,否则会发现超出的空间用不到。不超过直接可以不用这步跳过。
(base) [root@automlgpu1 ~]# parted /dev/sdc 
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)                                                                  
#(parted) mklabel gpt
Warning: The existing disk label on /dev/sdc will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes                                                               
#(parted) mkpart primary 0% 100%
(parted)                                                                  
#(parted) p                                                                
Model: DELL PERC H330 Adp (scsi)
Disk /dev/sdc: 4000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: Number  Start   End     Size    File system  Name     Flags1      1049kB  4000GB  4000GB  ext4         primary#(parted) q                                                                
Information: You may need to update /etc/fstab.
  1. 更改分区格式为lvm
(base) [root@automlgpu1 ~]# fdisk /dev/sdc 
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
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): t
#Partition type (type L to list all types): 31
#Command (m for help): pDisk /dev/sdc: 4000.2 GB, 4000225165312 bytes, 7812939776 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: gpt
Disk identifier: 55202227-561A-4085-8A48-AF2DBF0CAAB5Start          End    Size  Type            Name1         2048   7812937727    3.7T  Microsoft basic primary#Command (m for help): pDisk /dev/sdc: 4000.2 GB, 4000225165312 bytes, 7812939776 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: gpt
Disk identifier: 55202227-561A-4085-8A48-AF2DBF0CAAB5#         Start          End    Size  Type            Name1         2048   7812937727    3.7T  Linux LVM       primary#Command (m for help): w
The partition table has been altered!
  1. 不用格式化分区,直接加入vg组,vg会自动帮格式化成他需要的格式
(base) [root@automlgpu1 ~]# vgextend centos /dev/sdc1
#WARNING: ext4 signature detected on /dev/sdc1 at offset 1080. Wipe it? [y/n]: yWiping ext4 signature on /dev/sdc1.Physical volume "/dev/sdc1" successfully created.Volume group "centos" successfully extended
  1. 为相应的挂载点去提升容量
(base) [root@automlgpu1 /]# lvextend -L +1.6t -r /dev/centos/root
(base) [root@automlgpu1 /]# lvextend -L +2t -r /dev/centos/home
  1. 完成结果
(base) [root@automlgpu1 /]# lsblk 
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0  223G  0 disk 
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0  222G  0 part ├─centos-root 253:0    0  1.7T  0 lvm  /├─centos-swap 253:1    0    4G  0 lvm  └─centos-home 253:2    0  2.2T  0 lvm  /home
sdb               8:16   0  223G  0 disk 
sdc               8:32   0  3.7T  0 disk 
└─sdc1            8:33   0  3.7T  0 part ├─centos-root 253:0    0  1.7T  0 lvm  /└─centos-home 253:2    0  2.2T  0 lvm  /home
sdd               8:48   0 14.9G  0 disk (base) [root@automlgpu1 /]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  1.7T   73G  1.6T   5% /
devtmpfs                  47G     0   47G   0% /dev
tmpfs                     47G  156K   47G   1% /dev/shm
tmpfs                     47G  969M   46G   3% /run
tmpfs                     47G     0   47G   0% /sys/fs/cgroup
/dev/sda1               1014M  182M  833M  18% /boot
/dev/mapper/centos-home  2.2T   47G  2.0T   3% /home
tmpfs                    9.3G   12K  9.3G   1% /run/user/42
tmpfs                    9.3G     0  9.3G   0% /run/user/0
overlay                  1.7T   73G  1.6T   5% /data/dockerdata/overlay2/710d394cf386ff88857daceb09baf2c64311ce5fdd160e38c17b394390a6bb05/merged

本文发布于:2024-01-30 15:30:21,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170659982320998.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:目录   系统
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23