Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
fuss:lvm [2020/06/08 04:15] officefuss:lvm [2024/11/23 15:12] (current) office
Line 113: Line 113:
 and LVM will take care to flush the cache to the cached logical drive before removing it. and LVM will take care to flush the cache to the cached logical drive before removing it.
  
 +====== Relocating Extents Before Resizing ======
 +
 +When attempting to resize a physical volume containing a logical volume, it may happen that an error pops up regarding extents or blocks that are allocated later ''cannot resize to 383999 extents as later ones are allocated''. Disappointingly for the current year, this happens with graphical interfaces such as ''gparted'' as well, that do not have an excuse for not automatically handling this situation because it is not difficult but rather tedious and requiring manual commands.
 +
 +The reason for that is that the actual data on the drive is not written exactly at the start of the partition or there are holes within the free space but changing the size of the PV requires that the data is laid out contiguously on the drive.
 +
 +{{fuss:fuss_lvm_relocate_extents.png?512}}
 +
 +This can be solved rather easily using ''pvmove'' and moving over the data such that there are no more holes between the written data. First, the ''pvs'' command is used to show the contiguous area of data on the drive (segments) such that they can be allocated:
 +
 +<code bash>
 +pvs -v --segments /dev/sda4
 +</code>
 +
 +Just as an example, the following data was printed in this case:
 +<code>
 +  PV         VG  Fmt  Attr PSize    PFree    Start SSize LV    Start Type   PE Ranges            
 +  /dev/sda4  vms lvm2 a--  <227.02g <177.02g     0 40960           0 free                        
 +  /dev/sda4  vms lvm2 a--  <227.02g <177.02g 40960 12800 seven     0 linear /dev/sda4:40960-53759
 +  /dev/sda4  vms lvm2 a--  <227.02g <177.02g 53760  4356           0 free                        
 +</code>
 +
 +and the interpretation is that the drive, in this case partition, ''/dev/sda4'' contains free space starting from ''0'' with a size of ''40960'', followed by actual data between ''40960'' with a size of ''12800'' and finally ending in another slice starting from ''53769'' with a size of ''4356''. What needs to be done in this case is to move the slice of data starting ''40960'' with a size of ''12800'' (namely, the logical volume ''seven'') right to the start at ''0'' with a size of ''40960''. We already know that the slice of data is of size ''12800'' which should fit perfectly starting at ''0'' with a size of ''40960''.
 +
 +Having understood the former, the command for this particular case will be:
 +<code bash>
 +pvmove --alloc anywhere /dev/sda4:40960+12800 /dev/sda4:0+40960
 +</code>
 +where:
 +  * ''/dev/sda4:40960+12800'' is the slice of data, referred to by the PVS partition, the start at ''40960'' and its length of ''12800'' and,
 +  * ''/dev/sda4:0+40960'' is the free space at the start of the drive
 +
 +This might be a length process but after it is completed, the size of the physical drive can be changed with a partition manager.
 +
 +
 + 
  
  
  

fuss/lvm.1591589732.txt.gz · Last modified: 2020/06/08 04:15 by office

Wizardry and Steamworks

© 2025 Wizardry and Steamworks

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.