0

I have a Virtual Machine into Hyper-V, I just expand the VHD and the free space are showing into lsblk command, but i cant expand the lv, it's always showing has no free space.

My Configuration and Tests:

lsblk

NAME                              MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT

fd0 2:0    1     4K  0 disk
sda                                 8:0    0    51G  0 disk
├─sda1                              8:1    0   128M  0 part /boot
└─sda2                              8:2    0  49.9G  0 part
  ├─vg00-lv_raiz (dm-0)           252:0    0   6.1G  0 lvm  /
  ├─vg00-lv_swap1 (dm-1)          252:1    0     4G  0 lvm  [SWAP]
  ├─vg00-lv_var (dm-2)            252:2    0   6.1G  0 lvm  /var
  ├─vg00-lv_opt (dm-3)  [1]          252:3    0     3G  0 lvm  /opt
  ├─vg00-lv_u01 (dm-4)            252:4    0     6G  0 lvm  /u01
  └─vg00-lv_oracle_oradata (dm-5) 252:5    0 344.7G  0 lvm  /oracle/oradata
sdb                                 8:16   0   210G  0 disk /oracle/archive
sdc                                 8:32   0    40G  0 disk /oracle
sdd                                 8:48   0   500G  0 disk
└─sdd1                              8:49   0   320G  0 part
  └─vg00-lv_oracle_oradata (dm-5) 252:5    0 344.7G  0 lvm  /oracle/oradata

Look, the SDD have 500GB and I need to extend all free Space to LV lv_oracle_oradata that have only 344GB

[root@dbmega oracle 21:57:50]# df -h
Filesystem                          Size  Used Avail Use% Mounted on
/dev/mapper/vg00-lv_raiz            5.9G  1.7G  3.9G  31% /
tmpfs                                24G     0   24G   0% /dev/shm
/dev/sda1                           124M   52M   67M  44% /boot
/dev/mapper/vg00-lv_opt             2.9G  5.8M  2.8G   1% /opt
/dev/mapper/vg00-lv_u01             5.8G  2.5G  3.0G  46% /u01
/dev/sdc                             35G   23G   11G  69% /oracle
/dev/mapper/vg00-lv_var             5.9G  1.3G  4.4G  23% /var
/dev/sdb                            197G   75G  113G  41% /oracle/archive
//10.10.10.2/Backup_Oracle        3.7T  994G  2.7T  27% /oracle/backup
/dev/mapper/vg00-lv_oracle_oradata  340G  317G  5.3G  99% /oracle/oradata

When I try to lvextend with

[root@dbmega oracle 22:03:32]# lvresize -L +1GB /dev/mapper/vg00-lv_oracle_oradata
  Extending logical volume lv_oracle_oradata to 345.69 GiB
  Insufficient free space: 32 extents needed, but only 0 available

How can I extend this without lose any data, some articles telling to delete the partition.

Nikita Kipriyanov
  • 10,947
  • 2
  • 24
  • 45

1 Answers1

1

Yes, your sdd is 500G, but the LVM PV partition on it has a size of 320G. This means, you have a unallocated space, but it is not available to LVM at the time. Before running lvresize, you really need to make this space available.

Always look to vgs, pvs and lvs to see the LVM state, in particular, how much space is available and so on. If you run it before making changes, you'll see that your VG really doesn't have enough space to enlarge a volume. (These commands will output a brief informaion; a more verbose output is given by vgdisplay, pvdisplay and lvdisplay.)


First way is to enlarge the partition. With fdisk, you should remove this partition and create larger one on its former place. Look carefully starting sector of the create partition is exactly the same, and if it asks about signature found, answer "no" (don't wipe). Alternatively, you can use growpart for that. Both variants were described here many times, search for an information how to resize a partition without losing its data. This may require a host reboot. When you have a 320G PV on the 500G partition, you may proceed with pvresize /dev/sdd1.


Alternatively, you can just create an additional partition sdd2 on the free space, make LVM labels on it with pvcreate /dev/sdd2, and add it to the LVM with vgextend vg00 /dev/sdd2.


Both ways will add the missing 180G to the VG, but first may require reboot and it's generally harder, while second way is certainly online and easier, but leaves a disk in a bit dirtier state (two LVM PV partitions both members of the same VG).

Now you may run lvresize. Don't forget resize2fs or whatever your filesystem tool is to make filesystem to fill the volume!

Nikita Kipriyanov
  • 10,947
  • 2
  • 24
  • 45