磁盘扩容2T+(学习笔记)

注意事项

# fdisk方式适用于2T以上磁盘扩容
# parted 用于2T以上磁盘扩容 (GPT磁盘模式)
# CentOS 6 及之前的版本,ext4是默认文件系统
# CentOS 7 开始,XFS是默认的文件系统格式

准备一块大于2T的磁盘

如下图所示sdc为一块未进行分区和挂载的磁盘

执行parted 进行分区

[root@localhost ~]# parted /dev/sdc          # 执行分区操作 sdc为需要进行分区的磁盘名称
GNU Parted 3.1
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel                     # 执行mklabel                                     
New disk label type? 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?                            # 提示当前操作会清空sdc所有数据
Yes/No? Yes                          # 确认执行                                   
(parted) p                           # 显示当前选定磁盘的分区表信息   目前没有任何分区信息                                 
Model: VMware Virtual disk (scsi)
Disk /dev/sdc: 3299GB                
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start  End  Size  File system  Name  Flags
                                                                 
(parted)  mkpart                    # 执行创建分区命令                                          
Partition name?  []? sdc1           # 指定分区名称                                      
File system type?  [ext2]? xfs      # 指定文件系统格式 xfs   //centos 6.0 之前默认为 ext4 centos 7 默认xfs                 
Start? 1                            # 分区起点
End? 3296GB                         # 分区终点                                      
(parted) p                          # 查看分区表信息 已创建编号为1 起点为1049kb 终点为3296GB 大小为 3296GB 名称为sdc1的的分区
Model: VMware Virtual disk (scsi)
Disk /dev/sdc: 3299GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  3296GB  3296GB               sdc1

(parted) Q                          # 保存对分区表更改,并退出
Information: You may need to update /etc/fstab.  # 提示需要更新/etc/fstab

创建逻辑卷(LVM)

# 执行lsblk -l 查看当前分区情况
[root@localhost ~]# pvcreate /dev/sdc1              # 将sdc1创建为PV物理卷
  Physical volume "/dev/sdc1" successfully created.
[root@localhost ~]# pvs                             # 查看当当前系统中物理卷信息
  PV         VG     Fmt  Attr PSize     PFree 
  /dev/sda3  centos lvm2 a--  <1023.00g     0 
  /dev/sdb1  centos lvm2 a--     <2.00t     0 
  /dev/sdc1         lvm2 ---     <3.00t <3.00t
[root@localhost ~]# vgextend centos /dev/sdc1       # 添加物理卷至 名为centos的卷组
  Volume group "centos" successfully extended
[root@localhost ~]# vgs                             # 查看LVM(逻辑卷管理)的信息
  VG     #PV #LV #SN Attr   VSize  VFree 
  centos   3   2   0 wz--n- <6.00t <3.00t
[root@localhost ~]# lvextend -l+100%FREE /dev/centos/root # 将空闲空间全部扩容给逻辑卷 
  Size of logical volume centos/root changed from <2.97 TiB (777982 extents) to <5.97 TiB (1563809 extents).
  Logical volume centos/root successfully resized.
[root@localhost ~]# xfs_growfs /dev/centos/root # 格式化逻辑卷 将xfs文件系统扩容至与卷大小一致
meta-data=/dev/mapper/centos-root isize=512    agcount=13, agsize=64945920 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=796653568, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=126847, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 796653568 to 1601340416
df -h  // 查看当前磁盘容量
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值