1

I am trying to delete my linux-swap partition /dev/sda5 and allocate the free space to /dev/sda6.

But when i try to delete sda5 GParted gives an error "You have to umount sda6". But i can not umount sda6. I gives me the error "umount: /: target is busy" If i reduce the size of sda5 i can not allocate the unallocated space to sda6.

Can anyone give me some advice on how to do this the right way?

I have a multi-boot system with windows and Linux. (Grub2)

enter image description here

6
  • 1
    Neither of those addresses his problem. Jun 13, 2018 at 23:08
  • If you happen to be running a remote (no direct access) system, live media is of limited usefulness. If the system had been setup to use LVM, you could have changed that swap partition to another chunk of the volume group containing /, and extended the filesystem with little impact. Jun 13, 2018 at 23:50
  • @Dafnie, first you'll need to get the last sector of your swap partition. Review the output of parted /dev/sda unit s print. If the start/end sector range of your swap partition is not AFTER the start/end range of your / partition, abort this procedure. Otherwise make a note of the end sector of the swap partition. Next, turn off your swap partition with swapoff -a. Next, edit /etc/fstab and remove the entry for your swap partition... Jun 14, 2018 at 15:26
  • ...Next, delete the swap partition with parted /dev/sda rm 5 Removing that partition will likely change the partition number for /, so run lsblk to get the correct partition number for /. Next, resize the / partition with parted /dev/sda unit s resizepart ROOT_PART_NUMBER_HERE LAST_SECTOR_HERE. Finally, you can grow the filesystem online with resize2fs /dev/sdaROOT_PART_NUMBER_HERE... Jun 14, 2018 at 15:27
  • ...Before running any of these commends, I highly recommend you have backups for everything; Basically you accept the possibility of wrecking your entire disk. And that you read the documentation for the commands so you know what they do and can adjust accordingly. Jun 14, 2018 at 15:27

2 Answers 2

2

As you can see in the image, sda6 is an ext4 partition that's mounted as /. That's the main node of your system, so it will stay busy as long as the system is up. You need either a live USB/DVD session or to connect the drive under another running system and perform the operation from there.

2
  • Thanks for the answars. I booted on a Linux USB and removed the swapdrive this way. 1. Disabled swap by rightkliking the swapdrive. 2. Unmount the swapdrive. 3. Delete the swapdrive. 4. expand the / drive 5. Edit /etc/fstab and remove the entry for your swap partition.
    – Dafnie
    Jun 16, 2018 at 19:28
  • @Dafnie Well done.
    – user147505
    Jun 16, 2018 at 19:30
0

Here's how you can remove your swap partition and use the free/unallocated space for your / partition.

Warning

But first... Before running any of these commands, I insist you have backups for everything. This is so important it's worth mentioning twice: no backups? Do not proceed.

By proceeding you accept the possibility of wrecking your entire disk. That's the nature of manipulating partitions.

Procedure

  1. Get the last sector of your swap partition. Review the output of parted /dev/sda unit s print. If the start/end sector range of your swap partition is not AFTER the start/end range of your / partition, abort this procedure. Otherwise make a note of the end sector of the swap partition.

  2. Turn off your swap partition with swapoff -a.

  3. Edit /etc/fstab and remove the entry for your swap partition.

  4. Delete the swap partition with parted /dev/sda rm 5. Removing that partition will likely change the partition number for /, so run lsblk to get the correct partition number for /.

  5. Resize the / partition with parted /dev/sda unit s resizepart ROOT_PART_NUMBER_HERE LAST_SECTOR_HERE.

  6. Grow the filesystem online with resize2fs /dev/sdaROOT_PART_NUMBER_HERE

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .