Score:-3

Merge two logical partitions (or unallocated space and a logical partition) not next to each other

ec flag

The space on my Linux Mint partition ran out, so I resized my shared data partition in order to assign the space to my Linux partition. I resized the whole Linux partition using GParted but it just put the unallocated space inside the Linux partition (without moving the partition leftwards). Now the first logical partition of the Linux partition is in the middle of the unallocated space and the second logical partition (which I want to enlarge with the unallocated space). Can I merge them together somehow (moving sda5 leftwards was disabled for some reason)? Below is a photo of my situation:

  • /dev/sda1 is the Windows boot partition
  • /dev/sda2 is Windows proper
  • /dev/sda3 is the partition, which I use on both Windows and Linux
  • /dev/sda4 is the Linux partition
    • the unallocated space is first
    • then comes /dev/sda5 - one of Linux's logical partitions
    • /dev/sda6 is the second logical Linux partition

Is there a way I can enlarge /dev/sda6 with the unallocated space without reinstalling Linux? There are similar problems out there but I wanted to make sure I receive advice particularly for my situation.

EDIT: I uploaded the question here, because I considered such a problem identical in both Linux Mint and Ubuntu. Excuse me for being off-topic.
enter image description here

mook765 avatar
cn flag
Linux Mint is off-topic here. But the soulution for this very basic problem is to move `sda5` to the left first, then you can resize `sda6`. Boot from live media, you cannot resize the partition while it's mounted.
Kotaka Danski avatar
ec flag
Moving `sda5` left was disabled due to some reason but I managed to get that out of the way and moved it left. I booted from a Mint USB. `/dev/sda6` was mounted so I unmounted it. Now I could move it left as well and started the process. I will continue to post comments on what I did for future visitors.
Kotaka Danski avatar
ec flag
I managed to do it, so I'll post an answer. Thanks for the directions.
Kotaka Danski avatar
ec flag
Obviously, my question is poorly written. It was disliked into oblivion but there's no feedback why. Dear users, who visit this page. Please write a comment on why you disliked the question, so I can fix it. I can't read your thoughts and I am not supposed to know the culture of this forum from the first post.
guiverc avatar
cn flag
Only Ubuntu and official flavors of Ubuntu (https://ubuntu.com/download/flavours) are on-topic here, refer to https://askubuntu.com/help/on-topic where you'll find other SE sites where you question will be welcome if you don't want to use a Linux Mint forum. (*One advantage of Ubuntu is it's many support options, you opted for Linux Mint so take advantage of it's support options, or SE Unix & Linux*)
guiverc avatar
cn flag
I suggest you read the *Mint* tag you actually used; also looking at the upvotes on the prior comment would have provided a *possible* clue as to downvotes, ie. off-topic. You can never know why people downvote/upvote, but going outside of site rules can get downvotes. Thank you though for trying to share your answer & thus help later readers. This isn't a Linux support site (*you mention Linux in your answer!*) but a Ubuntu one, so it should state Ubuntu for this site.
Kotaka Danski avatar
ec flag
@guiverc I assumed that since Linux Mint is based on Ubuntu, that the problem would be nearly identical in both distributions. Thanks for the feeback. Now I know what to fix :-)
np8 avatar
cn flag
np8
I think this would be on-topic if only the words *Linux Mint* would be replaced with *Ubuntu*.
Score:1
ec flag

Thanks to @mook765 for confirming the steps towards accomplishing this task. Here's a list, based on what I did:

  • If you take space from a Windows partition, shrink or erase that partition in Windows, not in Linux. You can resize the C partition but you shouldn't erase it (you will brake your Windows OS).
  • Always prefer to extend a partition rightwards, not leftwards, because in that case the process is self-explanatory, unlike expanding leftwards
  • You can't mofify a partition, which is in use at the moment. That's why you will have to boot Linux from a drive, different than the one, you are resizing (Live Media). I personally used the USB stick, which I used to install Linux in the first place. You can use a CD, too. If you don't keep the media, which you used to install Linux, you can burn one (e.g. with Etcher).
  • Always apply the pending changes in GParted one by one. Otherwise, options such as moving leftwards, changing size etc might be unavailable.

If you do need, to resize from the left, do this:

  • Turn off your computer
  • Stick the USB stick
  • Turn on your computer
  • If you have dual-boot, it's possible that the Grub menu won't display the option to burn from CD/USB. That's why, open the BIOS menu before the Grub menu appears. Select "Boot from your-device-name". My shortcut to the BIOS was F9
  • install gparted (if you don't have it): sudo apt install gparted
  • install boot-repair (if you don't have it): sudo apt install boot-repair
  • open gparted
  • unmount all partitions
  • select the first logical partition, which you want to resize and move left (sda5 in my case) and choose "Resize/Move". I set up 0MB free space on the left
  • confirm and exit the context window.
  • apply the pending changes
  • Now repeat for the second logical partition - in my case sda6
  • apply the pending changes (it may take several hours)
  • I personally received an error in the end of the process: The original files had been moved leftwards and the partition sda6 was expanded but the enlarged space wasn't allocated enter image description here
  • in such case, select the problematic partition and "Check" it.
  • I received an error yet again, citing the operation wasn't successful. I decided to turn off my computer and boot it again using the live media
  • this time, checking the partition helped and the free space was allocated
  • the last thing to do is make sure your Linux system can boot. If the Linux partition, that you moved, contains the boot folder (like mine did), it is likely that GRUB won't be able to find it, so you wouldn't be able to boot any OS on your PC. That's why I preemptively installed boot-repair. After the successful resize and reallocation of memory, I ran boot-repair and chose the default option, which should fix any issues with booting
  • That's all. Turn off your PC and remove the live media. Now, when you turn it on, everything should be working as expected.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.