In my CentOS 7 server, there is one disk and one partition (sda, sda1) . now it is full, i asked from server provider to add new disk (sdb) then i created a partition sdb1 with LVM type . how can i merge sda1 and sdb1 without loosing data or boot corruption ?
fdisk -l output :
Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000ab236 Device Boot Start End Blocks Id System /dev/sda1 * 2048 83886079 41942016 83 Linux Disk /dev/sdb: 32.2 GB, 32212254720 bytes, 62914560 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: 0x09a86f50 Device Boot Start End Blocks Id System /dev/sdb1 2048 62914559 31456256 8e Linux LVM df -h output :
Filesystem Size Used Avail Use% Mounted on devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 188M 1.7G 10% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 40G 40G 623M 99% / tmpfs 381M 0 381M 0% /run/user/54321 tmpfs 381M 0 381M 0% /run/user/0 11 Answer
You can use vgextend to extent the volume group and lvextend to extend the existing logical volume. Assuming that sdb1 is already created as LWM:
# pvcreate <<newly created partition>>, or in our case pvcreate /dev/sdb1 # Listing of curent volume group. # We will use later VG Name - so remember it somewhere (or copy-paste) vgdisplay # vgextend <<VG Name>> <<newly created partition>>, or in our case vgextend cl_centos7 /dev/sdb1 # Scanning for psychical volumes (please notice our with 120GB) pvscan # Listing of logical volumes. # We want to extend this with name root and important info for us is LV path lvdisplay # Logical volume extending # lvextend <<LV path>> <<newly created partition>>, or in our case lvextend /dev/cl_centos7/root /dev/sdb1 # Logical volume extending for free space which we added by new disk # resize2fs <<LV path>>, or in our case resize2fs /dev/cl_centos7/root Alternatively instead of 2 last commands you could use which extends the existing ДМ path to 100% of disk space:
# lvextend -l +100%FREE /dev/cl_centos7/root 1 