1

I have a dualboot system with fedora 27 and windows 10. I am running out of space on my linux volume group (i.e. partition) and I don't have unallocated space. I've read that I might need Gparted and that maybe resize2fs can be used to increase a linux partition (reference 1, reference 2) but all those cases were dealing with extending the root partition where unallocated space already exists.

Output of df -h

Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G  192M  3.7G   5% /dev/shm
tmpfs                    3.9G  2.0M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/fedora-root   43G   32G  8.1G  80% /
tmpfs                    3.9G   14M  3.9G   1% /tmp
/dev/sda5                976M  196M  713M  22% /boot
tmpfs                    789M   16K  789M   1% /run/user/42
tmpfs                    789M   11M  778M   2% /run/user/1000
tmpfs                    789M     0  789M   0% /run/user/0

and ouput of fdisk -l

Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 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
Disklabel type: dos
Disk identifier: 0xb72b0508

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048   1026047   1024000   500M  7 HPFS/NTFS/exFAT
/dev/sda2         1026048 395909025 394882978 188.3G  7 HPFS/NTFS/exFAT
/dev/sda3       498311168 500113407   1802240   880M 27 Hidden NTFS WinRE
/dev/sda4       395909120 498311167 102402048  48.8G  5 Extended
/dev/sda5       395911168 398008319   2097152     1G 83 Linux
/dev/sda6       398010368 498311167 100300800  47.8G 8e Linux LVM

Partition table entries are not in disk order.


Disk /dev/mapper/fedora-root: 43 GiB, 46103789568 bytes, 90046464 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


Disk /dev/mapper/fedora-swap: 4.9 GiB, 5247074304 bytes, 10248192 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

My partitions are: enter image description here

Windows 10 has 80 GB of free space. I want to take 70 GB from Windows and give it to fedora. How do I do this without losing either or both of my operating systems and any data? Can I shrink windows first to create unlocated space or should I create a partition of 70 GB inside the windows partition? If so can I do this inside windows else if I have to use Gparted can I download it to my external hard drive which contains other files or is a blank memory stick necessary?

My linux partition was created in windows before installing fedora using rufus and I have roughly 5 GB of swap. If possible I would also like to increase the size of the swap to match my RAM size because I find my system tends to use up all of my swap partition.

  • There's a discrepancy between your fdisk output and what's being reported by Windows. fdisk suggests that you have 3 primary partitions and an extended partition containing 2 logical partitions, yet your Window screenshot is listing everything as a primary partition, which is impossible: You can only have a max of 4 primary partitions. I'm assuming fdisk is correct, which means you're maxed out at 3 primaries and 1 extended partition. So even if you shrink the Windows partition to create unallocated space you can't use it because said space would be outside of the extended partition... – Emmanuel Rosa May 16 '18 at 12:41
  • ... In other words, with your current setup all you can do with free space is create more logical partitions, but you don't have any free space on that area of the disk. Instead of shuffling partitions, which would waste quite a bit of time and may not work, I recommend deleting the extended partition, shrinking the Windows partition, move the "Hidden NTFS WinRE" that's all the way at the end of the disk to create a single continous unallocated space, and reinstalling Linux. There are ways to backup and restore, but... no offense it requires significant expertise. – Emmanuel Rosa May 16 '18 at 12:49
  • To sum up what @EmmanuelRosa said, you are better off dumping a backup of everything important on external media and re-partitioning your box. – ajeh May 16 '18 at 14:20
  • @EmmanuelRosa I was hoping this would be fairly easy. So are you saying it is not possible to add free space to root? If windows and fdisk -l are reporting two different things then maybe I will try confirming it with Gparted. When you say there are ways to back and restore what do you mean? Can you be more explicit? It should be doable. – MyWrathAcademia May 16 '18 at 18:27
  • @EmmanuelRosa do you mind writing an answer detailing the steps you recommend? I wanted to avoid having to re-install linux but if your instructions are understandable then I will consider it. – MyWrathAcademia May 16 '18 at 18:28
0

You can reduce windows partition C which has 80G free, using the windows disk manager itself.

Once done, you won't be able I think to add the newly unallocated space to your LVM, but you can create some new partition(s) that you could then mount in your Linux to hold data on specific mount-point(s) (/home or whatever).

  • I thought that the stated purpose of LVM was to be able to add space. So he should be able to add that freed space, I think. – ajeh May 16 '18 at 14:19
  • Yes, you can add multiple partitions to an LVM volume group. The problem in this case is that the OP cannot add any more partitions. So even if a partition is shrunk to create unallocated space, the space cannot be used. – Emmanuel Rosa May 16 '18 at 16:48
  • @tonioc thats a good idea but what are the disadvantages of mounting a partition in Linux compared to creating a logical volume? For example can I install programs on it like I do for root ( / )? When I installed linux I only created a root partition and no $HOME. If I mounted this new partition to $HOME would it be thesame as increasing the size of $HOME by say 70 GB, that is would the total space in home then be continuous and not separated in two? I'm guessing your suggestion would be similar to the way an external hard drive works, right? – MyWrathAcademia May 16 '18 at 18:41
  • @tonioc Just to mention, my home and root are not separate, instead my root contains home. Would I still be able to mount the new partition to hold data on points like /home? – MyWrathAcademia May 16 '18 at 20:11
  • I was maybe wrong when stating you could not use the free space in your LVM structure. You may create a new PV with it and then add this PV to your existing VG, and then: either create new LVs to add them as specific mount-points, or use a live CD to extend you / LV (which I would discourage). – tonioc May 17 '18 at 17:36
0

I ended up using the terminal but before that I used GParted live to shrink the windows partition to create unallocated space. The problem with GParted was that after adding this unallocated space to the extended partition, my boot partition was in between this new space and my logical volume group, so I switched to command line which is easier to use.

Here's what I did:

Before switching to the terminal I first of all converted the unallocated space to a partition named /dev/sda7. I did this in GParted and chose ext4.

Now keep in mind that the following works only for lvm.

  1. Created physical volume

    pvcreate /dev/sda7

  2. Extended volume group to make use of this physical volume

    vgextend fedora /dev/sda7

    Note: I found my volume group name by running the command: vgdisplay. vgs also works.

  3. Activated logical volume to make it available in order for file system check and resizing to work.

    lvchange -ay /fedora/root

    OR

    vgchange -ay

    The -a option stands for activate and -y means on all existing devices, so it looks everywhere.

  4. I performed a file system check to make sure there were no errors. This actually found some errors and fixed it.

    e2fsck /dev/fedora/root

  5. Resized the file system

    resize2fs -l 100%FREE /dev/fedora/root

    If you want to increase the size by an absolute number like 50 GB then use the -L option.

  6. Again performed another file system check to fix any errors

    e2fsck /dev/fedora/root

    You can now check that your root has been enlarged by running lsblk or similar commands which show partitions.

    After this, I also increased my swap logical volume by well over 50%, and it was just as easy although steps are slightly different, for example there is no need for e2fsck since that only works for ext 2, 3, 4 file systems.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.