Linux磁盘扩容系统根目录

Centos7.4 磁盘卷组管理_centos未分卷组的盘有数据如何分组_若行若冲的博客-CSDN博客


 

 一、Ubuntu2004超2T-LVM磁盘扩容文件系统

root@datanode3:/home/user1# fdisk -l
Disk /dev/loop0: 55.39 MiB, 58073088 bytes, 113424 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 /dev/loop1: 69.9 MiB, 73277440 bytes, 143120 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 /dev/loop2: 31.9 MiB, 32600064 bytes, 63672 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 /dev/vda: 100 GiB, 107374182400 bytes, 209715200 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
Disklabel type: gpt
Disk identifier: 717AD41E-CB34-475E-B610-DCC13E235564

Device       Start       End   Sectors Size Type
/dev/vda1     2048      4095      2048   1M BIOS boot
/dev/vda2     4096   2101247   2097152   1G Linux filesystem
/dev/vda3  2101248 209713151 207611904  99G Linux filesystem


Disk /dev/vdb: 2.95 TiB, 3221225472000 bytes, 6291456000 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 /dev/mapper/ubuntu--vg-ubuntu--lv: 49.51 GiB, 53150220288 bytes, 103809024 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
root@datanode3:/home/user1# parted /dev/vdb
GNU Parted 3.3
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt
(parted) mkpart primary ext4 0 -1
Warning: The resulting partition is not properly aligned for best performance: 34s % 2048s != 0s
Ignore/Cancel? i                                                          
(parted) toggle 1 lvm                                                     
(parted) quit                                                             
Information: You may need to update /etc/fstab.

root@datanode3:/home/user1# partprobe
root@datanode3:/home/user1# pvcreate /dev/vdb1
  Physical volume "/dev/vdb1" successfully created.
root@datanode3:/home/user1# vgextend ubuntu-vg /dev/vdb1
  Volume group "ubuntu-vg" successfully extended

root@monitor:/home/user1# lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv 
  Size of logical volume ubuntu-vg/ubuntu-lv changed from 1.56 TiB (409145 extents) to 1.56 TiB (409342 extents).
  Logical volume ubuntu-vg/ubuntu-lv successfully resized.
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required
old_desc_blocks = 200, new_desc_blocks = 200
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 419166208 (4k) blocks long.

root@datanode3:/home/user1# df -hl
Filesystem                         Size  Used Avail Use% Mounted on
udev                                32G     0   32G   0% /dev
tmpfs                              6.3G  1.3M  6.3G   1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv  3.0T   23G  2.9T   1% /
tmpfs                               32G   72K   32G   1% /dev/shm
tmpfs                              5.0M     0  5.0M   0% /run/lock
tmpfs                               32G     0   32G   0% /sys/fs/cgroup
/dev/vda2                          976M  104M  806M  12% /boot
/dev/loop0                          56M   56M     0 100% /snap/core18/1944
/dev/loop2                          32M   32M     0 100% /snap/snapd/10707
/dev/loop1                          70M   70M     0 100% /snap/lxd/19188
tmpfs                              6.3G     0  6.3G   0% /run/user/1000
tmpfs                              6.3G     0  6.3G   0% /run/user/997
root@datanode3:/home/user1# 

二、centos79-LVM磁盘扩容文件系统

[root@mdw ~]# fdisk -l

Disk /dev/vda: 1099.5 GB, 1099511627776 bytes, 2147483648 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: dos
Disk identifier: 0x000d6c72

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     3907583     1952768   83  Linux
/dev/vda2         3907584  1048575999   522334208   8e  Linux LVM

Disk /dev/mapper/centos-root: 100.0 GB, 100000595968 bytes, 195313664 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 /dev/mapper/centos-swap: 32.0 GB, 32002539520 bytes, 62504960 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 /dev/mapper/centos-home: 402.9 GB, 402858704896 bytes, 786833408 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

[root@mdw ~]#
[root@mdw ~]# fdisk /dev/vda
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): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 回车
First sector (1048576000-2147483647, default 1048576000): 回车
Using default value 1048576000
Last sector, +sectors or +size{K,M,G} (1048576000-2147483647, default 2147483647):回车
Using default value 2147483647
Partition 3 of type Linux and of size 524 GiB is set

Command (m for help): t 设置分区号
Partition number (1-3, default 3): 回车
Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / 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 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 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 hi eb  BeOS fs
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'

Command (m for help): w 保存变更
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
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)
Syncing disks.
[root@mdw ~]# reboot
Connection to 10.11.28.2 closed by remote host.
Connection to 10.11.28.2 closed.

[root@mdw ~]#
[root@mdw ~]#
[root@mdw ~]# fdisk -l

Disk /dev/vda: 1099.5 GB, 1099511627776 bytes, 2147483648 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: dos
Disk identifier: 0x000d6c72

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     3907583     1952768   83  Linux
/dev/vda2         3907584  1048575999   522334208   8e  Linux LVM
/dev/vda3      1048576000  2147483647   549453824   8e  Linux LVM

Disk /dev/mapper/centos-root: 100.0 GB, 100000595968 bytes, 195313664 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 /dev/mapper/centos-swap: 32.0 GB, 32002539520 bytes, 62504960 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 /dev/mapper/centos-home: 402.9 GB, 402858704896 bytes, 786833408 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

[root@mdw ~]#
[root@mdw ~]#
[root@mdw ~]# pvcreate /dev/vda3 创建物理卷
  Physical volume "/dev/vda3" successfully created.
[root@mdw ~]# vgextend centos /dev/vda3  添加物理卷到卷组
  Volume group "centos" successfully extended
[root@mdw ~]# vgdisplay  查看卷组属性
  --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <1022.13 GiB
  PE Size               4.00 MiB
  Total PE              261665
  Alloc PE / Size       127521 / <498.13 GiB
  Free  PE / Size       134144 / 524.00 GiB
  VG UUID               dsDDIq-sHms-CQHk-fqqg-eOoo-evot-0nqqwm

[root@mdw ~]# lvextend -l +100%FREE /dev/mapper/centos-home  分配空闲空间到文件系统
  Size of logical volume centos/home changed from 375.19 GiB (96049 extents) to 899.19 GiB (230193 extents).
  Logical volume centos/home successfully resized.
[root@mdw ~]# xfs_growfs /dev/mapper/centos-home  扩容文件系统
meta-data=/dev/mapper/centos-home isize=512    agcount=4, agsize=24588544 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=98354176, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=48024, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 98354176 to 235717632
[root@mdw ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   94G  3.1G   91G   4% /
devtmpfs                  16G     0   16G   0% /dev
tmpfs                     16G     0   16G   0% /dev/shm
tmpfs                     16G  9.2M   16G   1% /run
tmpfs                     16G     0   16G   0% /sys/fs/cgroup
/dev/vda1                1.9G  133M  1.8G   7% /boot
/dev/mapper/centos-home  900G  110G  790G  13% /home
tmpfs                    3.2G     0  3.2G   0% /run/user/0
[root@mdw ~]#
[root@mdw ~]#
[root@mdw ~]#

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值