Partitioning existing LVM physical volume and Create new LVM physical volume

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












My goal is to create new LVM physical volume named sda3.
I installed the Centos 7.5 in such partitioning:



 Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 468877311 233389056 8e Linux LVM

Disk /dev/mapper/centos-root: 222.9 GB, 222885314560 bytes, 435322880 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 /dev/mapper/centos-swap: 10.7 GB, 10733223936 bytes, 20963328 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 /dev/mapper/centos-home: 5368 MB, 5368709120 bytes, 10485760 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


Actually, I have 3 partitions, swap, home and root which the OS is installed on the root partition. I tried to create a new LVM physical volume using the command pvcreate but it errors:



Device /dev/sda3 not found.


and when I tried /dev/sda2 it says:



Can't open /dev/sda2 exclusively. Mounted filesystem?


So I guess I should do the following steps to create a new LVM physical volume:



  1. Repartition(resize) the sda2 and create a new partition named sda3

  2. Unmount sda3 and now I can create a new LVM physical volume from sda3

The question is how can I resize the root(sda2) to make space for new partition sda3 while the OS is installed on the sda2?



In the following, I add some related command outputs.



Here is the output of the command lvmdiskscan



 /dev/centos/root [ <207.58 GiB] 
/dev/sda1 [ 1.00 GiB]
/dev/centos/swap [ <10.00 GiB]
/dev/sda2 [ <222.58 GiB] LVM physical volume
/dev/centos/home [ 5.00 GiB]
3 disks
1 partition
0 LVM physical volume whole disks
1 LVM physical volume


and here is the output of lsblk command:



sda 8:0 0 465.8G 0 disk 
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 464.8G 0 part
├─centos-root 253:0 0 451.9G 0 lvm /
├─centos-swap 253:1 0 7.9G 0 lvm [SWAP]
└─centos-home 253:2 0 5G 0 lvm /home


The lvs command:



 LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- 5.00g
root centos -wi-ao---- <207.58g
swap centos -wi-ao---- <10.00g


The vgs command:



VG #PV #LV #SN Attr VSize VFree
centos 1 3 0 wz--n- 222.57g 0


The pvs command:



PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 222.57g 0









share|improve this question























  • Why would you want to create another physical volume (PV)?
    – roaima
    Nov 26 at 8:11











  • I want to use it as the OpenStack Cinder volume group. I tried sda2 but it was mounted (running the OS)
    – Soheil Pourbafrani
    Nov 26 at 8:14










  • Kindly add the output of lvs vgs and pvs command.
    – erTugRul
    Nov 27 at 6:36










  • @erTugRul has been Added.
    – Soheil Pourbafrani
    Nov 27 at 6:41










  • Forgot to ask you to show the output of df -Th. My bad. Kindly add that one also
    – erTugRul
    Nov 27 at 7:17














up vote
0
down vote

favorite












My goal is to create new LVM physical volume named sda3.
I installed the Centos 7.5 in such partitioning:



 Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 468877311 233389056 8e Linux LVM

Disk /dev/mapper/centos-root: 222.9 GB, 222885314560 bytes, 435322880 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 /dev/mapper/centos-swap: 10.7 GB, 10733223936 bytes, 20963328 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 /dev/mapper/centos-home: 5368 MB, 5368709120 bytes, 10485760 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


Actually, I have 3 partitions, swap, home and root which the OS is installed on the root partition. I tried to create a new LVM physical volume using the command pvcreate but it errors:



Device /dev/sda3 not found.


and when I tried /dev/sda2 it says:



Can't open /dev/sda2 exclusively. Mounted filesystem?


So I guess I should do the following steps to create a new LVM physical volume:



  1. Repartition(resize) the sda2 and create a new partition named sda3

  2. Unmount sda3 and now I can create a new LVM physical volume from sda3

The question is how can I resize the root(sda2) to make space for new partition sda3 while the OS is installed on the sda2?



In the following, I add some related command outputs.



Here is the output of the command lvmdiskscan



 /dev/centos/root [ <207.58 GiB] 
/dev/sda1 [ 1.00 GiB]
/dev/centos/swap [ <10.00 GiB]
/dev/sda2 [ <222.58 GiB] LVM physical volume
/dev/centos/home [ 5.00 GiB]
3 disks
1 partition
0 LVM physical volume whole disks
1 LVM physical volume


and here is the output of lsblk command:



sda 8:0 0 465.8G 0 disk 
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 464.8G 0 part
├─centos-root 253:0 0 451.9G 0 lvm /
├─centos-swap 253:1 0 7.9G 0 lvm [SWAP]
└─centos-home 253:2 0 5G 0 lvm /home


The lvs command:



 LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- 5.00g
root centos -wi-ao---- <207.58g
swap centos -wi-ao---- <10.00g


The vgs command:



VG #PV #LV #SN Attr VSize VFree
centos 1 3 0 wz--n- 222.57g 0


The pvs command:



PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 222.57g 0









share|improve this question























  • Why would you want to create another physical volume (PV)?
    – roaima
    Nov 26 at 8:11











  • I want to use it as the OpenStack Cinder volume group. I tried sda2 but it was mounted (running the OS)
    – Soheil Pourbafrani
    Nov 26 at 8:14










  • Kindly add the output of lvs vgs and pvs command.
    – erTugRul
    Nov 27 at 6:36










  • @erTugRul has been Added.
    – Soheil Pourbafrani
    Nov 27 at 6:41










  • Forgot to ask you to show the output of df -Th. My bad. Kindly add that one also
    – erTugRul
    Nov 27 at 7:17












up vote
0
down vote

favorite









up vote
0
down vote

favorite











My goal is to create new LVM physical volume named sda3.
I installed the Centos 7.5 in such partitioning:



 Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 468877311 233389056 8e Linux LVM

Disk /dev/mapper/centos-root: 222.9 GB, 222885314560 bytes, 435322880 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 /dev/mapper/centos-swap: 10.7 GB, 10733223936 bytes, 20963328 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 /dev/mapper/centos-home: 5368 MB, 5368709120 bytes, 10485760 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


Actually, I have 3 partitions, swap, home and root which the OS is installed on the root partition. I tried to create a new LVM physical volume using the command pvcreate but it errors:



Device /dev/sda3 not found.


and when I tried /dev/sda2 it says:



Can't open /dev/sda2 exclusively. Mounted filesystem?


So I guess I should do the following steps to create a new LVM physical volume:



  1. Repartition(resize) the sda2 and create a new partition named sda3

  2. Unmount sda3 and now I can create a new LVM physical volume from sda3

The question is how can I resize the root(sda2) to make space for new partition sda3 while the OS is installed on the sda2?



In the following, I add some related command outputs.



Here is the output of the command lvmdiskscan



 /dev/centos/root [ <207.58 GiB] 
/dev/sda1 [ 1.00 GiB]
/dev/centos/swap [ <10.00 GiB]
/dev/sda2 [ <222.58 GiB] LVM physical volume
/dev/centos/home [ 5.00 GiB]
3 disks
1 partition
0 LVM physical volume whole disks
1 LVM physical volume


and here is the output of lsblk command:



sda 8:0 0 465.8G 0 disk 
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 464.8G 0 part
├─centos-root 253:0 0 451.9G 0 lvm /
├─centos-swap 253:1 0 7.9G 0 lvm [SWAP]
└─centos-home 253:2 0 5G 0 lvm /home


The lvs command:



 LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- 5.00g
root centos -wi-ao---- <207.58g
swap centos -wi-ao---- <10.00g


The vgs command:



VG #PV #LV #SN Attr VSize VFree
centos 1 3 0 wz--n- 222.57g 0


The pvs command:



PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 222.57g 0









share|improve this question















My goal is to create new LVM physical volume named sda3.
I installed the Centos 7.5 in such partitioning:



 Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 468877311 233389056 8e Linux LVM

Disk /dev/mapper/centos-root: 222.9 GB, 222885314560 bytes, 435322880 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 /dev/mapper/centos-swap: 10.7 GB, 10733223936 bytes, 20963328 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 /dev/mapper/centos-home: 5368 MB, 5368709120 bytes, 10485760 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


Actually, I have 3 partitions, swap, home and root which the OS is installed on the root partition. I tried to create a new LVM physical volume using the command pvcreate but it errors:



Device /dev/sda3 not found.


and when I tried /dev/sda2 it says:



Can't open /dev/sda2 exclusively. Mounted filesystem?


So I guess I should do the following steps to create a new LVM physical volume:



  1. Repartition(resize) the sda2 and create a new partition named sda3

  2. Unmount sda3 and now I can create a new LVM physical volume from sda3

The question is how can I resize the root(sda2) to make space for new partition sda3 while the OS is installed on the sda2?



In the following, I add some related command outputs.



Here is the output of the command lvmdiskscan



 /dev/centos/root [ <207.58 GiB] 
/dev/sda1 [ 1.00 GiB]
/dev/centos/swap [ <10.00 GiB]
/dev/sda2 [ <222.58 GiB] LVM physical volume
/dev/centos/home [ 5.00 GiB]
3 disks
1 partition
0 LVM physical volume whole disks
1 LVM physical volume


and here is the output of lsblk command:



sda 8:0 0 465.8G 0 disk 
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 464.8G 0 part
├─centos-root 253:0 0 451.9G 0 lvm /
├─centos-swap 253:1 0 7.9G 0 lvm [SWAP]
└─centos-home 253:2 0 5G 0 lvm /home


The lvs command:



 LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- 5.00g
root centos -wi-ao---- <207.58g
swap centos -wi-ao---- <10.00g


The vgs command:



VG #PV #LV #SN Attr VSize VFree
centos 1 3 0 wz--n- 222.57g 0


The pvs command:



PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 222.57g 0






centos partition lvm openstack






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 at 6:40

























asked Nov 26 at 7:55









Soheil Pourbafrani

1135




1135











  • Why would you want to create another physical volume (PV)?
    – roaima
    Nov 26 at 8:11











  • I want to use it as the OpenStack Cinder volume group. I tried sda2 but it was mounted (running the OS)
    – Soheil Pourbafrani
    Nov 26 at 8:14










  • Kindly add the output of lvs vgs and pvs command.
    – erTugRul
    Nov 27 at 6:36










  • @erTugRul has been Added.
    – Soheil Pourbafrani
    Nov 27 at 6:41










  • Forgot to ask you to show the output of df -Th. My bad. Kindly add that one also
    – erTugRul
    Nov 27 at 7:17
















  • Why would you want to create another physical volume (PV)?
    – roaima
    Nov 26 at 8:11











  • I want to use it as the OpenStack Cinder volume group. I tried sda2 but it was mounted (running the OS)
    – Soheil Pourbafrani
    Nov 26 at 8:14










  • Kindly add the output of lvs vgs and pvs command.
    – erTugRul
    Nov 27 at 6:36










  • @erTugRul has been Added.
    – Soheil Pourbafrani
    Nov 27 at 6:41










  • Forgot to ask you to show the output of df -Th. My bad. Kindly add that one also
    – erTugRul
    Nov 27 at 7:17















Why would you want to create another physical volume (PV)?
– roaima
Nov 26 at 8:11





Why would you want to create another physical volume (PV)?
– roaima
Nov 26 at 8:11













I want to use it as the OpenStack Cinder volume group. I tried sda2 but it was mounted (running the OS)
– Soheil Pourbafrani
Nov 26 at 8:14




I want to use it as the OpenStack Cinder volume group. I tried sda2 but it was mounted (running the OS)
– Soheil Pourbafrani
Nov 26 at 8:14












Kindly add the output of lvs vgs and pvs command.
– erTugRul
Nov 27 at 6:36




Kindly add the output of lvs vgs and pvs command.
– erTugRul
Nov 27 at 6:36












@erTugRul has been Added.
– Soheil Pourbafrani
Nov 27 at 6:41




@erTugRul has been Added.
– Soheil Pourbafrani
Nov 27 at 6:41












Forgot to ask you to show the output of df -Th. My bad. Kindly add that one also
– erTugRul
Nov 27 at 7:17




Forgot to ask you to show the output of df -Th. My bad. Kindly add that one also
– erTugRul
Nov 27 at 7:17










1 Answer
1






active

oldest

votes

















up vote
0
down vote













You have a problem. Your /dev/centos/root LV is about 207 GiB in size, and together with /dev/centos/swap and /dev/centos/home it looks like your /dev/sda2 PV is fully in use. By default, CentOS uses a XFS filesystem which cannot be shrunk, neither as online nor offline operation, other than by backing up its contents, destroying the filesystem and recreating it in smaller size. Under such conditions, you should always initially configure your filesystems to be as small as reasonable, and be prepared to extend them if needed, since XFS offers a robust on-line extension mechanism.



To get free space for /dev/sda3 partition/PV, you would first need to shrink the /dev/centos/root filesystem, then shrink the LV to match, make sure the free extents are at the end of the disk (using pvmove to rearrange them if necessary) then pvresize to shrink the PV, then edit the partition table to shrink the actual /dev/sda2 partition... a lot of work.



If you don't have anything too complicated on the system yet, the easiest way would probably be to backup everything necessary, and then completely reinstall CentOS 7.5, this time either configuring the installer to create an empty /dev/sda3 partition for you, or otherwise ensuring that the space won't get added to any filesystem. In cases like this, the automatic partitioning feature of the OS installer is definitely not your friend.






share|improve this answer




















  • Thanks, If I had created partitions as standard partition and not LVM at the OS installation, I could shrink it easily and make it LMV group, yes?
    – Soheil Pourbafrani
    Nov 26 at 12:39






  • 1




    A bit less steps perhaps, but the first step, shrinking an XFS filesystem, would remain just as impossible.
    – telcoM
    Nov 26 at 14:12










  • Thanks, I want to allocate 100G to sda2 and make free about 200G and create new sda3. I wanted to use the command pvresize --setphysicalvolumesize 100G /dev/sda2 but according to your advice I think I should rearrange data using to prevent data loss. Could give me an example of the command pvmove, pls?
    – Soheil Pourbafrani
    Nov 26 at 14:27










  • Please add the output of lsblk into your question post.
    – telcoM
    Nov 26 at 14:56










  • I edited the post and add the output of the lsblk command.
    – Soheil Pourbafrani
    Nov 27 at 5:55










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f484136%2fpartitioning-existing-lvm-physical-volume-and-create-new-lvm-physical-volume%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













You have a problem. Your /dev/centos/root LV is about 207 GiB in size, and together with /dev/centos/swap and /dev/centos/home it looks like your /dev/sda2 PV is fully in use. By default, CentOS uses a XFS filesystem which cannot be shrunk, neither as online nor offline operation, other than by backing up its contents, destroying the filesystem and recreating it in smaller size. Under such conditions, you should always initially configure your filesystems to be as small as reasonable, and be prepared to extend them if needed, since XFS offers a robust on-line extension mechanism.



To get free space for /dev/sda3 partition/PV, you would first need to shrink the /dev/centos/root filesystem, then shrink the LV to match, make sure the free extents are at the end of the disk (using pvmove to rearrange them if necessary) then pvresize to shrink the PV, then edit the partition table to shrink the actual /dev/sda2 partition... a lot of work.



If you don't have anything too complicated on the system yet, the easiest way would probably be to backup everything necessary, and then completely reinstall CentOS 7.5, this time either configuring the installer to create an empty /dev/sda3 partition for you, or otherwise ensuring that the space won't get added to any filesystem. In cases like this, the automatic partitioning feature of the OS installer is definitely not your friend.






share|improve this answer




















  • Thanks, If I had created partitions as standard partition and not LVM at the OS installation, I could shrink it easily and make it LMV group, yes?
    – Soheil Pourbafrani
    Nov 26 at 12:39






  • 1




    A bit less steps perhaps, but the first step, shrinking an XFS filesystem, would remain just as impossible.
    – telcoM
    Nov 26 at 14:12










  • Thanks, I want to allocate 100G to sda2 and make free about 200G and create new sda3. I wanted to use the command pvresize --setphysicalvolumesize 100G /dev/sda2 but according to your advice I think I should rearrange data using to prevent data loss. Could give me an example of the command pvmove, pls?
    – Soheil Pourbafrani
    Nov 26 at 14:27










  • Please add the output of lsblk into your question post.
    – telcoM
    Nov 26 at 14:56










  • I edited the post and add the output of the lsblk command.
    – Soheil Pourbafrani
    Nov 27 at 5:55














up vote
0
down vote













You have a problem. Your /dev/centos/root LV is about 207 GiB in size, and together with /dev/centos/swap and /dev/centos/home it looks like your /dev/sda2 PV is fully in use. By default, CentOS uses a XFS filesystem which cannot be shrunk, neither as online nor offline operation, other than by backing up its contents, destroying the filesystem and recreating it in smaller size. Under such conditions, you should always initially configure your filesystems to be as small as reasonable, and be prepared to extend them if needed, since XFS offers a robust on-line extension mechanism.



To get free space for /dev/sda3 partition/PV, you would first need to shrink the /dev/centos/root filesystem, then shrink the LV to match, make sure the free extents are at the end of the disk (using pvmove to rearrange them if necessary) then pvresize to shrink the PV, then edit the partition table to shrink the actual /dev/sda2 partition... a lot of work.



If you don't have anything too complicated on the system yet, the easiest way would probably be to backup everything necessary, and then completely reinstall CentOS 7.5, this time either configuring the installer to create an empty /dev/sda3 partition for you, or otherwise ensuring that the space won't get added to any filesystem. In cases like this, the automatic partitioning feature of the OS installer is definitely not your friend.






share|improve this answer




















  • Thanks, If I had created partitions as standard partition and not LVM at the OS installation, I could shrink it easily and make it LMV group, yes?
    – Soheil Pourbafrani
    Nov 26 at 12:39






  • 1




    A bit less steps perhaps, but the first step, shrinking an XFS filesystem, would remain just as impossible.
    – telcoM
    Nov 26 at 14:12










  • Thanks, I want to allocate 100G to sda2 and make free about 200G and create new sda3. I wanted to use the command pvresize --setphysicalvolumesize 100G /dev/sda2 but according to your advice I think I should rearrange data using to prevent data loss. Could give me an example of the command pvmove, pls?
    – Soheil Pourbafrani
    Nov 26 at 14:27










  • Please add the output of lsblk into your question post.
    – telcoM
    Nov 26 at 14:56










  • I edited the post and add the output of the lsblk command.
    – Soheil Pourbafrani
    Nov 27 at 5:55












up vote
0
down vote










up vote
0
down vote









You have a problem. Your /dev/centos/root LV is about 207 GiB in size, and together with /dev/centos/swap and /dev/centos/home it looks like your /dev/sda2 PV is fully in use. By default, CentOS uses a XFS filesystem which cannot be shrunk, neither as online nor offline operation, other than by backing up its contents, destroying the filesystem and recreating it in smaller size. Under such conditions, you should always initially configure your filesystems to be as small as reasonable, and be prepared to extend them if needed, since XFS offers a robust on-line extension mechanism.



To get free space for /dev/sda3 partition/PV, you would first need to shrink the /dev/centos/root filesystem, then shrink the LV to match, make sure the free extents are at the end of the disk (using pvmove to rearrange them if necessary) then pvresize to shrink the PV, then edit the partition table to shrink the actual /dev/sda2 partition... a lot of work.



If you don't have anything too complicated on the system yet, the easiest way would probably be to backup everything necessary, and then completely reinstall CentOS 7.5, this time either configuring the installer to create an empty /dev/sda3 partition for you, or otherwise ensuring that the space won't get added to any filesystem. In cases like this, the automatic partitioning feature of the OS installer is definitely not your friend.






share|improve this answer












You have a problem. Your /dev/centos/root LV is about 207 GiB in size, and together with /dev/centos/swap and /dev/centos/home it looks like your /dev/sda2 PV is fully in use. By default, CentOS uses a XFS filesystem which cannot be shrunk, neither as online nor offline operation, other than by backing up its contents, destroying the filesystem and recreating it in smaller size. Under such conditions, you should always initially configure your filesystems to be as small as reasonable, and be prepared to extend them if needed, since XFS offers a robust on-line extension mechanism.



To get free space for /dev/sda3 partition/PV, you would first need to shrink the /dev/centos/root filesystem, then shrink the LV to match, make sure the free extents are at the end of the disk (using pvmove to rearrange them if necessary) then pvresize to shrink the PV, then edit the partition table to shrink the actual /dev/sda2 partition... a lot of work.



If you don't have anything too complicated on the system yet, the easiest way would probably be to backup everything necessary, and then completely reinstall CentOS 7.5, this time either configuring the installer to create an empty /dev/sda3 partition for you, or otherwise ensuring that the space won't get added to any filesystem. In cases like this, the automatic partitioning feature of the OS installer is definitely not your friend.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 26 at 11:18









telcoM

14.9k12043




14.9k12043











  • Thanks, If I had created partitions as standard partition and not LVM at the OS installation, I could shrink it easily and make it LMV group, yes?
    – Soheil Pourbafrani
    Nov 26 at 12:39






  • 1




    A bit less steps perhaps, but the first step, shrinking an XFS filesystem, would remain just as impossible.
    – telcoM
    Nov 26 at 14:12










  • Thanks, I want to allocate 100G to sda2 and make free about 200G and create new sda3. I wanted to use the command pvresize --setphysicalvolumesize 100G /dev/sda2 but according to your advice I think I should rearrange data using to prevent data loss. Could give me an example of the command pvmove, pls?
    – Soheil Pourbafrani
    Nov 26 at 14:27










  • Please add the output of lsblk into your question post.
    – telcoM
    Nov 26 at 14:56










  • I edited the post and add the output of the lsblk command.
    – Soheil Pourbafrani
    Nov 27 at 5:55
















  • Thanks, If I had created partitions as standard partition and not LVM at the OS installation, I could shrink it easily and make it LMV group, yes?
    – Soheil Pourbafrani
    Nov 26 at 12:39






  • 1




    A bit less steps perhaps, but the first step, shrinking an XFS filesystem, would remain just as impossible.
    – telcoM
    Nov 26 at 14:12










  • Thanks, I want to allocate 100G to sda2 and make free about 200G and create new sda3. I wanted to use the command pvresize --setphysicalvolumesize 100G /dev/sda2 but according to your advice I think I should rearrange data using to prevent data loss. Could give me an example of the command pvmove, pls?
    – Soheil Pourbafrani
    Nov 26 at 14:27










  • Please add the output of lsblk into your question post.
    – telcoM
    Nov 26 at 14:56










  • I edited the post and add the output of the lsblk command.
    – Soheil Pourbafrani
    Nov 27 at 5:55















Thanks, If I had created partitions as standard partition and not LVM at the OS installation, I could shrink it easily and make it LMV group, yes?
– Soheil Pourbafrani
Nov 26 at 12:39




Thanks, If I had created partitions as standard partition and not LVM at the OS installation, I could shrink it easily and make it LMV group, yes?
– Soheil Pourbafrani
Nov 26 at 12:39




1




1




A bit less steps perhaps, but the first step, shrinking an XFS filesystem, would remain just as impossible.
– telcoM
Nov 26 at 14:12




A bit less steps perhaps, but the first step, shrinking an XFS filesystem, would remain just as impossible.
– telcoM
Nov 26 at 14:12












Thanks, I want to allocate 100G to sda2 and make free about 200G and create new sda3. I wanted to use the command pvresize --setphysicalvolumesize 100G /dev/sda2 but according to your advice I think I should rearrange data using to prevent data loss. Could give me an example of the command pvmove, pls?
– Soheil Pourbafrani
Nov 26 at 14:27




Thanks, I want to allocate 100G to sda2 and make free about 200G and create new sda3. I wanted to use the command pvresize --setphysicalvolumesize 100G /dev/sda2 but according to your advice I think I should rearrange data using to prevent data loss. Could give me an example of the command pvmove, pls?
– Soheil Pourbafrani
Nov 26 at 14:27












Please add the output of lsblk into your question post.
– telcoM
Nov 26 at 14:56




Please add the output of lsblk into your question post.
– telcoM
Nov 26 at 14:56












I edited the post and add the output of the lsblk command.
– Soheil Pourbafrani
Nov 27 at 5:55




I edited the post and add the output of the lsblk command.
– Soheil Pourbafrani
Nov 27 at 5:55

















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f484136%2fpartitioning-existing-lvm-physical-volume-and-create-new-lvm-physical-volume%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?