I am running a virtual server, and the provider added extra diskspace. However, I need to somehow increase (merge) the existing disk (has data) and the new disk (empty).
how to increase the size for /dev/mapper/centos-root
?
[root]#df -hFilesystem Size Used Avail Use% Mounted ondevtmpfs 3.9G 0 3.9G 0% /devtmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 3.9G 243M 3.7G 7% /runtmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup/dev/mapper/centos-root 98G 83G 16G 85% /tmpfs 3.9G 156K 3.9G 1% /tmp/dev/sda1 497M 168M 330M 34% /boottmpfs 797M 0 797M 0% /run/user/1000[root]# fdisk -lDisk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x000997be Device Boot Start End Blocks Id System/dev/sda1 * 2048 1026047 512000 83 Linux/dev/sda2 1026048 41943039 20458496 8e Linux LVM/dev/sda3 41943040 209715199 83886080 8e Linux LVMDisk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-root: 104.7 GB, 104694022144 bytes, 204480512 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
It shows a total of > 200GB, so I do have 100GB extra (unused), so I tried to grow it from the Volume Group (VG), but it indicates there is no free space. So I guess I have to somehow add the free space to the VG first? Just how?
[root]# 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 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 99.50 GiB PE Size 4.00 MiB Total PE 25473 Alloc PE / Size 25473 / 99.50 GiB Free PE / Size 0 / 0 VG UUID mlGu82-tMEl-EB1I-LdvQ-V5Jz-FmRD-7wMPdk
Below you see how the LV is divided (between SWAP and ROOT)m guess that is pretty default.
[root]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID E4q3BO-bxxu-Mj8J-nNYJ-ECdR-He20-UqTzHd LV Write Access read/write LV Creation host, time localhost, 2017-07-12 03:09:26 +0700 LV Status available # open 2 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID fANu3W-nl0g-40rQ-NLSA-I77S-4vXE-Stg2D5 LV Write Access read/write LV Creation host, time localhost, 2017-07-12 03:09:27 +0700 LV Status available # open 1 LV Size 97.50 GiB Current LE 24961 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1
Only in the CFDISK I can actually see there is free space on the same disk: sda
cfdisk (util-linux 2.23.2) Disk Drive: /dev/sda Size: 214748364800 bytes, 214.7 GB Heads: 255 Sectors per Track: 63 Cylinders: 26108 Name Flags Part Type FS Type [Label] Size (MB) ------------------------------------------------------------------------------ Pri/Log Free Space 1.05* sda1 Boot Primary xfs 524.29* sda2 Primary LVM2_member 20949.50* sda3 Primary LVM2_member 85899.35* Pri/Log Free Space 107374.19*
For Filesystems (read somewhere not all support resizing):
[root]# lsblk -fNAME FSTYPE LABEL UUID MOUNTPOINTsda├─sda1 xfs 9b1d00b3-24f5-4c0e-b84a-d6d9527d375d /boot├─sda2 LVM2_member 4rFgZ8-tAZH-8Mr0-hauE-vz9j-YCV4-3gVl3r│├─centos-swap swap 456e16d8-3c60-46b5-812a-3ae2d54f5bcf [SWAP]│└─centos-root xfs fa159170-1c29-4387-80c4-d168e2cc64c4 /└─sda3 LVM2_member c6CKfP-RP63-F107-qJ7G-0lCC-0CJZ-pOKJ4x└─centos-root xfs fa159170-1c29-4387-80c4-d168e2cc64c4 /
Also, the centos-root is referenced in the fstab:
/dev/mapper/centos-root / xfs defaults 1 1
I hope I provided enough info to make a good assessment and I really I hope I can increase the disk without data loss, otherwise I have to find a way to transfer 100GB somewhere, and then delete all, and re-create a bigger disk. I am sure there is an easier way in 2022 :)
Thanks in advance!
PS. I did read similar posts of course, but it puzzled me even more. And I am just afraid to accidently remove the existing data (even though I have a backup).