This manual is for general reference only.
Some environment may be different from this article, you may need a little adjustment for your own environment.
Before adding extra disk space, confirm current disk configuration.
1. Confirm current disk usage.
[root@18 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 907M 0 907M 0% /dev
tmpfs 920M 0 920M 0% /dev/shm
tmpfs 920M 8.9M 911M 1% /run
tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 3.4G 47G 7% /
/dev/sda1 497M 171M 327M 35% /boot
tmpfs 184M 0 184M 0% /run/user/0
[root@18 ~]#
2. Confirm current disk size (This sample has 53.7GB of total disk space)
[root@18 ~]# fdisk -l Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x00096f86 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 104857599 51915776 8e Linux LVM Disk /dev/mapper/centos-root: 53.2 GB, 53158608896 bytes, 103825408 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@18 ~]#
This example, we are going to add +30GB (unformatted) of disk capacity.
In order to complete, you need to "format" 30GB disk and "extend" 30GB into existing partition.
3. Notice your disk size has changed from 53.7GB to 85.9GB (+30GB) .
In general (by default), /dev/sda2 will be a primary partition for centOS7 environment and most of disk shortage will occur at /dev/sda2. Thus, we will exlain how to add extra disk for /dev/sda2 partition.
[root@18 ~]# fdisk -l Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 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: 0x00096f86 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 104857599 51915776 8e Linux LVM Disk /dev/mapper/centos-root: 53.2 GB, 53158608896 bytes, 103825408 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@18 ~]#
4. please follow below step (Command) to configure disk.
[root@18 ~]# [root@18 ~]# fdisk /dev/sda 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): p Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 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: 0x00096f86 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 104857599 51915776 8e Linux LVM 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 (104857600-167772159, default 104857600): Using default value 104857600 Last sector, +sectors or +size{K,M,G} (104857600-167772159, default 167772159): Using default value 167772159 Partition 3 of type Linux and of size 30 GiB is set Command (m for help): p Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 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: 0x00096f86 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 104857599 51915776 8e Linux LVM /dev/sda3 104857600 167772159 31457280 83 Linux 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): p Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 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: 0x00096f86 Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 104857599 51915776 8e Linux LVM /dev/sda3 104857600 167772159 31457280 8e 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@18 ~]#
5. reboot OS
Check to confirm disk size (If total size is not changed... go to next step)
[root@18 ~]# [root@18 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 907M 0 907M 0% /dev tmpfs 920M 0 920M 0% /dev/shm tmpfs 920M 8.9M 911M 1% /run tmpfs 920M 0 920M 0% /sys/fs/cgroup /dev/mapper/centos-root 50G 3.4G 47G 7% / /dev/sda1 497M 171M 327M 35% /boot tmpfs 184M 0 184M 0% /run/user/0 [root@18 ~]#
6. Follow this command to extend disk space.
[root@18 ~]# vgdisplay -C VG #PV #LV #SN Attr VSize VFree centos 1 1 0 wz--n- <49.51g 0 [root@18 ~]# [root@18 ~]# vgextend centos /dev/sda3 Physical volume "/dev/sda3" successfully created. Volume group "centos" successfully extended [root@18 ~]# [root@18 ~]# vgdisplay -C VG #PV #LV #SN Attr VSize VFree centos 2 1 0 wz--n- 79.50g <30.00g [root@18 ~]# [root@18 ~]# [root@18 ~]# df Filesystem 1K-blocks Used Available Use% Mounted on devtmpfs 928524 0 928524 0% /dev tmpfs 941096 0 941096 0% /dev/shm tmpfs 941096 9000 932096 1% /run tmpfs 941096 0 941096 0% /sys/fs/cgroup /dev/mapper/centos-root 51887356 3546060 48341296 7% / /dev/sda1 508588 174728 333860 35% /boot tmpfs 188220 0 188220 0% /run/user/0 [root@18 ~]# [root@18 ~]# [root@18 ~]# [root@18 ~]# lvextend -l +100%FREE /dev/centos/root Size of logical volume centos/root changed from <49.51 GiB (12674 extents) to 79.50 GiB (20353 extents). Logical volume centos/root successfully resized. [root@18 ~]# [root@18 ~]# [root@18 ~]# xfs_growfs /dev/mapper/centos-root meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=3244544 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 spinodes=0 data = bsize=4096 blocks=12978176, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=6337, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 12978176 to 20841472 [root@18 ~]#
[root@18 ~]# [root@18 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 907M 0 907M 0% /dev tmpfs 920M 0 920M 0% /dev/shm tmpfs 920M 8.8M 911M 1% /run tmpfs 920M 0 920M 0% /sys/fs/cgroup /dev/mapper/centos-root 80G 3.4G 77G 5% / /dev/sda1 497M 171M 327M 35% /boot tmpfs 184M 0 184M 0% /run/user/0 [root@18 ~]#
[root@18 ~]#
[root@18 ~]#
END
Comments
0 comments
Article is closed for comments.