1

I want to move my unallocated space so I can expand my ext4 Linux partition. Here is what gparted shows now.

/dev/sda 465 GB

Partition   lock filesystem mount pt      size   used   free    flags
/dev/sda1   Y   FAT32       /boot/efi    260 MB  38 MB  222 MB   boot hidden esp
/dev/sda2   !   unknown                   16 MB                  mftres
/dev/sda3       bitlocker                243 GB                  msdtdata
unallocated     unallocated              124 GB
/dev/sda5   Y   linux-swap                19 GB  19 GB
/dev/sda6   Y   ext4        /             79 GB  70 GB    9 GB
/dev/sda4       ntfs                       1 GB 551 MB  449 MB   hidden diag

How do I do this? Thank you.

K7AAY
  • 17,202
  • 2
    You don't move the unallocated space, you move the partition which is in the way (swap partition sda5) to the left. https://askubuntu.com/a/1176013/590937 – mook765 Nov 11 '19 at 19:04
  • 1
    Moving partitions can be bad for data, backup all important data first. – crip659 Nov 11 '19 at 19:35
  • The answer can depend on which version you are using. Please click [edit] and tell us the version number you are using. Please don't use Add Comment, but use [edit] instead. http://askubuntu.com/a/1187340/197910 may also be helpful. – K7AAY Nov 11 '19 at 19:41
  • Another alternative is to make a new partition and use it as /home. To move /home uses rsync- Be sure to use parameters to preserve ownership & permissions https://help.ubuntu.com/community/Partitioning/Home/Moving As mentioned in other comments, be sure to have good backups. – oldfred Nov 11 '19 at 21:41

2 Answers2

0

0) Changing partitions is risky. Please make a backup of your data, then verify the backup matches the source data; then backup again to a different drive or cloud, verify that matches the source, and only then start with partition changes.

00) Make one change at a time with gparted. After you specify a change (e.g., deleting the swap partition, if you decide that's OK), then click on the green check mark at top center to commit that change. Change-commit, change-commit, change-commit.

1) You can't change things unless the partition you want to change is unlocked. In this case, you must boot from a LiveDVD or a LiveUSB, such as was used to install Ubuntu in the first place.

2) If you are using Ubuntu 18.04 or newer, and you do not use Hibernation, you can eliminate the Swap Partition /dev/sda5 and give its space to /dev/sda6, then create a Swap File once you finish changing the partitions. Otherwise, if you either use Ubuntu 16.04 or older, or use Hibernation, you have to delete the Swap Partition and recreate it at the beginning of the unallocated space.

3) Once you have moved or deleted the Swap Partition, then you can move your ext4 Ubuntu partition, /dev/sda6, forward into unallocated space.

4) Once the move completes, then expand the end of the ext4 partition to occupy all remaining unused space. Thanks to heynnema https://askubuntu.com/users/4272/heynnema for the advice!

K7AAY
  • 17,202
  • It's my opinion that it's safer to move /dev/sda6 left, and then resize it to the right. – heynnema Nov 11 '19 at 20:47
  • @heynnema Based on personal experience (certainly not invalid), or documentation, or both? – K7AAY Nov 11 '19 at 21:09
  • 1
    Personal opinion/experience. I've never had some of the bad experiences that others have described, doing it that way. It may also effect having the desired "aligned partitions". – heynnema Nov 11 '19 at 22:08
0

Make sure that you have a good backup of your important Ubuntu files, as this procedure can corrupt or loose data.

Keep these things in mind:

  • always start the entire procedure with issuing a swapoff on any mounted swap partitions, and end the entire procedure with issuing a swapon on that same swap partition

  • a move is done by pointing the mouse pointer at the center of a partition and dragging it left/right with the hand cursor

  • a resize is done by dragging the left/right side of a partition to the left/right with the directional arrow cursor

  • if any partition can't be moved/resized graphically, you may have to manually enter the specific required numeric data (don't do this unless I instruct you to)

  • you begin any move/resize by right-clicking on the partition in the lower pane of the main window, and selecting the desired action from the popup menu, then finishing that action in the new move/resize window

Do the following...

Note: if the procedure doesn't work exactly as I outline, STOP immediately and DO NOT continue.

  • boot to a Ubuntu Live DVD/USB
  • open a terminal window by pressing Ctrl+Alt+T
  • type sudo fdisk -l
  • identify the /dev/sdXX device name for your "Linux Filesystem"
  • type sudo fsck -f /dev/sda6, replacing sdXX with the number you found earlier
  • quit fdisk
  • start gparted
  • move /dev/sda5 left
  • move /dev/sda6 left
  • resize /dev/sda6 right side to the right
  • click the Apply icon
  • wait for it to finish, then quit gparted
  • reboot
heynnema
  • 70,711
  • Thanks for the advice. I have used Linux distros for years but have hardly ever monkeyed around with the guts of the system. I am somewhat intimidated. I have backed up all of my essential files. I would like to keep Windows 10 for emergencies. – Calvin Norwood Nov 13 '19 at 03:42
  • @CalvinNorwood Don't be intimidated... we all had to learn this stuff... a little at a time. Yes, keep Windows 10. Good news on your backup. Take a leap of faith and believe that you can do this if you try. I'm here to help. – heynnema Nov 13 '19 at 04:02
  • @CalvinNorwood status please... – heynnema Nov 15 '19 at 14:29