1 (edited by no_BS 2020-07-31 09:35:55)

Topic: [Solved] shrinking encrypted LVM partition + touchpad mouse click

Hi, I just downloaded and first used the GParted 1.1.0-5 Live image to solve the follwoing problem.
I have a hard disk layout like

> lsblk
NAME                                       MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                                          8:0    0 149.1G  0 disk
├─sda1                                       8:1    0   156M  0 part  /boot
├─sda2                                       8:2    0    22G  0 part
│ └─cr_ata-WDC_WD1600BEVT-22ZCT0_WD-WXE708N10973-part2
│                                          254:0    0    22G  0 crypt
│   ├─system-root                          254:1    0  19.9G  0 lvm   /
│   └─system-swap                          254:2    0     2G  0 lvm   [SWAP]
└─sda4                                       8:4    0   127G  0 part
  └─cr_ata-WDC_WD1600BEVT-22ZCT0_WD-WXE708N10973-part4
                                           254:3    0   127G  0 crypt
    └─system-home                          254:4    0   127G  0 lvm   /home
sr0                                         11:0    1  1024M  0 rom

/sda2 and sda4 are both LUKS encrypted LVM.  root, swap and home are in the volume group system, the file system in root and home is ext4.

For an upgrade of my openSuSE Leap 15.1 -> 15.2 I need to increase the size of the /boot partition (sda1). I plan to so this by shrinking sda4, moving this to the end, moving sda2, and finally increasing sda1, and though that maybe GParted would be the right tool to use.

Now I find that GParted Live (Default settings) boots up well, I can open the luks encrypted partitions and active the LVM, but I can not shrink home. From reading several posts on the internet, I suspect that I first have to shrink the file system. Is that indeed the case? Is there a way to do this insode GParted, or does this have to be done outside?
What is the recommended procedure to do the changes to the partinioning that I plan?

If you need any additional information, I am happy to supply.

However, I have another problem with the GParted Live version: It seems I can not correctly use the touchpad of the laptop machine. I can move the pointer OK, but clicking does not seem to work. Right click with the touchpad button works correct, and I can  click on some controls, but clicking on the touchpad field does not work. Any ideas on this?

Thank you very much for your help in advance.

2 (edited by mfleetwo 2020-07-28 20:07:28)

Re: [Solved] shrinking encrypted LVM partition + touchpad mouse click

GParted can do some / most of what needs doing, but not all.  It only supports LVM Physical Volumes, but not LVM Volume Groups or Logical Volumes.

MAKE SURE YOU HAVE BACKUPS OF ANY DATA YOU CARE ABOUT.
This is especially important when working on encrypted data.  If something fails it will be impossible to reconstruct from the pieces.

What you need to do is:
1. Shrink /home file system.  Suggest 1024 MiB.

gparted /dev/mapper/system-home

2. Shrink LVM Logical Volume containing /home by 1024 MiB.

lvm lvresize --size -1024M /dev/mapper/cr_ata-WDC_WD1600BEVT-22ZCT0_WD-WXE708N10973-part4

Correction 2020-07-28:
The above device name /dev/mapper/cr_ata-WDC_WD1600BEVT-22ZCT0_WD-WXE708N10973-part4 is the name of the Physical Volume, so is therefore wrong.  The correct command to shrink the Logical Volume is:

lvm lvresize --size -1024M /dev/mapper/system-home

3. Shrink sda4 (and LVM Physical Volume and LUKS mapping) by 1024 MiB.

gparted

4. Deactivate LVM "system" Volume Group.

lvm vgchange -an system

5. Close LUKS mapping containing /home.

gparted

6. Move sda4 towards the end of the disk by 1024 MiB.
   (still in GParted)
7. Close LUKS mapping containing / and swap.
   (still in GParted)
8. Move sda2 towards the end by as much as possible (1024 MiB).
   (still in GParted)
9. Grow sda1.
   (still in GParted)

3

Re: [Solved] shrinking encrypted LVM partition + touchpad mouse click

Thank you for the quick reply.

Before I proceed, I would like to be absolutely sure, I am doing the correct steps.

Is it correct that I assume that all steps except item (2) and (4) in your list can be done within GParted?

Do I need the GParted Live system (I had assumed so since eventually I will have to touch /root)?

I find that I can not access /device/mapper/system-home for item (1) from the GParted window displayed when I start the GParted Live stick. From the "Terminal" application, I can use the command "gparted /device/mapper/system-home" successfully, but only after I have opened encryption and activated partitions sda2 and sda4 in the GParted window. Is that the correct behavior?

4

Re: [Solved] shrinking encrypted LVM partition + touchpad mouse click

Yes all steps other than (2) and (4) can be performed using the GParted application.

Yes you need to boot from the GParted Live distro (or other live distro with GParted) because the steps required the "system" LVM Volume Group to be stopped part way through the process, meaning / file system won't be available.

Yes the behaviour with regard /dev/mapper/system-home is expected.  As it is an LVM Logical Volume, which GParted doesn't support, it won't be shown when launced from an icon or just running as "gparted".  This is why it has to be specified on the command line.  Step (1) is just shrinking the /home file system within the LV.  Step (2) is shrinking the LV to match.

For steps (5) onward running GParted, compose one operation and apply before moving on to the next step.

5

Re: [Solved] shrinking encrypted LVM partition + touchpad mouse click

I have now done some steps with the GParted Live medium. Unfortunately, I encountered some problems. I try to provide some information below.

I must say that I first realized that at the end of the disk there was some unused space, and I decided to include this into sda4, and to start to shrink from the situation after adding this space.
Growing sda4 within GParted seemed OK, the graphical windows shows that there is no unused space left. I have a screenshot after reboot, but I don't find a way to upload the image to the BB (although I can see the "Images" help).
Now, just after reboot into GParted Live, before I activate the LUKS encrypted LVM partitions, I get the following fdisk -l result (/dev/sdb is of course the USB stick with the Live medium):

Disk /dev/sdb: 7.27 GiB, 7801405440 bytes, 15237120 sectors
Disk model: STORE N GO
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x41c15519

Device     Boot Start    End Sectors  Size Id Type
/dev/sdb1  *       64 714751  714688  349M 17 Hidden HPFS/NTFS


Disk /dev/sda: 149.5 GiB, 160041885696 bytes, 312581808 sectors
Disk model: WDC WD1600BEVT-2
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000c12a9

Device     Boot    Start       End   Sectors  Size Id Type
/dev/sda1  *        2048    321535    319488  156M 83 Linux
/dev/sda2         321536  46313471  45991936   22G 8e Linux LVM
/dev/sda4       46315395 312580095 266264701  127G 8e Linux LVM




Disk /dev/loop0: 303.31 MiB, 318033920 bytes, 621160 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

 
The number of sectors for /dev/sda4 has indeed increased, see the respective line in the fdisk report before growing:

/dev/sda4       46315395 312576704 266261310  127G 8e Linux LVM

If I now unlock both sda2 and sda4, both become also activated and fdisk -l lists more information, but the size of /dev/mapper/system-home has not changed and is still:

Disk /dev/mapper/system-home: 127 GiB, 136319074304 bytes, 266248192 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

No sectors have been added. So, I thought that the LV and the file system should be grown as well, and used in analogy to your suggestion with the added -r flag

lvm lvresize -r -l+100%FREE /dev/mapper/sda4_crypt

Please note, that I used "sda4_crypt" instead of the "cr_ata-WDC_WD1600BEVT-22ZCT0_WD-WXE708N10973-part4", because the latter was the name in my Leap 15.1 system (from where I created the lsblk output in my original post, but in the GParted Live system, sda4_crypt appears instead. In fact, I also tried the "cr_ata...", but of course that gave me an error.
This command gave the following result:

  "/dev/mapper/sda4_crypt": Invalid path for Logical Volume.
  Run `lvresize --help' for more information.

Well, indeed the command lvdisplay shows that

  WARNING: PV /dev/mapper/sda2_crypt in VG system is using an old PV header, modify the VG to update.
  WARNING: PV /dev/mapper/sda4_crypt in VG system is using an old PV header, modify the VG to update.
  --- Logical volume ---
  LV Path                /dev/system/home
  LV Name                home
  VG Name                system
  LV UUID                XHMtO6-TFcg-mQea-qPI7-yCer-GlYP-tjgt1Z
  LV Write Access        read/write
  LV Creation host, time linux, 2013-04-25 19:25:29 +0000
  LV Status              available
  # open                 0
  LV Size                <126.96 GiB
  Current LE             32501
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:2

Apart from the warnings, this seems to tell me that the logical volume path were rather /dev/system/home, while the pvdisplay command shows /dev/mapper/sda4_crypt to be a physical volume:

  WARNING: PV /dev/mapper/sda2_crypt in VG system is using an old PV header, modify the VG to update.
  WARNING: PV /dev/mapper/sda4_crypt in VG system is using an old PV header, modify the VG to update.
  --- Physical volume ---
  PV Name               /dev/mapper/sda2_crypt
  VG Name               system
  PV Size               <21.93 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              5613
  Free PE               0
  Allocated PE          5613
  PV UUID               4ZpFcU-CsmK-9JsR-O1eG-RDlI-8aTa-FB97Et

  --- Physical volume ---
  PV Name               /dev/mapper/sda4_crypt
  VG Name               system
  PV Size               126.96 GiB / not usable <4.41 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              32501
  Free PE               0
  Allocated PE          32501
  PV UUID               2XDQmQ-WR8a-3bKR-AdjE-dVVa-yael-xJN3Qj

Finally, I tried to apply lvresize to /dev/system/home:

  WARNING: PV /dev/mapper/sda2_crypt in VG system is using an old PV header, modify the VG to update.
  WARNING: PV /dev/mapper/sda4_crypt in VG system is using an old PV header, modify the VG to update.
fsck from util-linux 2.35.2
/dev/mapper/system-home: Inode 3410128 extent tree (at level 1) could be shorter.  IGNORED.
/dev/mapper/system-home: 175972/8323072 files (1.6% non-contiguous), 13931353/33281024 blocks
  Size of logical volume system/home unchanged from <126.96 GiB (32501 extents).
  Logical volume system/home successfully resized.
resize2fs 1.45.6 (20-Mar-2020)
The filesystem is already 33281024 (4k) blocks long.  Nothing to do!

The filesystem block count times 4k is exactly what fdisk -l shows me to be the number of bytes of /dev/mapper/system-home: 136319074304 bytes. And this is the same before and after adding the previously unused space by growing.

What do I have to do to include the additional space?
And: is it OK that I have to use lvresize on /dev/system/home rather than on sda4_crypt (or cr_ata_...) to get any action (as opposed to your suggestion)?
Can I now proceed to shrink sda4 by 1024 (or rather 512)M by applying lvresize to /dev/system/home ?

6

Re: [Solved] shrinking encrypted LVM partition + touchpad mouse click

Sorry, I made a mistake earlier in the instructions.  Incorrectly passed the PV (Physical Volume) name when trying to shrink the LV (Logical Volume) with the lvm lvresize command.  See correction to step (2) in earlier post.

Yes proceed with the steps, shrinking by 512M instead of 1024M if you want.

7

Re: [Solved] shrinking encrypted LVM partition + touchpad mouse click

I was in doubt, but that makes it clear.
In the meantime, I have done all the steps and boot into the system with the larger /boot partition works fine.

Thank you very much for your help.