0

I wrote a partition table manually during a system installation which contains an encrypted part, the /boot partition and an unpartitioned rest. Although I first created the partitions (manually each) and put them in one logical volume. The logical volume important is filled up with the volume group a (if it cannot be this way, please correct; if you know it must be this way, please remove this note). Afterwards, I encrypted the logical volume with LUKS and installed the system.

partition table

$ LC_ALL=C sudo lsblk [sudo] password for sj126: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931.5G 0 disk |-sda1 8:1 0 953M 0 part /boot |-sda2 8:2 0 1K 0 part |-sda3 8:3 0 16G 0 part [SWAP] |-sda4 8:4 0 100G 0 part |-sda5 8:5 0 7.5G 0 part | `-experiment-test 254:0 0 418.3G 0 lvm | `-experiment-test_crypt 254:1 0 418.3G 0 crypt / |-sda6 8:6 0 14G 0 part | `-experiment-test 254:0 0 418.3G 0 lvm | `-experiment-test_crypt 254:1 0 418.3G 0 crypt / |-sda7 8:7 0 372.5G 0 part | `-experiment-test 254:0 0 418.3G 0 lvm | `-experiment-test_crypt 254:1 0 418.3G 0 crypt / |-sda8 8:8 0 7G 0 part | `-experiment-test 254:0 0 418.3G 0 lvm | `-experiment-test_crypt 254:1 0 418.3G 0 crypt / |-sda9 8:9 0 7G 0 part | `-experiment-test 254:0 0 418.3G 0 lvm | `-experiment-test_crypt 254:1 0 418.3G 0 crypt / |-sda10 8:10 0 7G 0 part | `-experiment-test 254:0 0 418.3G 0 lvm | `-experiment-test_crypt 254:1 0 418.3G 0 crypt / |-sda11 8:11 0 2.3G 0 part | `-experiment-test 254:0 0 418.3G 0 lvm | `-experiment-test_crypt 254:1 0 418.3G 0 crypt / `-sda12 8:12 0 1.1G 0 part `-experiment-test 254:0 0 418.3G 0 lvm `-experiment-test_crypt 254:1 0 418.3G 0 crypt / $ LC_ALL=C sudo partitionmanager QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root' Loaded backend plugin: "pmlibpartedbackendplugin" "Using backend plugin: pmlibpartedbackendplugin (1)" "Scanning devices..." "Device found: [...]" blkid: unknown file system type "" on "/dev/sda2" "Partition ‘/dev/sda2’ is not properly aligned (first sector: 1955838, modulo: 2046)." "Scan finished." 

The point is that when browsing my dirs, only /boot on /dev/sda2 appears as a (separate) partition, the residual parts in / seem to be on the same partition. dev/sda{5,..12} should become partitions containing /home, e. g., stay in the same logical volume and should also be mounted there.

EDIT: The following is my partition table (updated). The partitions 3 and 4 are the beginning of a workaround and may be ignored for now. The only things left out are the disk label and the disk identifier.

$ LC_ALL=C sudo fdisk -l /dev/sda Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors Disk model: [...] Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: dos Disk identifier: [...] Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 1953791 1951744 953M 83 Linux /dev/sda2 1955838 879298559 877342722 418.4G 5 Extended /dev/sda3 879300608 912855039 33554432 16G 82 Linux swap / Solaris /dev/sda4 * 912857088 1122572287 209715200 100G 83 Linux /dev/sda5 1955840 17577983 15622144 7.5G 8e Linux LVM /dev/sda6 17580032 46874623 29294592 14G 8e Linux LVM /dev/sda7 46876672 828125183 781248512 372.5G 8e Linux LVM /dev/sda8 828127232 842774527 14647296 7G 8e Linux LVM /dev/sda9 842776576 857423871 14647296 7G 8e Linux LVM /dev/sda10 857425920 872073215 14647296 7G 8e Linux LVM /dev/sda11 872075264 876955647 4880384 2.3G 8e Linux LVM /dev/sda12 876957696 879298559 2340864 1.1G 8e Linux LVM Partition 2 does not start on physical sector boundary. Partition table entries are not in disk order. $ LC_ALL=C sudo lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert test experiment -wi-ao---- <418.32g $ LC_ALL=C sudo pvs PV VG Fmt Attr PSize PFree /dev/sda10 experiment lvm2 a-- 6.98g 0 /dev/sda11 experiment lvm2 a-- 2.32g 0 /dev/sda12 experiment lvm2 a-- 1.11g 0 /dev/sda5 experiment lvm2 a-- <7.45g 0 /dev/sda6 experiment lvm2 a-- 13.96g 0 /dev/sda7 experiment lvm2 a-- <372.53g 0 /dev/sda8 experiment lvm2 a-- 6.98g 0 /dev/sda9 experiment lvm2 a-- 6.98g 0 
6
  • The sentence "when browsing my dirs, only /boot on /dev/sda2 appears as a (separate) partition, the residual parts in / seem to be on the same partition" has no meaning. Directories and partitions exist at vastly different structural levels; there is no reasonable connection between them. And please add the result of sudo parted /dev/sda unit s print free to the question. Commented Oct 14, 2019 at 11:35
  • @AlexP PCManFM shows the free and total space of a partition in the lower right corner ("Free space: [...] (Total: [...])"). The total size doesn't change on this system where it changes on other, automatically partitioned systems. Therefore it's seen as one partition, isn't it? Commented Oct 14, 2019 at 13:37
  • Can you please show the partition list from either parted /dev/sda unit s print free or from fdisk -l /dev/sda? I have no idea what PCManFM is. Commented Oct 14, 2019 at 14:08
  • What kind of disk is this? Can you please edit the question and put the entire output from fdisk -l /dev/sda, especially the physical / logical sector size. Look at the lines for /dev/sda7, 8 and 9: they all have the same number of sectors, 14647296, but their capacity varies from 6 to 8 GB. This must be a joke. Commented Oct 14, 2019 at 14:39
  • Please show also the outputs of the lvs and pvs commands. So far, it looks like you've actually made a number of partitions, then made each of them into LVM PVs, added all of them to a VG named important, then made one big LV named a using all the PVs, then encrypted it. Commented Oct 14, 2019 at 14:54

2 Answers 2

0

You disk is partitioned using the MBR partition table. The disk is partitioned as follows:

  • sda1: Primary partition, formatted with a filesystem, mounted on /boot.

  • sda2: Extended partition, containing the following logical partitions:

    • sda5 to sda12: Logical partitions, formatted as LVM physical disks.
  • sda3: Primary partition. Cannot say whether it is formatted or not.

  • sda4: Primary partition. Cannot say whether it is formatted or not.

The LVM physical disks sda5 to sda12 are members of the LVM volume group experiment.

The LVM volume group experiment contains a LVM logical volume named test. The LVM logical volume experiment-test is formatted as a LUKS container. The payload of the LUKS container is named experiment-test_crypt; it is formatted with a with a file system and mounted on /.

Note that:

  • sda2 is an extended partition. It is simply a container for logical partitions, it cannot be formatted with a filesystem and mounted.

  • The logical partitions sda5 to sda12 are all formatted as LVM physical disks and made members of the LVM volume group experiment. All the space in the LVM volume group experiment is allocated to the logical volume test, formatted LUKS.

0

The point of LVM is to decouple the sizes of physical units of storage (whole disks or partitions) from the size of logical volumes (which will often contain filesystems).

As a result, splitting a single disk into multiple partitions and then adding all of those partitions as LVM physical volumes (PVs) in the same volume group (VG) is not very useful, except as a typing exercise. You'll end up essentially back to where you started from - with a big block of undifferentiated storage you'll need to slice apart into useful chunks.

Each PV can only be a member of just one VG at a time. Since all your PVs are members of the experiment VG, the VG a you mentioned in the question apparently no longer exists, and that means the logical volume (LV) important that was supposed to be inside it is now gone and overwritten. Sorry.

Your description of your LVM setup seemed to be... frankly, backwards or perhaps inside-out to me. Hopefully the explanation below may help in getting the concepts straight.

To maximize the advantages of LVM on a new disk, you'd generally want to do one of two things:

  • if a system disk, create whatever is necessary to satisfy the requirements of the system firmware (e.g. an EFI System Partition on UEFI systems, or /boot on very old BIOS systems whose firmware may not be able to handle the full size of the disk) and single large partition to cover the rest of the disk, to be used as a LVM PV. Even if the firmware places no particular restrictions (e.g. with BIOS-style booting with the latest version of GRUB with LVM and encryption support) you might want to create a non-LVM /boot partition to ensure that the bootloader component modules and the kernel & initramfs files vital for booting are definitely contained on a particular "boot disk" instead of "anywhere" on a big multi-disk LVM volume group, to make troubleshooting easier.

  • if a data disk, you have the option of not using partitioning at all, but just using the whole disk as a LVM PV. This can be an advantage if the disk is actually a SAN LUN: if the LUN needs to be expanded, a whole-disk LVM PV can be extended on-the-fly. After the SAN administrator has increased the LUN size, only a few commands is needed to make immediate use of the expanded size, with no need to fiddle with the partition table first. The flip-side is that for other operating systems, a whole-disk LVM PV is not recognizable as a disk that contains valid data: such a disk may easily be accidentally reformatted if accessed with another operating system. To minimize that risk, you might create a single partition encompassing the entire disk, and use that as a LVM PV.

Having multiple PVs is not a big deal by itself, but you should have at least some specific reason for having more than one PV per physical disk. Reclaiming space used by a previous dual-boot OS installation is one such valid reason. Having multiple VGs where one would suffice, on the other hand, can be a pain.

Once you have one or more PVs, you can create one or more VGs. If you have just one disk, there is generally no reason to create more than one VG. If you have multiple physical disks, you'll need to decide whether there is an expected need to separate those disks from each other for any reason, or if you can assume that they will be kept together for the life of the data stored on them. If the disks can be kept together, you can add all their PVs into a single VG. This will give you one big pool of storage, which you can slice into LVs any way you want - as long as the VG has enough total space available, you can create a LV that extends beyond the limits of any single PV.

When using LVM, the LVs mostly take the place of traditional partitions as containers of filesystems. If you need to extend a LV, you can do it - even on-line - as long as your VG still has unallocated space in at least one of its PVs. And if you run out of unallocated space, you can add (yes, even hot-add) a new PV into the VG and then extend your LV(s) onto it.

Within the bounds of the VG, you can use the pvmove command to move the LVs around if necessary - even while the VG is active and the filesystems on the LVs are mounted and in use. You can migrate the data on a new, bigger physical disk by adding the new disk as a PV into the old VG, then using pvmove to move the data from the old disk(s) to the new one(s), then remove the old disk(s) from the VG once they are empty. All this can be done without unmounting anything.

If you expect that a particular disk would need to be moved to another system with data in it, then you create a separate volume group for that disk - or maybe not use LVM at all on that disk, if the other system is not another Linux system. That could be the only real reason to create more than one VG in an average Linux setup with LVM.

There are two ways to set up encryption together with LVM:

  • you can encrypt the physical disk/partition before you set it up as a LVM PV, so that a single encryption passphrase will unlock all the LVs at once (Layering: disk -> partition -> encryption device -> PV -> LV)
  • or you can first set up your PVs, VG and LVs, and then set up encryption on one or more LVs separately, allowing different LVs to have different encryption passphrases if needed. (Layering: disk -> partition -> PV -> LV -> encryption device)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.