描述: 17G 扩充到 30G

代码:

1. df -h

[root@k8s-master test]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   17G   16G  1.2G   93% /
devtmpfs                 1.9G     0  1.9G    0% /dev
tmpfs                    1.9G     0  1.9G    0% /dev/shm
tmpfs                    1.9G   20M  1.9G    2% /run
tmpfs                    1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sda1               1014M  177M  838M   18% /boot
overlay                   17G   16G  1.2G   93% /var/lib/docker/overlay2/fa7262db9c9492000b5bc7d14d1ccdb11089b50a289ea1a8516804ef93ab97b1/merged
overlay                   17G   16G  1.2G   93% /var/lib/docker/overlay2/dcd3422a1eed0c46abc26ee2063ecdc5623a6cbaff36130b32db43d013f192b0/merged
overlay                   17G   16G  1.2G   93% /var/lib/docker/overlay2/cdb10799373218bcb0a1babd022b58db71e4f3aac385c6574312a0a4a512c932/merged
shm                       64M  4.0K   64M    1% /var/lib/docker/containers/3169bb04e4f5676ec6c43ab3dfb2bf8e8bdfe11155bb9abe746de35b3a4288f8/mounts/shm
shm                       64M     0   64M    0% /var/lib/docker/containers/cd65be734d193aabbf9cf102a9d845dd44733c0f3dcf007978dfe0f2991e7d57/mounts/shm
shm                       64M     0   64M    0% /var/lib/docker/containers/a1bd44d56ec9e6bccf13025fa0c15b86efa23fae75fe96147f8e53f924983214/mounts/shm
tmpfs                    378M     0  378M    0% /run/user/0
overlay                   17G   16G  1.2G   93% /var/lib/docker/overlay2/5044a45c4531e5d867a42db17ebd5c8af668c5e24154ebde2495fcdcc6f91ba1/merged
shm                       64M     0   64M    0% /var/lib/docker/containers/3f7e59e9e4a580dce85d69acc06a976a47ec67e2a266aed15167f3cdcefe3531/mounts/shm
overlay                   17G   16G  1.2G   93% /var/lib/docker/overlay2/572ebc9871780f7943e8ec28d10bbfffe425dcac75a914ff4d43120b7033664c/merged
shm                       64M     0   64M    0% /var/lib/docker/containers/2590e473b1d8a8ba96df6385268903fdc8441d24bd54a0f5cf748cd723845d0d/mounts/shm
overlay                   17G   16G  1.2G   93% /var/lib/docker/overlay2/25da6c12e0ec29d72a647ca1041e311c247bc31b6d552f64e39face5441b044b/merged
shm                       64M     0   64M    0% /var/lib/docker/containers/f4884c5afdc613aebcb982ae91bd1ad6774c5433f80b1adf706abcd9ebba0d6b/mounts/shm


2. fdisk /dev/sda

[root@k8s-master test]# fdisk /dev/sda
欢迎使用 fdisk (util-linux 2.23.2)。

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


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

命令(输入 m 获取帮助):t
分区号 (1-3,默认 3):
Hex 代码(输入 L 列出所有代码):
Hex 代码(输入 L 列出所有代码):L

 0  空              24  NEC DOS         81  Minix / 旧 Linu bf  Solaris        
 1  FAT12           27  隐藏的 NTFS Win 82  Linux 交换 / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 隐藏的 C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux 扩展      c7  Syrinx         
 5  扩展            41  PPC PReP Boot   86  NTFS 卷集       da  非文件系统数据 
 6  FAT16           42  SFS             87  NTFS 卷集       db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux 纯文本    de  Dell 工具      
 8  AIX             4e  QNX4.x 第2部分  8e  Linux LVM       df  BootIt         
 9  AIX 可启动      4f  QNX4.x 第3部分  93  Amoeba          e1  DOS 访问       
 a  OS/2 启动管理器 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad 休 eb  BeOS fs        
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT            
 f  W95 扩展 (LBA)  54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC  
11  隐藏的 FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor      
12  Compaq 诊断     5c  Priam Edisk     a9  NetBSD          f4  SpeedStor      
14  隐藏的 FAT16 <3 61  SpeedStor       ab  Darwin 启动     f2  DOS 次要       
16  隐藏的 FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS    
17  隐藏的 HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE 
18  AST 智能睡眠    65  Novell Netware  b8  BSDI swap       fd  Linux raid 自动
1b  隐藏的 W95 FAT3 70  DiskSecure 多启 bb  Boot Wizard 隐  fe  LANstep        
1c  隐藏的 W95 FAT3 75  PC/IX           be  Solaris 启动    ff  BBT            
1e  隐藏的 W95 FAT1 80  旧 Minix       
Hex 代码(输入 L 列出所有代码):8e
已将分区“Linux”的类型更改为“Linux LVM”

命令(输入 m 获取帮助):p

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

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    41943039    19921920   8e  Linux LVM
/dev/sda3        41943040    62914559    10485760   8e  Linux LVM

命令(输入 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. df -T /dev/sda1

[root@k8s-master test]# df -T /dev/sda1
文件系统       类型   1K-块   已用   可用 已用% 挂载点
/dev/sda1      xfs  1038336 180268 858068   18% /boot
[root@k8s-master test]# mkfs.xfs /dev/sda3
/dev/sda3: 没有那个文件或目录
Usage: mkfs.xfs
/* blocksize */         [-b log=n|size=num]
/* metadata */          [-m crc=0|1,finobt=0|1,uuid=xxx]
/* data subvol */       [-d agcount=n,agsize=n,file,name=xxx,size=num,
                            (sunit=value,swidth=value|su=num,sw=num|noalign),
                            sectlog=n|sectsize=num
/* force overwrite */   [-f]
/* inode size */        [-i log=n|perblock=n|size=num,maxpct=n,attr=0|1|2,
                            projid32bit=0|1]
/* no discard */        [-K]
/* log subvol */        [-l agnum=n,internal,size=num,logdev=xxx,version=n
                            sunit=value|su=num,sectlog=n|sectsize=num,
                            lazy-count=0|1]
/* label */             [-L label (maximum 12 characters)]
/* naming */            [-n log=n|size=num,version=2|ci,ftype=0|1]
/* no-op info only */   [-N]
/* prototype file */    [-p fname]
/* quiet */             [-q]
/* realtime subvol */   [-r extsize=num,size=num,rtdev=xxx]
/* sectorsize */        [-s log=n|size=num]
/* version */           [-V]
                        devicename
<devicename> is required unless -d name=xxx is given.
<num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),
      xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).
<value> is xxx (512 byte blocks).
[root@k8s-master test]# df -T /dev/sda3
df: "/dev/sda3": 没有那个文件或目录
[root@k8s-master test]# df -T /dev/sda2
文件系统       类型       1K-块  已用    可用 已用% 挂载点
devtmpfs       devtmpfs 1918732     0 1918732    0% /dev
[root@k8s-master test]# reboot

Last login: Sat Dec 21 14:18:46 2019
[root@k8s-master ~]# df -T /dev/sda3
文件系统       类型       1K-块  已用    可用 已用% 挂载点
devtmpfs       devtmpfs 1918728     0 1918728    0% /dev
[root@k8s-master ~]# df -T /dev/sda2
文件系统       类型       1K-块  已用    可用 已用% 挂载点
devtmpfs       devtmpfs 1918728     0 1918728    0% /dev

4. mkfs.xfs /dev/sda3

[root@k8s-master ~]# mkfs.xfs /dev/sda3
meta-data=/dev/sda3              isize=512    agcount=4, agsize=655360 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=2621440, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@k8s-master ~]# df -T /dev/sda3
文件系统       类型       1K-块  已用    可用 已用% 挂载点
devtmpfs       devtmpfs 1918728     0 1918728    0% /dev
[root@k8s-master ~]# df -T /dev/sda1
文件系统       类型   1K-块   已用   可用 已用% 挂载点
/dev/sda1      xfs  1038336 180268 858068   18% /boot

5. pvcreate /dev/sda3

[root@k8s-master ~]# pvcreate /dev/sda3
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.
[root@k8s-master ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               <19.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              4863
  Free PE               0
  Allocated PE          4863
  PV UUID               XJkHLv-d8Zs-uEGQ-cAXp-67Yj-0Nf5-ZjnKcY
   
  "/dev/sda3" is a new physical volume of "10.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sda3
  VG Name               
  PV Size               10.00 GiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               xnskSP-Vbjo-7OIz-V6hz-WRQd-J3qo-uMeTv2
   

6. vgextend centos /dev/sda3

   
[root@k8s-master ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <19.00 GiB
  PE Size               4.00 MiB
  Total PE              4863
  Alloc PE / Size       4863 / <19.00 GiB
  Free  PE / Size       0 / 0   
  VG UUID               c6W3yP-XGmu-md4W-DHFq-9eVz-BVs1-Wh7tbB
   
[root@k8s-master ~]# vgextend centos /dev/sda3
  Volume group "centos" successfully extended
[root@k8s-master ~]# vgdisplay
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               28.99 GiB
  PE Size               4.00 MiB
  Total PE              7422
  Alloc PE / Size       4863 / <19.00 GiB
  Free  PE / Size       2559 / <10.00 GiB
  VG UUID               c6W3yP-XGmu-md4W-DHFq-9eVz-BVs1-Wh7tbB

7. lvextend /dev/centos/root /dev/sda3

[root@k8s-master ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                trolaW-Z94e-5hxf-QzXS-a49B-fmoZ-Kin4Ac
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-07-30 19:54:38 +0800
  LV Status              available
  # open                 0
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                2lwKo1-cl3H-Xszz-jGLw-crqu-A7JQ-ACllX3
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-07-30 19:54:38 +0800
  LV Status              available
  # open                 1
  LV Size                <17.00 GiB
  Current LE             4351
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
[root@k8s-master ~]# lvextend /dev/centos/root /dev/sda3
  Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to 26.99 GiB (6910 extents).
  Logical volume centos/root successfully resized.
[root@k8s-master ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=1113856 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=4455424, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 4455424 to 7075840
[root@k8s-master ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   27G   16G   12G   59% /
devtmpfs                 1.9G     0  1.9G    0% /dev
tmpfs                    1.9G     0  1.9G    0% /dev/shm
tmpfs                    1.9G   12M  1.9G    1% /run
tmpfs                    1.9G     0  1.9G    0% /sys/fs/cgroup
/dev/sda1               1014M  177M  838M   18% /boot
overlay                   27G   16G   12G   59% /var/lib/docker/overlay2/fa7262db9c9492000b5bc7d14d1ccdb11089b50a289ea1a8516804ef93ab97b1/merged
overlay                   27G   16G   12G   59% /var/lib/docker/overlay2/dcd3422a1eed0c46abc26ee2063ecdc5623a6cbaff36130b32db43d013f192b0/merged
shm                       64M     0   64M    0% /var/lib/docker/containers/a1bd44d56ec9e6bccf13025fa0c15b86efa23fae75fe96147f8e53f924983214/mounts/shm
shm                       64M     0   64M    0% /var/lib/docker/containers/cd65be734d193aabbf9cf102a9d845dd44733c0f3dcf007978dfe0f2991e7d57/mounts/shm
tmpfs                    378M     0  378M    0% /run/user/0
overlay                   27G   16G   12G   59% /var/lib/docker/overlay2/572ebc9871780f7943e8ec28d10bbfffe425dcac75a914ff4d43120b7033664c/merged
shm                       64M     0   64M    0% /var/lib/docker/containers/2590e473b1d8a8ba96df6385268903fdc8441d24bd54a0f5cf748cd723845d0d/mounts/shm

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐