I have a laptop with a single HD that shipped with Windows on 2 primary partitions (PPs) /dev/sda1 and /dev/sda2. I subsequently dual-booted by adding PP=/dev/sda3 for /boot and an extended partition with a single logical partition /dev/sda5 for the rest of my Linux install and data (inside LVM logical volumes (LVs) inside a LUKS container).

I want now to "eat" the Windows install and reallocate its diskspace to the Linux partition, which would now presumably be a primary and not a logical (since I would now have 2 partitions instead of 4). As currently, the Linux partition would still be entirely allocated to a LUKS container, which in turn would still be entirely allocated to LVM LVs. I'd like to know,

  1. What is the "general procedure" for this task? Is this process already documented somewhere? If so, please point to doc and I will RTFM.
  2. Am I using the correct vocabulary to describe what I want to do?
  3. Is there essential detail I have omitted below? If so, please lemme know and I will edit.

FWIW, I have

  • good backups for /home
  • freespace on backup drives sufficient to create backups for the other 'real' top-level dirs/folders currently in / (i.e. /bin , /.config , /etc , /lib , /lib64 , /opt , /root , /sbin , /tmp , /usr , /var)


current state

Following is the PC's current lsblk table, slightly edited:

NAME                  MAJ:MIN   SIZE  TYPE  POINT   NOTES
sda                     8:0   465.8G  disk
├─sda1                  8:1    16.6G  part          [1]
├─sda2                  8:2    97.7G  part          [2]
├─sda3                  8:3     500M  part  /boot
├─sda4                  8:4       1K  part          extended
└─sda5                  8:5     351G  part          logical
  └─LVM2_crypt        254:0     351G  crypt         LUKS
    ├─LVM2_crypt-swap 254:1     3.9G  lvm   [SWAP]
    ├─LVM2_crypt-root 254:2      20G  lvm   /       [3]
    └─LVM2_crypt-home 254:3   327.1G  lvm   /home   [3]

[1]: sda1 is a bootable Windows Recovery Environment PP with GRUB ≅

menuentry 'WRE (loader) (on /dev/sda1)' --class windows --class os ...
    insmod part_msdos
    insmod ntfs
    set root='hd0,msdos1'
    parttool ${root} hidden-
    drivemap -s (hd0) ${root}
    chainloader +1

[2]: sda2 is a bootable Windows PP with GRUB ≅

menuentry 'Windows 7 (loader) (on /dev/sda2)' --class windows --class os ...
    insmod part_msdos
    insmod ntfs
    set root='hd0,msdos2'
    parttool ${root} hidden-
    chainloader +1

[3] Currently I frequently see low-space warnings on my filesystem=/: after freeing space (with a script) from "the usual suspects" I usually have freespace ≅ 500 MB. This is a problem, esp since there's software I'd like to install (but can't). I also have freespace < 5% on my FS=/home: less of a problem, but will need fixing before too long.

desired final state

I want to reclaim the Windows diskspace (114 GB ≅ size(current(sda1)) + size(current(sda2))) and reallocate it to new resizeable parts of my FS=/ . Hence I envision something like

me@it: ~ $ lsblk_magic_8_ball
                                              MOUNT   CURRENT
NAME                    MAJ:MIN   SIZE  TYPE  POINT   SIZE
sda                       8:0   465.8G  disk          same
├─sda1                    8:1     500M  part  /boot   same
└─sda2                    8:2   465.3G  part          size(sda) - size(sda1)
  └─LVM2_crypt          254:0   465.3G  crypt         LUKS all of sda2
    ├─LVM2_crypt-swap   254:1     3.9G  lvm   [SWAP]  same
    ├─LVM2_crypt-etc    254:2     1.0G  lvm   /etc    currently du=27M
    ├─LVM2_crypt-lib    254:2     1.0G  lvm   /lib    currently du=400M
    ├─LVM2_crypt-opt    254:2     1.0G  lvm   /opt    currently du=386M
    ├─LVM2_crypt-tmp    254:2     1.0G  lvm   /tmp    currently du=640k
    ├─LVM2_crypt-usr    254:2      10G  lvm   /usr    currently du=5.3G
    ├─LVM2_crypt-var    254:2      20G  lvm   /var    currently du=11G
    ├─LVM2_crypt-root   254:2      20G  lvm   /       [1]
    └─LVM2_crypt-home   254:3   407.1G  lvm   /home   [2]

[1]: My current LV size(/)=20 GB and du(/) ≅ 500 MB. I would retain that size, but would be moving sub-FSs with current du(/etc , /lib , /opt , /tmp , /usr , /var) ≤ 17.2 GB out of LV=/ into their own LVs.

[2]: I intend to create size(new LVs) ≅ 24 GB out of reclaimed Windows diskspace ≅ 114 GB. That would leave 80 GB which I would add to LV=/home.

IMHO I understand how to create the new LVs inside the enlarged LUKS container. What I don't know--and am asking about--is how to get the space currently consumed by Windows PPs into the new-and-enlarged Linux PP to host that enlarged LUKS container. Your enlightenment is appreciated.

  • 1
    Given that you have good backups, and aren't needing the data on the windoze partitions, it might be easier to get what you want with a fresh install of the distro of your choice. I think that a fresh install would be less difficult to pull off than multiple re-partitioning and encryption operations on a running system. – datUser Sep 1 '17 at 12:48
  • In a nutshell, you can only expand partitions to the right. So to do this sort of thing you'd need to be able to clear enough space on the left-most partition (beginning of disk) to contain the data you want to keep, the copy the data, then delete the old partition(s), then expand the remaining partition to consume the rest of the disk, and finally resize the filesystem on the partition. In your case, it's even more complicated due to having LUKS and LVM. That's the general procedure. It's not documented because everyone's case is different. Take datUser's advice: reinstall. – Emmanuel Rosa Sep 3 '17 at 2:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.