[linux disk expansion root disk expansion]

Linux disk expansion – root disk expansion

Reference blog: Click to jump to the original blog

1. Operation command

partprobe /dev/vda
fdisk /dev/vda
d
n
p
Y
a
w
xfs_growfs/

2. Operation echo log

[root@master-001 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 253:0 0 200G 0 disk
└─vda1 253:1 0 10G 0 part /
vdb 253:16 0 300G 0 disk
└─vdb1 253:17 0 300G 0 part
  └─vg_data-lv_data 252:0 0 300G 0 lvm /data
[root@master-001 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 32G 0 32G 0% /dev
tmpfs tmpfs 32G 0 32G 0% /dev/shm
tmpfs tmpfs 32G 1.5M 32G 1% /run
tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/vda1 xfs 10G 7.1G 3.0G 71% /
/dev/mapper/vg_data-lv_data xfs 300G 6.1G 294G 3% /opt
overlay overlay 10G 7.1G 3.0G 71% /var/lib/docker/overlay2/6dc2f4faf4dbaf57567fe5ac077e556b9627bffbbac9ca0792140b511daa03fd/merged
*************************************************** *************************
tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/0

[root@master-001 ~]#
[root@master-001 ~]# partprobe /dev/vda
[root@master-001 ~]# fdisk /dev/vda

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m

Help:

  DOS(MBR)
   a toggle a bootable flag
   b edit nested BSD disklabel
   c toggle the dos compatibility flag

  Generic
   d delete a partition
   F list free unpartitioned space
   l list known partition types
   add a new partition
   p print the partition table
   t change a partition type
   v verify the partition table
   i print information about a partition

  Misc
   m print this menu
   u change display/entry units
   x extra functionality (experts only)

  Script
   I load disk layout from sfdisk script file
   O dump disk layout to sfdisk script file

  Save & Exit
   w write table to disk and exit
   q quit without saving changes

  Create a new label
   g create a new empty GPT partition table
   G create a new empty SGI (IRIX) partition table
   o create a new empty DOS partition table
   s create a new empty Sun partition table


Command (m for help): p
Disk /dev/vda: 200 GiB, 214748364800 bytes, 419430400 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: dos
Disk identifier: 0xab4e6aa3

Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 20971519 20969472 10G 83 Linux

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): p
Disk /dev/vda: 200 GiB, 214748364800 bytes, 419430400 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: dos
Disk identifier: 0xab4e6aa3

Command (m for help): n
Partition type
   p primary (0 primary, 0 extended, 4 free)
   e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-419430399, default 2048):
Last sector, + sectors or + size{<!-- -->K,M,G,T,P} (2048-419430399, default 419430399):

Created a new partition 1 of type 'Linux' and of size 200 GiB.
Partition #1 contains a xfs signature.

Do you want to remove the signature? [Y]es/[N]o: Y

The signature will be removed by a write command.

Command (m for help): p
Disk /dev/vda: 200 GiB, 214748364800 bytes, 419430400 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: dos
Disk identifier: 0xab4e6aa3

Device Boot Start End Sectors Size Id Type
/dev/vda1 2048 419430399 419428352 200G 83 Linux

Filesystem/RAID signature on partition 1 will be wiped.

Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.

Command (m for help): p
Disk /dev/vda: 200 GiB, 214748364800 bytes, 419430400 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: dos
Disk identifier: 0xab4e6aa3

Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 419430399 419428352 200G 83 Linux

Filesystem/RAID signature on partition 1 will be wiped.

Command (m for help): w
The partition table has been altered.
Syncing disks.

[root@master-001 ~]# xfs_growfs /
meta-data=/dev/vda1 isize=512 agcount=4, agsize=655296 blks
         = sectsz=512 attr=2, projid32bit=1
         = crc=1 finobt=1, sparse=1, rmapbt=0
         = reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=2621184, 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
data blocks changed from 2621184 to 52428544
[root@master-001 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 32G 0 32G 0% /dev
tmpfs tmpfs 32G 0 32G 0% /dev/shm
tmpfs tmpfs 32G 1.5M 32G 1% /run
tmpfs tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/vda1 xfs 200G 8.5G 192G 5% /
/dev/mapper/vg_data-lv_data xfs 300G 6.1G 294G 3% /opt
overlay overlay 200G 8.5G 192G 5% /var/lib/docker/overlay2/6dc2f4faf4dbaf57567fe5ac077e556b9627bffbbac9ca0792140b511daa03fd/merged
*************************************************** *************************
tmpfs tmpfs 6.3G 0 6.3G 0% /run/user/0
[root@master-001 ~]#