We can make a disk a PV by `pvcreate`, if and only if the disk has only one partition?












-3















Manpage of pvcreate says




pvcreate initializes a PV so that it is recognized as belonging to LVM, and allows the PV to be
used in a VG. A PV can be a disk partition, whole disk, meta device, or loopback file.




Why doesn't the following pvcreate command fail to mark a disk as PV then?



$ sudo parted -l
Model: ATA TOSHIBA MQ01ABF0 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp
2 538MB 500GB 500GB ext4
$ sudo lvmdiskscan
/dev/sda1 [ 512.00 MiB]
/dev/sda2 [ <465.26 GiB]
0 disks
2 partitions
0 LVM physical volume whole disks
0 LVM physical volumes

$ sudo pvcreate /dev/sda
Device /dev/sda excluded by a filter.


roaima wrote in https://unix.stackexchange.com/a/502428/674:




You're trying to use the entire /dev/sda for a PV. But you've got (at least) two partitions on that disk (sda1 and sda2), so LVM is rightly refusing to honour your request.




Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?



Thanks.










share|improve this question



























    -3















    Manpage of pvcreate says




    pvcreate initializes a PV so that it is recognized as belonging to LVM, and allows the PV to be
    used in a VG. A PV can be a disk partition, whole disk, meta device, or loopback file.




    Why doesn't the following pvcreate command fail to mark a disk as PV then?



    $ sudo parted -l
    Model: ATA TOSHIBA MQ01ABF0 (scsi)
    Disk /dev/sda: 500GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags:

    Number Start End Size File system Name Flags
    1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp
    2 538MB 500GB 500GB ext4
    $ sudo lvmdiskscan
    /dev/sda1 [ 512.00 MiB]
    /dev/sda2 [ <465.26 GiB]
    0 disks
    2 partitions
    0 LVM physical volume whole disks
    0 LVM physical volumes

    $ sudo pvcreate /dev/sda
    Device /dev/sda excluded by a filter.


    roaima wrote in https://unix.stackexchange.com/a/502428/674:




    You're trying to use the entire /dev/sda for a PV. But you've got (at least) two partitions on that disk (sda1 and sda2), so LVM is rightly refusing to honour your request.




    Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?



    Thanks.










    share|improve this question

























      -3












      -3








      -3








      Manpage of pvcreate says




      pvcreate initializes a PV so that it is recognized as belonging to LVM, and allows the PV to be
      used in a VG. A PV can be a disk partition, whole disk, meta device, or loopback file.




      Why doesn't the following pvcreate command fail to mark a disk as PV then?



      $ sudo parted -l
      Model: ATA TOSHIBA MQ01ABF0 (scsi)
      Disk /dev/sda: 500GB
      Sector size (logical/physical): 512B/512B
      Partition Table: gpt
      Disk Flags:

      Number Start End Size File system Name Flags
      1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp
      2 538MB 500GB 500GB ext4
      $ sudo lvmdiskscan
      /dev/sda1 [ 512.00 MiB]
      /dev/sda2 [ <465.26 GiB]
      0 disks
      2 partitions
      0 LVM physical volume whole disks
      0 LVM physical volumes

      $ sudo pvcreate /dev/sda
      Device /dev/sda excluded by a filter.


      roaima wrote in https://unix.stackexchange.com/a/502428/674:




      You're trying to use the entire /dev/sda for a PV. But you've got (at least) two partitions on that disk (sda1 and sda2), so LVM is rightly refusing to honour your request.




      Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?



      Thanks.










      share|improve this question














      Manpage of pvcreate says




      pvcreate initializes a PV so that it is recognized as belonging to LVM, and allows the PV to be
      used in a VG. A PV can be a disk partition, whole disk, meta device, or loopback file.




      Why doesn't the following pvcreate command fail to mark a disk as PV then?



      $ sudo parted -l
      Model: ATA TOSHIBA MQ01ABF0 (scsi)
      Disk /dev/sda: 500GB
      Sector size (logical/physical): 512B/512B
      Partition Table: gpt
      Disk Flags:

      Number Start End Size File system Name Flags
      1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp
      2 538MB 500GB 500GB ext4
      $ sudo lvmdiskscan
      /dev/sda1 [ 512.00 MiB]
      /dev/sda2 [ <465.26 GiB]
      0 disks
      2 partitions
      0 LVM physical volume whole disks
      0 LVM physical volumes

      $ sudo pvcreate /dev/sda
      Device /dev/sda excluded by a filter.


      roaima wrote in https://unix.stackexchange.com/a/502428/674:




      You're trying to use the entire /dev/sda for a PV. But you've got (at least) two partitions on that disk (sda1 and sda2), so LVM is rightly refusing to honour your request.




      Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?



      Thanks.







      partition lvm






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 24 at 15:51









      TimTim

      27.8k78265485




      27.8k78265485






















          2 Answers
          2






          active

          oldest

          votes


















          1














          You said yourself:




          A PV can be a disk partition, whole disk, meta device, or loopback file




          I don't understand your question. A PV can be a partition or a whole disk. Delete all partitions and you will be able to use the whole disk. If you don't want to use the whole disk, then use a partition instead.



          You should also know that one partition that covers the whole disk space could make less trouble.



          Please read this answer before you wipe your hdd: What is the best practice for adding disks in LVM.






          share|improve this answer


























          • My question is "Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?"

            – Tim
            Feb 24 at 16:25











          • You can't make the whole disk a PV if there is at least one partition on it (because pvcreate won't let you).

            – Freddy
            Feb 24 at 16:28











          • What do you mean a disk without a partition? Any disk without being partitioned is a partition by itself

            – Tim
            Feb 24 at 16:34











          • “Any disk without being partitioned” is a disk with no partitions. It isn’t a partition by itself. When you get a new disk, or if you overwrite a disk with zeros, it’s empty, with no partition table, let alone partitions.

            – Stephen Kitt
            Feb 24 at 16:39













          • @Tim If you delete /dev/sda1 and /dev/sda2 with gparted or any other partitioning program, then your disk is without partitions.

            – Freddy
            Feb 24 at 16:52



















          1














          No.



          I have absolutely no experience with this, but from the information in the question. No.



          You can pvcreate a partition or a disk, or …



          It is stopping you, because it sees that the device you have asked to process, has partitions on it. The important word here is partitions (ignore pluralisation).



          So the logical predicate you are after is:



          Partitions on device implies, pvcreate refuses to work (destroy data).


          If you want to do the whore disk, then remove partitions. However it looks like you have a boot partition, so you may want to pvcreate /dev/sda2.






          share|improve this answer























            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',
            autoActivateHeartbeat: false,
            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%2f502709%2fwe-can-make-a-disk-a-pv-by-pvcreate-if-and-only-if-the-disk-has-only-one-part%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            You said yourself:




            A PV can be a disk partition, whole disk, meta device, or loopback file




            I don't understand your question. A PV can be a partition or a whole disk. Delete all partitions and you will be able to use the whole disk. If you don't want to use the whole disk, then use a partition instead.



            You should also know that one partition that covers the whole disk space could make less trouble.



            Please read this answer before you wipe your hdd: What is the best practice for adding disks in LVM.






            share|improve this answer


























            • My question is "Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?"

              – Tim
              Feb 24 at 16:25











            • You can't make the whole disk a PV if there is at least one partition on it (because pvcreate won't let you).

              – Freddy
              Feb 24 at 16:28











            • What do you mean a disk without a partition? Any disk without being partitioned is a partition by itself

              – Tim
              Feb 24 at 16:34











            • “Any disk without being partitioned” is a disk with no partitions. It isn’t a partition by itself. When you get a new disk, or if you overwrite a disk with zeros, it’s empty, with no partition table, let alone partitions.

              – Stephen Kitt
              Feb 24 at 16:39













            • @Tim If you delete /dev/sda1 and /dev/sda2 with gparted or any other partitioning program, then your disk is without partitions.

              – Freddy
              Feb 24 at 16:52
















            1














            You said yourself:




            A PV can be a disk partition, whole disk, meta device, or loopback file




            I don't understand your question. A PV can be a partition or a whole disk. Delete all partitions and you will be able to use the whole disk. If you don't want to use the whole disk, then use a partition instead.



            You should also know that one partition that covers the whole disk space could make less trouble.



            Please read this answer before you wipe your hdd: What is the best practice for adding disks in LVM.






            share|improve this answer


























            • My question is "Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?"

              – Tim
              Feb 24 at 16:25











            • You can't make the whole disk a PV if there is at least one partition on it (because pvcreate won't let you).

              – Freddy
              Feb 24 at 16:28











            • What do you mean a disk without a partition? Any disk without being partitioned is a partition by itself

              – Tim
              Feb 24 at 16:34











            • “Any disk without being partitioned” is a disk with no partitions. It isn’t a partition by itself. When you get a new disk, or if you overwrite a disk with zeros, it’s empty, with no partition table, let alone partitions.

              – Stephen Kitt
              Feb 24 at 16:39













            • @Tim If you delete /dev/sda1 and /dev/sda2 with gparted or any other partitioning program, then your disk is without partitions.

              – Freddy
              Feb 24 at 16:52














            1












            1








            1







            You said yourself:




            A PV can be a disk partition, whole disk, meta device, or loopback file




            I don't understand your question. A PV can be a partition or a whole disk. Delete all partitions and you will be able to use the whole disk. If you don't want to use the whole disk, then use a partition instead.



            You should also know that one partition that covers the whole disk space could make less trouble.



            Please read this answer before you wipe your hdd: What is the best practice for adding disks in LVM.






            share|improve this answer















            You said yourself:




            A PV can be a disk partition, whole disk, meta device, or loopback file




            I don't understand your question. A PV can be a partition or a whole disk. Delete all partitions and you will be able to use the whole disk. If you don't want to use the whole disk, then use a partition instead.



            You should also know that one partition that covers the whole disk space could make less trouble.



            Please read this answer before you wipe your hdd: What is the best practice for adding disks in LVM.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Feb 24 at 16:25

























            answered Feb 24 at 16:19









            FreddyFreddy

            1,319110




            1,319110













            • My question is "Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?"

              – Tim
              Feb 24 at 16:25











            • You can't make the whole disk a PV if there is at least one partition on it (because pvcreate won't let you).

              – Freddy
              Feb 24 at 16:28











            • What do you mean a disk without a partition? Any disk without being partitioned is a partition by itself

              – Tim
              Feb 24 at 16:34











            • “Any disk without being partitioned” is a disk with no partitions. It isn’t a partition by itself. When you get a new disk, or if you overwrite a disk with zeros, it’s empty, with no partition table, let alone partitions.

              – Stephen Kitt
              Feb 24 at 16:39













            • @Tim If you delete /dev/sda1 and /dev/sda2 with gparted or any other partitioning program, then your disk is without partitions.

              – Freddy
              Feb 24 at 16:52



















            • My question is "Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?"

              – Tim
              Feb 24 at 16:25











            • You can't make the whole disk a PV if there is at least one partition on it (because pvcreate won't let you).

              – Freddy
              Feb 24 at 16:28











            • What do you mean a disk without a partition? Any disk without being partitioned is a partition by itself

              – Tim
              Feb 24 at 16:34











            • “Any disk without being partitioned” is a disk with no partitions. It isn’t a partition by itself. When you get a new disk, or if you overwrite a disk with zeros, it’s empty, with no partition table, let alone partitions.

              – Stephen Kitt
              Feb 24 at 16:39













            • @Tim If you delete /dev/sda1 and /dev/sda2 with gparted or any other partitioning program, then your disk is without partitions.

              – Freddy
              Feb 24 at 16:52

















            My question is "Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?"

            – Tim
            Feb 24 at 16:25





            My question is "Does it mean that we can make a disk a PV by pvcreate, if and only if the disk has only one partition? In other words, we can't make a disk a PV by pvcreate, if and only if the disk has more than one partitions?"

            – Tim
            Feb 24 at 16:25













            You can't make the whole disk a PV if there is at least one partition on it (because pvcreate won't let you).

            – Freddy
            Feb 24 at 16:28





            You can't make the whole disk a PV if there is at least one partition on it (because pvcreate won't let you).

            – Freddy
            Feb 24 at 16:28













            What do you mean a disk without a partition? Any disk without being partitioned is a partition by itself

            – Tim
            Feb 24 at 16:34





            What do you mean a disk without a partition? Any disk without being partitioned is a partition by itself

            – Tim
            Feb 24 at 16:34













            “Any disk without being partitioned” is a disk with no partitions. It isn’t a partition by itself. When you get a new disk, or if you overwrite a disk with zeros, it’s empty, with no partition table, let alone partitions.

            – Stephen Kitt
            Feb 24 at 16:39







            “Any disk without being partitioned” is a disk with no partitions. It isn’t a partition by itself. When you get a new disk, or if you overwrite a disk with zeros, it’s empty, with no partition table, let alone partitions.

            – Stephen Kitt
            Feb 24 at 16:39















            @Tim If you delete /dev/sda1 and /dev/sda2 with gparted or any other partitioning program, then your disk is without partitions.

            – Freddy
            Feb 24 at 16:52





            @Tim If you delete /dev/sda1 and /dev/sda2 with gparted or any other partitioning program, then your disk is without partitions.

            – Freddy
            Feb 24 at 16:52













            1














            No.



            I have absolutely no experience with this, but from the information in the question. No.



            You can pvcreate a partition or a disk, or …



            It is stopping you, because it sees that the device you have asked to process, has partitions on it. The important word here is partitions (ignore pluralisation).



            So the logical predicate you are after is:



            Partitions on device implies, pvcreate refuses to work (destroy data).


            If you want to do the whore disk, then remove partitions. However it looks like you have a boot partition, so you may want to pvcreate /dev/sda2.






            share|improve this answer




























              1














              No.



              I have absolutely no experience with this, but from the information in the question. No.



              You can pvcreate a partition or a disk, or …



              It is stopping you, because it sees that the device you have asked to process, has partitions on it. The important word here is partitions (ignore pluralisation).



              So the logical predicate you are after is:



              Partitions on device implies, pvcreate refuses to work (destroy data).


              If you want to do the whore disk, then remove partitions. However it looks like you have a boot partition, so you may want to pvcreate /dev/sda2.






              share|improve this answer


























                1












                1








                1







                No.



                I have absolutely no experience with this, but from the information in the question. No.



                You can pvcreate a partition or a disk, or …



                It is stopping you, because it sees that the device you have asked to process, has partitions on it. The important word here is partitions (ignore pluralisation).



                So the logical predicate you are after is:



                Partitions on device implies, pvcreate refuses to work (destroy data).


                If you want to do the whore disk, then remove partitions. However it looks like you have a boot partition, so you may want to pvcreate /dev/sda2.






                share|improve this answer













                No.



                I have absolutely no experience with this, but from the information in the question. No.



                You can pvcreate a partition or a disk, or …



                It is stopping you, because it sees that the device you have asked to process, has partitions on it. The important word here is partitions (ignore pluralisation).



                So the logical predicate you are after is:



                Partitions on device implies, pvcreate refuses to work (destroy data).


                If you want to do the whore disk, then remove partitions. However it looks like you have a boot partition, so you may want to pvcreate /dev/sda2.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 24 at 16:31









                ctrl-alt-delorctrl-alt-delor

                12k42360




                12k42360






























                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f502709%2fwe-can-make-a-disk-a-pv-by-pvcreate-if-and-only-if-the-disk-has-only-one-part%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 make a Squid Proxy server?

                    第一次世界大戦

                    Touch on Surface Book