So when I do (as a root)

fdisk -l

I see /dev/sda1 and /dev/sda2

Now I am practicing creating logical volumes, when I tried partitioning


I got two new partition /dev/sda2p1 and /dev/sda2p2

and then I run


but then when I try creating a pv

/dev/sda2p1 /dev/sda2p2

It says these devices are not found even though when I run

fdisk -l /dev/sda2

I do see them listed there (and I did chose type 8e when creating these partition lvm)

what am I doing wrong ?

enter image description here

  • I would probably be less confused if the text of your question included the command pvcreate anywhere within it :-P. BTW you should really post both the command you use, and the exact error message, i.e. copy+paste. It helps to minimize ambiguity, even if in this case the ambiguity was more about what you were trying to do and I may have found the technical problem anyway :-P.
    – sourcejedi
    Commented Dec 5, 2017 at 19:12
  • PS: in case English is not your system language, you can (and should) use export LC_ALL=C, to temporarily get ASCII English messages and everything else.
    – sourcejedi
    Commented Dec 5, 2017 at 19:30

2 Answers 2


What am I doing wrong?

LVM Logical Volumes are not created with fdisk. You need to use lvcreate instead.

I did chose type 8e when creating these partition lvm

Setting the partition type using fdisk, let you hint that a partition may contain an LVM Physical Volume. Like setting any other partition type, this doesn't actually format the partition. To format a partition as an LVM Physical Volume, you need to use pvcreate.

You do the pvcreate first. Then assign it to a LVM Volume Group, for example creating a new VG using vgcreate myvg /dev/sda2. Then you can create logical volumes.

You could go ahead and do this from the man pages, you shouldn't need to set any non-default option here, but it's probably easier to look for a nice tutorial which satisfies these critera :-P.

So what did you do? Well, you effectively treated the partition /dev/sda2 as a disk itself. You formatted it with a partition table, and created partitions inside it. Apparently fdisk is happy to let you do this without considering it a problem :). However this isn't generally useful or something that people do. BSD installs on PCs do something a bit like this, however Linux installers do not. I tried creating something like sda2p1 myself. My conclusion was the Linux kernel itself does not support nesting partition tables like this, although userspace commands can let you access them if you understand what's going on.

In my own testing, partprobe /dev/sda8 failed. It seemed confused, thinking that partitions were already being used, and reported errors on more partitions than existed anywhere on my system. Instead, using kpartx -av /dev/sda8 worked, in my case to detect and map "sda8p1". However it appears the Linux kernel did not support nested partitions like this.[1] The kernel was not aware of the block device sda8p1. (It did not appear in /sys/class/block under that name). Instead, the result of kpartx was to create a "device mapper" block device called dm-0. It was created such that cat /sys/block/dm-0/dm/name showed sda8p1.

Even after the kpartx command, my system did not create a device node at /dev/sda8p1. Instead, the device node was accessible as /dev/mapper/sda8p1.

(Or directly as /dev/dm-0. ls -l /dev/mapper shows that the file(s) there are symbolic links to /dev/dm-*).

[1] Bonus fact: device nodes for sda1 etc. have pre-allocated device numbers. There is no pre-allocated number for sda2p1 etc.

  • I actually understand all of that, when I tried doing a pvcreate, it came up to me as devices are not available, i know that I have to use lvcreate, this is just a preparation, am preparing the partitions first and then i will use pvcreate, vgcreate and then lgcreate
    – alkabary
    Commented Dec 5, 2017 at 18:48
  • @alkabary updated with test result. I strongly suspect /dev/sda2p1 does not actually exist. To disprove this you would need to post the result of ls /dev/sd*, thanks.
    – sourcejedi
    Commented Dec 5, 2017 at 19:08
  • I read your answer, it's very helpful. I included a screenshot and put it my question here. It did let me create it ! @sourcejedi
    – alkabary
    Commented Dec 5, 2017 at 19:57
  • @alkabary haha. What I'm telling you is that fdisk is making that up. (The /dev/ part, to be specific). You have not posted the result of ls /dev/sd*. I have no idea why you don't want to run that.
    – sourcejedi
    Commented Dec 6, 2017 at 9:02
  • I also wish people wouldn't say my answers were very useful, when what they mean is: "this is an impressive wall of text but I'm not sure how I can use this information to help me". It's not very helpful. I have edited to bold the important part, since it ends up being at the end.
    – sourcejedi
    Commented Dec 6, 2017 at 9:37

First you have a physical harddisk e.g. sda or sdb A physical harddisk can contain a partition table.

you can add the whole disk to your lvm, then you don't need a partition table. e.g.:

pvcreate /dev/sda

or you create a partition table with fdisk or cfdisk after this you have to create the physical extents e.g.:

pvcreate /dev/sda5

the command pvcreatecreate physical extents now you have to create a volume group, a volume group contains many physical extents, a volume group can contain physical extents from one or many devices.

vgcreate VGName /dev/sda5
#          ^the name of your new volume group
#                    ^the partition or device

You can view with vgs the free space for your volume groups.

lvcreate -L 100G -n home VGName
#           ^size of your new logical volume
#                    ^with -n you can set a name e.g. home
#                          ^at the end the name of your VolumeGroup

You can use lvcreate -l 100%FREE if you like use your whole volume group or lvcreate -l60%VG for 60%

after you created a logical volume, you can create a filesystem e.g. ext4 mkfs.ext4 /dev/VGName/home

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .