ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

centos7 xfs文件系统的磁盘扩容

2020-03-10 11:58:22  阅读:1339  来源: 互联网

标签:字节 centos 文件系统 dev 扇区 centos7 xfs 512 7.8


1. 找到未使用的磁盘

 df -hT,目前是1T的空间

文件系统                类型      容量  已用  可用 已用% 挂载点
devtmpfs                devtmpfs  7.8G     0  7.8G    0% /dev
tmpfs                   tmpfs     7.8G     0  7.8G    0% /dev/shm
tmpfs                   tmpfs     7.8G  8.9M  7.8G    1% /run
tmpfs                   tmpfs     7.8G     0  7.8G    0% /sys/fs/cgroup
/dev/mapper/centos-root xfs       965G   85G  881G    9% /
/dev/sda1               xfs      1014M  188M  827M   19% /boot
/dev/mapper/centos-home xfs        50G   33M   50G    1% /home
tmpfs                   tmpfs     1.6G     0  1.6G    0% /run/user/0

   fdisk -l

磁盘是2T的容量

磁盘 /dev/sda:2199.0 GB, 2199023255552 字节,4294967296 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000b948d

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200  2147483647  1072692224   8e  Linux LVM

磁盘 /dev/mapper/centos-root:1036.3 GB, 1036286689280 字节,2023997440 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-swap:8455 MB, 8455716864 字节,16515072 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-home:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

  

 

2. 新建分区

fdisk /dev/sda

然后输入m->n->p->回车->回车->回车->w

然后重起机器 reboot

 

WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).

欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。


命令(输入 m 获取帮助):m
命令操作
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

命令(输入 m 获取帮助):n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
分区号 (3,4,默认 3):
起始 扇区 (2147483648-4294967295,默认为 2147483648):
将使用默认值 2147483648
Last 扇区, +扇区 or +size{K,M,G} (2147483648-4294967294,默认为 4294967294):
将使用默认值 4294967294
分区 3 已设置为 Linux 类型,大小设为 1024 GiB

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
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)
正在同步磁盘。

  可以看到,新的分区号是3

 

3. 对分区进行格式化,格式化后的文件系统也是xfs格式 

fdisk -l,可以看到新的分区号是3

磁盘 /dev/sda:2199.0 GB, 2199023255552 字节,4294967296 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000b948d

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200  2147483647  1072692224   8e  Linux LVM
/dev/sda3      2147483648  4294967294  1073741823+  83  Linux

磁盘 /dev/mapper/centos-root:1036.3 GB, 1036286689280 字节,2023997440 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-swap:8455 MB, 8455716864 字节,16515072 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos-home:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

 对/dev/sda3进行格式化

mkfs.xfs /dev/sda3

meta-data=/dev/sda3              isize=512    agcount=4, agsize=67108864 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=268435455, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=131071, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

  

4. 创建pv

pvcreate /dev/sda3

然后输入y

WARNING: xfs signature detected on /dev/sda3 at offset 0. Wipe it? [y/n]: y
  Wiping xfs signature on /dev/sda3.
  Physical volume "/dev/sda3" successfully created.

  

5. 处理逻辑卷

vgs

  VG     #PV #LV #SN Attr   VSize     VFree
  centos   1   3   0 wz--n- <1023.00g 4.00m

vgextend centos /dev/sda3

  Volume group "centos" successfully extended

vgs

  VG     #PV #LV #SN Attr   VSize  VFree
  centos   2   3   0 wz--n- <2.00t 1.00t

 可以看到由原来的1023G变成了2T。其中1T是空闲的

df -h 

查看要扩容的文件系统的位置 ,这是是/dev/mapper/centos-root

文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 7.8G     0  7.8G    0% /dev
tmpfs                    7.8G     0  7.8G    0% /dev/shm
tmpfs                    7.8G  8.9M  7.8G    1% /run
tmpfs                    7.8G     0  7.8G    0% /sys/fs/cgroup
/dev/mapper/centos-root  965G   85G  881G    9% /
/dev/sda1               1014M  188M  827M   19% /boot
/dev/mapper/centos-home   50G   33M   50G    1% /home
tmpfs                    1.6G     0  1.6G    0% /run/user/0

 

lvextend -l +100%free /dev/mapper/centos-root

  Size of logical volume centos/root changed from <965.12 GiB (247070 extents) to 1.94 TiB (509214 extents).
  Logical volume centos/root successfully resized.

 

 

6. 扩容,调整分区

xfs_growfs /dev/mapper/centos-root

meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=63249920 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=252999680, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=123535, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 252999680 to 521435136

 df -h

扩容成功

文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 7.8G     0  7.8G    0% /dev
tmpfs                    7.8G     0  7.8G    0% /dev/shm
tmpfs                    7.8G  8.9M  7.8G    1% /run
tmpfs                    7.8G     0  7.8G    0% /sys/fs/cgroup
/dev/mapper/centos-root  2.0T   85G  1.9T    5% /
/dev/sda1               1014M  188M  827M   19% /boot
/dev/mapper/centos-home   50G   33M   50G    1% /home
tmpfs                    1.6G     0  1.6G    0% /run/user/0

  

 

参考文档  https://blog.51cto.com/11403002/2044689 

标签:字节,centos,文件系统,dev,扇区,centos7,xfs,512,7.8
来源: https://www.cnblogs.com/zhangyy3/p/12454728.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有