0

When am trying to increase the root partition (/) on Ubuntu 16.04 using Gparted it failed and gave me this message.

# umount -v "/"
umount: /: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)

What other method can I use to extend my root partition.

While doing df -h returns

Filesystem      Size  Used Avail Use% Mounted on
udev            2.9G     0  2.9G   0% /dev
tmpfs           591M  8.9M  582M   2% /run
/dev/sda1       138G  111G   20G  85% /
tmpfs           2.9G  336K  2.9G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           2.9G     0  2.9G   0% /sys/fs/cgroup
/dev/sda5        20G  243M   18G   2% /boot
tmpfs           591M   68K  591M   1% /run/user/1000
/dev/sda3       197G   25G  173G  13% /media/kilasa/Personal-db
/dev/sda7       116G   17G   99G  15% /media/kilasa/Water
/dev/sda6       194G   59G  125G  33% /media/kilasa/Tutorials
/dev/sda4       176G   51G  125G  29% /media/kilasa/Wind

While lsblk returns

 NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 139.9G  0 part /
├─sda3   8:3    0 196.6G  0 part /media/kilasa/Personal-db
├─sda4   8:4    0 175.8G  0 part /media/kilasa/Wind
├─sda5   8:5    0  19.6G  0 part /boot
├─sda6   8:6    0 196.5G  0 part /media/kilasa/Tutorials
└─sda7   8:7    0 115.2G  0 part /media/kilasa/Water
sr0     11:0    1  1024M  0 rom  
sr1     11:1    1   128M  0 rom  

The screenshot I took from Gparted shows this

View Gparted Screenshot

Kafiti
  • 151
  • Can you run df -h and lsblk commands and share the output? –  Aug 12 '16 at 00:20
  • I have edit the question, added more infos. – Kafiti Aug 12 '16 at 10:28
  • 1
  • They aren't duplicate , root partition cannot be resolved with Gparted as many of the solutions from your question recommended. @Pilot6 – Kafiti Aug 12 '16 at 10:42
  • You need to boot from LiveUSB and you will be able to move any partitions. You ignore that step, that's why you have problems. – Pilot6 Aug 12 '16 at 10:47
  • if / was sda7 with unprovisioned space ahead of it, it would be possible to increase size inside OS itself. In your setup, you will need to boot with a live Linux disk or any other live utility that can resize Linux partitions without data loss. –  Aug 12 '16 at 10:53

4 Answers4

1

The error you received was because the partition was currently being used by your current session.

The only way to safely move/resize partitions is to boot from a Ubuntu LiveCD and use gparted. This way, the partitions on hard disk are not actively being used.

If you need further help, please post a screenshot of how gparted see's your disk configuration now. Please explain more about your intent for the final/new disk configuration. Then I can give a better recommendation.

heynnema
  • 70,711
  • I have edit the question,

    I only need to extend the root(sda 1) partition by adding unallocated 80gb from sda 2, need to left sda 3 and sda 4 unchanged. Sda 4 contains Windows file

    – Kafiti Aug 12 '16 at 10:30
  • I've taken a look at your gparted screenshot. Before I give you a recommendation, let me comment. It seems like you've partitioned off some of your data, rather than just using folders, and you're wasting a LOT of disk space this way. Are you dead set against modifying sda7, sda3, and sda4? Is your disk partitioned as MBR (or GPT)? What is the total disk capacity? Do you have a UEFI computer? Do you have any way to backup your NTFS and EXT4 partitions before moving anything? – heynnema Aug 12 '16 at 12:47
  • ps: where is your Ubuntu swap partition? – heynnema Aug 12 '16 at 12:59
  • The disk was partitioned as MBR only, its 1TB Hdd. The Pc is capable of UEFI. I can backup my data to an external disk, there is no swap partition there. – Kafiti Aug 12 '16 at 15:47
  • You forgot to answer this one... It seems like you've partitioned off some of your data, rather than just using folders, and you're wasting a LOT of disk space this way. Are you dead set against modifying sda7, sda3, and sda4? Lastly, what, if anything, is on sda5 /boot? Cheers, Al – heynnema Aug 12 '16 at 23:32
  • Since sda4 contains Windows File (am using dual boot) i don't want to disturb it. The rest can be recovered. – Kafiti Aug 13 '16 at 16:43
  • My first thought in consolidating your disk space was to move the files from sda7 and sda3, into folders on sda4 (and later extending sda4), then deleting sda7 and sda3 as they exist now. To do what needs to be done, safely, will take 2-3 steps. 2nd step would be to move sda1, and create swap partition. 3rd step would be to adjust various partition sizes, move sda4 and extend it. This would leave you with a somewhat standardized partition configuration. To set the swap, I need to know how much RAM you have. Are you onboard for all of this work? Do you have Windows install CD? – heynnema Aug 13 '16 at 17:02
  • I don't have Windows install CD, am having 6gb of RAM. – Kafiti Aug 13 '16 at 17:33
  • Create a Windows install disk by following the instructions at http://www.howtogeek.com/186775/how-to-download-windows-7-8-and-8.1-installation-media-legally/ – heynnema Aug 13 '16 at 17:38
  • Create a boot-repair DVD or USB flash key, by following the instructions at https://help.ubuntu.com/community/Boot-Repair – heynnema Aug 13 '16 at 17:41
  • Create a Ubuntu 16.04.1 DVD. – heynnema Aug 13 '16 at 18:00
  • I know those two steps, I have through those several times but it looks like I have had a little knowledge about how to partition my harddrive. Could you suggest the right partition table for me. -Need to have 250gb of root -200 of Windows – Kafiti Aug 13 '16 at 18:07
  • See my new answer, below... ps: you'll still need to create the 3 bootable disks that I mention. – heynnema Aug 13 '16 at 18:21
0

Answer for final partitioning:

sda2 extended partition

- sda5 boot
- sda1 Ubuntu ~300-400GB (check UUID in /etc/fstab)
- sdax swap ~6-8GB (edit/add /etc/fstab with UUID)

sda4 Windows ~300-400GB

It sounds like I should let you figure out how to accomplish this on your own. It's taking too much of my time. Cheers, Al

heynnema
  • 70,711
0

As the extended partition starts immediately after your root partition it is not that easy to extend your root partition, even when booting from Live CD, without destroying the data in your other partitions.

One simple way could be:

Find out which subfolder could fit into the empty space on your disk (> 80GiB):

sudo du -hs /* (this will show the usage of the toplevel directories).

Those mounted in /media, /boot, etc are not interesting, so do system directories as you cannot move them in a running system. Maybe your /home directory is worth moving and fits into 80 GiB. Or some subdirectory - just for the idea.

Create a partition in the empty space and format it (e.g. ext4).

Mount the newly created partition with sudo mount /dev/sdax /mnt. Move the contents of the respective folder to /mnt. In case of /home, you will meet some errors as not all files may be moved (when logged in as normal user). You may temporary create a user with sudo rights and home directory outside /home.

Umount /mnt and add a line in fstab to permanently mount the new partition at the directory whose contents you moved (e.g. /home).

This is contrary to what heynnema stated (folders contra partitions), but to me has been a proved solution throughout the last 25 years.

Edit:

I just read the comments on your question completely. My solution would not give you the space you require for / and windows (> 250GiB). Maybe if you backup the data in /dev/sda7 (/media/kilasa/Water) and delete this partition then gparted allows you to move the start of the extended partiotion (I never tried this; do it at your own risk). Then you can extend the root partition and the filesystem in it (as it is ext4, it is possible even if the partition is mounted, see man resize2fs; don't know if gparted allows to do so). You may the create a new NTFS-FS in the empty space after /dev/sda5 and restore your files from the backup. Thus you would not have to touch your windows system partition.

ridgy
  • 2,356
  • However, by using the partition method, as the user did, each one is only 13-33% full, and the rest is unused wasted space. Instead, by using folders to separate files by project (water, wind, etc.), as I suggest, you can now allocate all that reclaimed space to / and C:, exactly what the user wanted. – heynnema Aug 13 '16 at 21:14
  • @heynnema You are right, and i do not disagree in preferring folders over partitions. My only suggestion was to ease the solution of the problem; if a complete repartitioning would not mind your suggestion should be followed anyway. – ridgy Aug 13 '16 at 21:23
  • Yes, unfortunately the user has created a partitioning "problem", and I just couldn't spend more time than I already did. Cheers, Al – heynnema Aug 13 '16 at 21:41
-3

In gparted, Rclick the partition to the R of /, select 'unmount'. Rclick on the unmounted partition, delete it. Then Rclick on your / partition (doesn't matter if it is mounted), select 'resize', and expand into the empty space.

If you don't want to delete the partition that is to the right of /, you can delete a partition to the left of /, then copy the partition to the right of / into the empty space by opening a terminal (ctrl+alt+t) then $ sudo dd if=/dev/sd!!! of=/dev/sd@@@ where sd!!! is the partition you want to copy, and sd@@@ is the partition you want to delete. Make sure sd@@@ is unmounted. You may prefer to use $ copy if=/dev/sd!!! of=/dev/sd@@@, if you have formatted sd@@@ as ext4.

If you want to move / to the left, you will have to close the computer then reboot into a live usb/CD, unmount / partition, then shift it to the left (which can be very time consuming).

Of course, you can only copy a partition into a space at least as large as that which you copy. You may need to shrink a partition by unmounting it, then (using gparted) resizing it. After you copy it, you can expand it to fill empty space in the partition. To do this, in gparted Lclick the partition, select 'Partition' from the dropdown menu, then select 'Disks' from the menu, and the next option for repair or somesuch.

In effect, you can use gparted to totally re-arrange your partitions' alignment. You can delete the swap space (after first Rclick and select 'swapoff', then recreate it.

The drawback to doing this is boot-up time blows out, I suspect root partition is not sure where swap has moved to. Perhaps someone can enlighten...

aarn
  • 80
  • TOTAL unmitigated bunk. How can you recommend that the user delete partitions to the right/left without knowing what's on those partitions? How can you recommend deleting/recreating swap without also discussing having to edit /etc/fstab? 99% bunk. Sheesh. – heynnema Aug 11 '16 at 21:33
  • "the partition to the R of /" is the extended partition; this one is not mounted, and cannot be deleted without deleting all partitions contained in it. – ridgy Aug 13 '16 at 20:59
  • Ridgy - sorry I didn't check the details/gparted s-shot of your original post. Looks like there is some good advice here concerning re-allocating space. You might make use of an external storage device, to temporarily move those resized partitions. gparted is a great tool. Good luck – aarn Aug 14 '16 at 23:36