龙空技术网

CENTOS7系统扩容(现有分区扩容)

zdhwl 56

前言:

此时看官们对“centos硬盘扩展分区”大约比较看重,大家都想要学习一些“centos硬盘扩展分区”的相关内容。那么小编同时在网上收集了一些关于“centos硬盘扩展分区””的相关内容,希望同学们能喜欢,各位老铁们一起来了解一下吧!

扩容前的占用情况

扩容增加四块硬盘

一块960g没做RAID,挂载/dev/sdb

两块960g做了RAID1,挂载/dev/sdc

一块600g没做RAID,挂载/dev/sdd

初步规划给sdc划分到 /home 目录,给sdb和sdd划分给 / (根目录)

首先给sdc分区 fdisk /dev/sdc

新建分区 n

打印分区表 p (默认)

分区编号 1 (默认)

分区开始扇区 (默认)

分区结束扇区 (默认)

保存 w

因为整块硬盘只建立一个问去所以起始都按默认

为分区创建物理卷 pvcreate /dev/sbc1

pvs 输出物理卷信息报表

将sdc1添加到centos卷 vgextend centos /dev/sdc1

将卷组100%容量分配到 /home 目录 lvextend -l +100%FREE /dev/centos/home

更新下 xfs_growfs /dev/centos/home

查看下目前分区

同理操作另外两块硬盘

[root@localhost data]# fdisk /dev/sdb欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。Device does not contain a recognized partition table使用磁盘标识符 0xd7d38946 创建新的 DOS 磁盘标签。The device presents a logical sector size that is smaller thanthe physical sector size. Aligning to a physical sector (or optimalI/O) size boundary is recommended, or performance may be impacted.命令(输入 m 获取帮助):nPartition type:   p   primary (0 primary, 0 extended, 4 free)   e   extendedSelect (default p): Using default response p分区号 (1-4,默认 1):起始 扇区 (2048-1875385007,默认为 2048):将使用默认值 2048Last 扇区, +扇区 or +size{K,M,G} (2048-1875385007,默认为 1875385007):将使用默认值 1875385007分区 1 已设置为 Linux 类型,大小设为 894.3 GiB命令(输入 m 获取帮助):wThe partition table has been altered!Calling ioctl() to re-read partition table.正在同步磁盘。[root@localhost data]# pvcreate /dev/sdb1  Physical volume "/dev/sdb1" successfully created.[root@localhost data]# pvs  PV         VG     Fmt  Attr PSize    PFree    /dev/sda3  centos lvm2 a--  <222.31g      0   /dev/sdb1         lvm2 ---   894.25g 894.25g  /dev/sdc1  centos lvm2 a--  <893.75g      0 [root@localhost data]# vgextend centos /dev/sdb1  Volume group "centos" successfully extended[root@localhost data]# lvextend -l +100%FREE /dev/centos/root  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 944.25 GiB (241728 extents).  Logical volume centos/root successfully resized.[root@localhost data]# xfs_growfs /dev/centos/rootmeta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3276800 blks         =                       sectsz=4096  attr=2, projid32bit=1         =                       crc=1        finobt=0 spinodes=0data     =                       bsize=4096   blocks=13107200, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal               bsize=4096   blocks=6400, version=2         =                       sectsz=4096  sunit=1 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0data blocks changed from 13107200 to 247529472[root@localhost data]# df -h文件系统                 容量  已用  可用 已用% 挂载点devtmpfs                  63G     0   63G    0% /devtmpfs                     63G     0   63G    0% /dev/shmtmpfs                     63G  4.1G   59G    7% /runtmpfs                     63G     0   63G    0% /sys/fs/cgroup/dev/mapper/centos-root  945G   42G  904G    5% //dev/sda2               1014M  170M  845M   17% /boot/dev/sda1                200M   12M  189M    6% /boot/efi/dev/mapper/centos-home  1.1T   32G  1.1T    3% /hometmpfs                     13G   52K   13G    1% /run/user/1000tmpfs                     13G   64K   13G    1% /run/user/0/dev/loop0               9.5G  9.5G     0  100% /mnt/yumoverlay                  945G   42G  904G    5% /var/lib/docker/overlay2/c6d7508c158d403889a316b54399859839cc0ffd58668f9ed961f45fc1bcd4f4/mergedshm                       64M   16K   64M    1% /var/lib/docker/containers/69c60e2b7825a32846fb82740bbf06955630fd5657bbc511392ccbd1dfb054c6/mounts/shm[root@localhost data]# fdisk -lWARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.磁盘 /dev/sda:240.0 GB, 239990276096 字节,468731008 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 4096 字节I/O 大小(最小/最佳):4096 字节 / 4096 字节磁盘标签类型:gptDisk identifier: F661ED7A-B842-464C-ACA3-FABDB0533A05#         Start          End    Size  Type            Name 1         2048       411647    200M  EFI System      EFI System Partition 2       411648      2508799      1G  Microsoft basic  3      2508800    468729855  222.3G  Linux LVM       磁盘 /dev/mapper/centos-root:1013.9 GB, 1013880717312 字节,1980235776 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 4096 字节I/O 大小(最小/最佳):4096 字节 / 4096 字节磁盘 /dev/mapper/centos-swap:4294 MB, 4294967296 字节,8388608 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 4096 字节I/O 大小(最小/最佳):4096 字节 / 4096 字节磁盘 /dev/mapper/centos-home:1140.4 GB, 1140372537344 字节,2227290112 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 4096 字节I/O 大小(最小/最佳):262144 字节 / 262144 字节磁盘 /dev/loop0:10.2 GB, 10200547328 字节,19922944 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x6b8b4567      设备 Boot      Start         End      Blocks   Id  System/dev/loop0p1   *           0    19922943     9961472    0  Empty/dev/loop0p2            5724       23323        8800   ef  EFI (FAT-12/16/32)磁盘 /dev/sdb:960.2 GB, 960197124096 字节,1875385008 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 4096 字节I/O 大小(最小/最佳):4096 字节 / 4096 字节磁盘标签类型:dos磁盘标识符:0xd7d38946   设备 Boot      Start         End      Blocks   Id  System/dev/sdb1            2048  1875385007   937691480   83  Linux磁盘 /dev/sdc:959.7 GB, 959656755200 字节,1874329600 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):262144 字节 / 262144 字节磁盘标签类型:dos磁盘标识符:0x325934ec   设备 Boot      Start         End      Blocks   Id  System/dev/sdc1            2048  1874329599   937163776   83  Linux磁盘 /dev/sdd:600.1 GB, 600127266816 字节,1172123568 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节[root@localhost data]# fdisk /dev/sdd欢迎使用 fdisk (util-linux 2.23.2)。更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。Device does not contain a recognized partition table使用磁盘标识符 0x8f09ef63 创建新的 DOS 磁盘标签。命令(输入 m 获取帮助):nPartition type:   p   primary (0 primary, 0 extended, 4 free)   e   extendedSelect (default p): Using default response p分区号 (1-4,默认 1):起始 扇区 (2048-1172123567,默认为 2048):将使用默认值 2048Last 扇区, +扇区 or +size{K,M,G} (2048-1172123567,默认为 1172123567):将使用默认值 1172123567分区 1 已设置为 Linux 类型,大小设为 558.9 GiB命令(输入 m 获取帮助):wThe partition table has been altered!Calling ioctl() to re-read partition table.正在同步磁盘。[root@localhost data]# pvcreate /dev/sdd1  Physical volume "/dev/sdd1" successfully created.[root@localhost data]# pvs  PV         VG     Fmt  Attr PSize    PFree    /dev/sda3  centos lvm2 a--  <222.31g      0   /dev/sdb1  centos lvm2 a--   894.25g      0   /dev/sdc1  centos lvm2 a--  <893.75g      0   /dev/sdd1         lvm2 ---   558.91g 558.91g[root@localhost data]# vgextend centos /dev/sdd1  Volume group "centos" successfully extended[root@localhost data]# pvs  PV         VG     Fmt  Attr PSize    PFree     /dev/sda3  centos lvm2 a--  <222.31g       0   /dev/sdb1  centos lvm2 a--   894.25g       0   /dev/sdc1  centos lvm2 a--  <893.75g       0   /dev/sdd1  centos lvm2 a--  <558.91g <558.91g[root@localhost data]# lvextend -l +100%FREE /dev/centos/root  Size of logical volume centos/root changed from 944.25 GiB (241728 extents) to <1.47 TiB (384808 extents).  Logical volume centos/root successfully resized.[root@localhost data]# xfs_growfs /dev/centos/rootmeta-data=/dev/mapper/centos-root isize=512    agcount=76, agsize=3276800 blks         =                       sectsz=4096  attr=2, projid32bit=1         =                       crc=1        finobt=0 spinodes=0data     =                       bsize=4096   blocks=247529472, imaxpct=25         =                       sunit=0      swidth=0 blksnaming   =version 2              bsize=4096   ascii-ci=0 ftype=1log      =internal               bsize=4096   blocks=6400, version=2         =                       sectsz=4096  sunit=1 blks, lazy-count=1realtime =none                   extsz=4096   blocks=0, rtextents=0data blocks changed from 247529472 to 394043392[root@localhost data]# df -h文件系统                 容量  已用  可用 已用% 挂载点devtmpfs                  63G     0   63G    0% /devtmpfs                     63G     0   63G    0% /dev/shmtmpfs                     63G  4.1G   59G    7% /runtmpfs                     63G     0   63G    0% /sys/fs/cgroup/dev/mapper/centos-root  1.5T   42G  1.5T    3% //dev/sda2               1014M  170M  845M   17% /boot/dev/sda1                200M   12M  189M    6% /boot/efi/dev/mapper/centos-home  1.1T   32G  1.1T    3% /hometmpfs                     13G   52K   13G    1% /run/user/1000tmpfs                     13G   64K   13G    1% /run/user/0/dev/loop0               9.5G  9.5G     0  100% /mnt/yumoverlay                  1.5T   42G  1.5T    3% /var/lib/docker/overlay2/c6d7508c158d403889a316b54399859839cc0ffd58668f9ed961f45fc1bcd4f4/mergedshm                       64M   16K   64M    1% /var/lib/docker/containers/69c60e2b7825a32846fb82740bbf06955630fd5657bbc511392ccbd1dfb054c6/mounts/shm

标签: #centos硬盘扩展分区 #centosbiosboot分区