Search code examples
linuxwindowsmountdiskdiskspace

How to use free space in linux?


The computer has 2 systems installed: linux and windows and 1 ssd disk. At some point linux started to run out of memory. So I created free space by separating it from the main partition (where windows was installed, with Aomei Partition Assistant), hoping that I could attach it to the linux partition. And question: How to attach partition (1) to partition (2), (see screenshot)? Can you please tell me how! enter image description here


Solution

  • short answer: what you try to achieve is not easily doable without commercial tools. It demands a reshuffling of the partitions on disk.

    long answer:

    1. The partition /dev/sda4 marked with 1 on the screenshot does not correspond to the free space you split of from the Windows partition. The Partition 1 marked on the screen shot is a so called "extended partition" (label: /dev/sda4), which contains all the logical partitions /dev/sda[5-7]. This can be easily seen if you compare the start and end sectors of those partitions. /dev/sda4 starts at 200941566 and ends at 247945215. In the same range are the partitions /dev/sda[5-7].
    2. The free space split off from the Windows partition is from sector 158208057 to 247945215. Unfortunately this sector range is physically not close to your linux partition. The neighboring partitions are /dev/sda1 (your windows partition) and /dev/sda2 (Windows Recovery partition).

    Solutions:

    a) Since you already have 4 primary partitions, you cannot create a new partition to use the empty space. The maximum number of primary partitions for the legacy partition table you use is 4. You can only assign the space to any of the existing neighboring partitions, i.e. /dev/sda1 or /dev/sda2.

    b) To be able to use the free space for linux, the two rescue partitions would have to be moved right to the end of the windows partition, then the extended partition would have to be expanded into the free sectors and then /dev/sda5 could be extended with the free space. I am not aware of any free tools which do that reliably. All this moving, shrinking and extending of partitions demands that the tool used knows the partition table and is able to read / write / modify all involved filesystems.

    c) Save all your important work from the linux installation. Remove the extended partition. Move the two windows recovery partitions (/dev/sda2 and /dev/sda3) next to the windows partition and create a new extended partition with logical partitions for your linux installation.

    d) Get rid of the Windows recovery partition /dev/sda2 and create a new, larger partition which contains also the freed space. Depending on where you need the space in Linux, you could mount /home (all your data) or / (all the operating system data) on that volume. As a downside, you will lose some windows recovery functionality.

    Best regards, Marc