Categories
Life hack

How to resize your ubuntu partitions

I’ve set my grandson’s laptop to be able to dual boot (Vista and Ubuntu). I’d like to give as much space as possible to Ubuntu as Windows isn’t used much. I’m pretty noob to Linux and have no real idea how to use gparted.

Here is a screenshot of gparted; it’d be great if someone could explain what it means and how to give more space to Ubuntu and less to Windows.

How to resize your ubuntu partitions

2 Answers 2

This is what to consider before we can change partition size:

  • Changing partitions always bears a risk of data loss. Therefore backup all valuable data.
  • Only partitions that are unmounted can be altered, i.e. work on a live session (boot Ubuntu “Try out”).
  • Ubuntu does not need much space (30 GB) but knowing that the other OS is Vista it may really be better to give Vista as little space as possible but not too small (or remove it entirely if you grandson agreed).
  • Ubuntu needs two partitions at least (root partition / , and swap) but it can handle more if needed. Some people recommend a seaparte HOME partition, which eases distribution upgrades and backups.
  • Swap needs to be in a single partition with no holes. It is therefore in the way when you enlarge your NTFS partition to hold Ubuntu.
  • Windows must not be hibernated.
  • We can only have 4 primary partitions in an MSDOS partition table. Make extended partitions to hold Ubuntu.

From your present partition layout it appears that the root partition for Ubuntu is a bit too small, and the swap partition is in the way of increasing your root partition.

It is possible to add a swap partition later but this may be too complicated for a first start into the Ubuntu universe.

Let me therefore recommend that you

  1. Backup all valuable data
  2. Delete and remove your existing Ubuntu partitions (this will delete all data in them!)
  3. Resize (shrink) the Windows partition (to the right side) according to the excellent answer you already have (but you may have to repair your filesystem from a Vista CD), or from Windows. Shrinking may need a defragmentation first.
  4. Re-install Ubuntu to the now sufficiently large unpartitioned space you will have gained in step 3.
  5. On re-installation of Ubuntu take care to select the unpartitioned space for installation of / , swap , and if applciable /home on “Do something else”, or let the installer automatically do this for your by choosing “Install alongside of Windows”.

I only have access to the server via a terminal and I can’t use graphical tools such as GParted!
I want to create a new partition from a part of the root (about 768mb) for swap.

3 Answers 3

You cannot shrink/edit a partition if any of the partition on the storage device is mounted. So in order to unmount and edit the root filesystem, the OS need to be shutdown. Then boot into a live system and edit the partition as described in other answers.

As an alternative to creating an entire partition, a swap file offers the ability to vary its size on-the-fly, and is more easily removed altogether. Swap file can be hot plugable. i.e can be added and removed without unmounting/turning off the OS.

Create a 512 MB file called /swapfile . This will be our swap file.

Set the right permissions (because a world-readable swap file is a huge local vulnerability):

After creating the correctly sized file, format it to swap:

Activate the swap file:

Edit /etc/fstab and add an entry for the swap file:

How to resize your ubuntu partitions

First of all is important to know that you cannot resize to shrink your root partition if you are using it (This is called online shrinking). You can only grow it online. This is supported by the resize2fs command. I will assume the following:

  • You don’t want to loose your information on the root partition.
  • You don’t have physical access to the hard drive in order to use a LiveCD. This can apply to a virtual environment or a remote one. In the case of a virtual one you can still manage to boot from a LiveCD if you set the VM to boot from a LiveCD. This is assumming the VM supports outputting the Desktop GUI from where you would run the Gparted app to resize easily. But since this is less likely I assume you can not.

There are 2 type of partitions that you can resize, the LVM partitions or Logical Volume Manager partitions which support Online resizing (Shrinking/Growing) since the creation of the galaxy and the standard partitions most of us use. Right now the only one that has almost 100% support of complete online resizing (Shrink/Grow) is the btrfs filesystem (Which is still in development). I will explain how to do the normal partitions most of us use in the ext4 filesystem.

Resizing (Growing) the Partition

To grow your partition you can do it with the root mounted. To do this simply do:

Provided you already have the empty space ready to be merged. Afterwards I recommend rebooting for the changes to take effect correctly. The command above would resize to the maximum permitted. If you wish to resize to a particular size then simply add the size at the end:

Note that if you want to specify 25.4 GB, you can not use the “.”. you would need to go down one unit of measure. In this case from GB to MB, so it would look like this:

This way you will have a partition of 25.4G

Resizing (Shrinking) the Partition

Shrinking the partition is a two step process which involves:

  • Reducing the size of the file system by the amount needed.
  • Reducing the size of the underlying block device to match that of the file system.

Before reducing the capacity of a file system you need to reduce the size of the block device (Which can be a partition or a logical volume). Since this is not available for any of the ext* file systems you won’t be able to shrink it from 20 GB to 19.5 GB to create the 500 MB swap one.

Even Ext4 does not support online shrinking. If you try to do it you will get the following:

Your only bet as far as I know is to either:

Install another Ubuntu version on the same server (On another partition) that can then be used to shrink the root partition of the original Ubuntu Server.

Install Ubuntu server from scratch with the size you actually want

Use the Ubuntu Server Live Image to resize the partition. For this case, you will need to get to this screen:

How to resize your ubuntu partitions

And choose the Resize option as shown in the image above. From there you will select what the new size will be since from here you can unmount the unit and shrink it if you want.

As an additional help here is the gparted filesystem suppor http://gparted.org/features.php which gives a very detailed list of supported ones and includes if they have full online resizing. Btrfs is amongst them.

How to resize your ubuntu partitions

The answer depends on whether you can unmount the partition to shrink, or not. In your case, you probably cannot unmount the partition. In Linux (UNIX/MAC OS), mounting a partition refers to using the file system and mapping it to the mount point (in your case / ). Unmounting means that you stop using the filesystem, and remove the mapping to the mount point. You cannot unmount the filesystem containing your running OS.

If the partition can be unmounted

Lets assume you want to shrink a 200GB ext4 partition on /dev/sda4 mounted to /data . It currently contains music and movies or similar, so you can temporarily unmount it. You want to create a 4GB swap.

to unmount the partition.

to resize the ext4 filesystem to 196 GB, assuming that there is enough space. Now, you have to shrink the partition. I currently belive you need to use cfdisk to delete the existing partition, and recreate a smaller partition in its place. You can then also create a new partition for the swap.

will give you a text-based gui to inspect your partition table. I would recommend you to print the partition table to a file or screen at that point, and take note of the current configuration as backup. You can then select /dev/sda4 and delete the partition. In its place, free space will be displayed. Use new to create a new partition with 196 GB in its place, and set the type to ext4. Then, move to the trailing free space and create the 4GB swap partition with type swap . Note: I did not test these commands, as I can’t play around with my / at the moment.

If the partition cannot be unmounted

You cannot shrink a mounted ext3/4 partition (see manpage of resize2fs ). As you are running your OS from / , you cannot unmount / . That means you have to boot another OS (e.g. from USB key) to do the changes.

In your case, it is a remote server (on KVM most likely), so you might not be able to boot from USB/ a live OS image. There might be other ways to change the partitioning from your vServer provider through an admin GUI. I believe that is your best bet currently.

@chrisbhoffman
Updated July 4, 2017, 1:48pm EDT

How to resize your ubuntu partitions

Whether you want to shrink your Ubuntu partition, enlarge it, or split it up into several partitions, you can’t do this while it’s in use. You’ll need a Ubuntu live CD or USB drive to edit your partitions.

The Ubuntu live CD includes the GParted partition editor, which can modify your partitions. GParted is a full-featured, graphical partition editor that acts as a frontend to a variety of Linux terminal commands.

Boot From CD or USB Drive

If you have the CD or USB drive you installed Ubuntu from, you can insert it into your computer and restart. If you don’t, you’ll have to create a new Ubuntu live media. You can download an Ubuntu ISO from Ubuntu.com and burn it a disc by right-clicking the downloaded ISO file and selecting Write to Disc.

How to resize your ubuntu partitions

If you’d rather use a USB drive, use the Startup Disk Creator application, which comes with Ubuntu. You’ll find it in the Dash.

How to resize your ubuntu partitions

Provide the Startup Disk Creator application with a Ubuntu ISO and a USB flash drive and it will create a live USB drive for you.

How to resize your ubuntu partitions

After creating the live media, insert it into your computer and restart. If the live environment doesn’t start, you may have to enter your computer’s BIOS and change its boot order. To access the BIOS, press the key that appears on you screen while your computer boots, often Delete, F1, or F2. You can find the appropriate key in your computer’s (or motherboard’s, if you assembled your own computer) manual.

Using GParted

While the GParted partition editor isn’t present by default on an installed Ubuntu system, it is included with the Ubuntu live environment. Launch GParted from the Dash to get started.

How to resize your ubuntu partitions

If you have multiple hard drives in your computer, select the appropriate one from the drop-down box at the top right corner of the GParted window.

How to resize your ubuntu partitions

Partitions can’t be modified while they’re in use – partitions in use have a key icon next to them. If a partition is mounted, unmount it by clicking the eject button in the file manager. If you have a swap partition, the Ubuntu live environment will likely have activated it. To deactivate the swap partition, right-click it and select Swapoff.

How to resize your ubuntu partitions

To resize a partition, right-click it and select Resize/Move.

How to resize your ubuntu partitions

The easiest way to resize a partition is by clicking and dragging the handles at either side of the bar, although you can also enter exact numbers. You can shrink any partition if it has free space.

How to resize your ubuntu partitions

Your changes won’t take effect immediately. Each change you make it queued, and appears in a list at the bottom of the GParted window.

How to resize your ubuntu partitions

Once you’ve shrunk a partition, you could use the unallocated space to create a new partition, if you like. To do so, right-click the unallocated space and select New. GParted will walk you through creating the partition.

How to resize your ubuntu partitions

If a partition has adjacent unallocated space, you can right-click it and select Resize/Move to enlarge the partition into the unallocated space.

How to resize your ubuntu partitions

To specify a new partition size, click and drag the sliders or enter an exact number into the boxes.

How to resize your ubuntu partitions

GParted shows a warning whenever you move the start sector of a partition. If you move the start sector of your Windows system partition (C:) or the Ubuntu partition containing your /boot directory – likely your primary Ubuntu partition – your operating system may fail to boot. In this case, we’re only moving the start sector of our swap partition, so we can ignore this warning. If you’re moving the start sector of your main Ubuntu partition, you’ll likely have to reinstall Grub 2 afterwards.

If your system does fail to boot, you can consult the Ubuntu wiki for several methods of reinstalling GRUB 2. The process is different from restoring the older GRUB 1 boot loader.

How to resize your ubuntu partitions

Click the green check mark icon on GParted’s toolbar to apply the changes when you’re finished.

How to resize your ubuntu partitions

Back ups are always important. However, back ups are particularly important if you’re modifying your partitions – a problem could occur and you may lose your data. Don’t resize your partitions until you’ve backed up any important data.

How to resize your ubuntu partitions

After you click Apply, GParted will apply all queued changes. This may take a while, depending on the changes you make. Don’t cancel the operation or power down your computer while the operation is in progress.

How to resize your ubuntu partitions

Restart your system and remove the CD or USB drive after performing the operations.

I’m using Ubuntu 20.04 and during the installation process I opted for manual partitioning, and I chose to keep root and home separate. So at the end, I obtained this configuration:

  • 650 Mb EFI partition (sdb3)
  • 20 Gb root partition @ / (sdb4)
  • 10 Gb swap partition (sdb5)
  • about 650 Gb partition (remaining free space) @ /home (sdb6)

Now I noticed that 20 Gb could be too little for root partition as this partition is already full for 80% of his dimension, so basically I may have been wrong to reserve only 20 Gb for it. I have to say that, at the moment, I haven’t particular problems with this configuration but maybe I could face them in the future.

Can I resize the root partition taking some space from home partition? As I see here How to resize partitions? I must use Gparted from liveUSB since it is not possible to modify mounted partitions, but as I explained home and root partitions aren’t close to each other (there is swap partition in between). Is this a problem?

NB.: There isn’t free space or unallocated space on sdb.

Additional informations: This is a dual boot stystem (on two different drives, win 10 is on sda). I did not mention “sdb1” and “sdb2” because before installing Ubuntu on “sdb” I chose to create (from win 10) a shared ntfs partition for both OS, here called sdb2, while sdb1 is an automatic generated partition labeled “Microsoft reserved partition”

A partition is the name given to each of the divisions that are present on a single physical storage device. For example, to illustrate, if you have several partitions, it is as if you had several hard drives on a single physical hard drive and each would have its file system and operation different from the others.

You can use these partitions for various things. For example you can use them only to store important data with security measures, you could also make backup copies of your files and use them to install different operating systems.

In operating systems such as Linux it will allow you to structure the disk into partitions for all the different files that this system uses. And that’s not all, you can also resize these partitions on your hard drive, and even install an operating system on an external hard drive .

In this article we will show you how to resize hard drive partitions in Ubuntu from your console easily. This time we will use the Ubuntu 13.04 operating system to do all the procedures.

How to resize hard drive partitions?

Although having the Linux system offers you many advantages, the truth is that one of its disadvantages is that unlike Windows, it cannot resize partitions of a hard disk or of a system that you are using. This occurs because in order to do this type of procedure, it is necessary to unmount the volume and resize it . Additionally there are differences between disk partitions .

We say that it is a disadvantage of Linux, since to do this same procedure in Windows you just have to go to its native disk management tool and from there you can resize the volume even if you are using the same drive where the Microsoft operating system is hosted.

Unlike Linux, it will not be necessary to unmount the drive volume and you can do the procedure in just a few minutes.

If you are here it is because you will do this procedure using Linux, but being different from Windows it is necessary that you do it from a Live CD or Ubuntu Live USB. In this article we will show you how to do it from the Live USB of Ubuntu version 13.04 as we mentioned earlier.

The first step you must follow is to reboot your system and boot it with the Ubuntu 13.04 Live USB, this process can be programmed directly from the Bios by selecting the USB device. Once your system has booted with the Live USB, you must open the Yumi program.

Previously installed, and select the Linux distributions option from its main screen and then the option to try Ubuntu 13.04 but without installing it on the hard disk. Once the Ubuntu desktop can be seen on the screen, you must follow these new steps that we will give you below.

What are the steps to follow to resize partitions?

Once you have started your system from the Live Distro, you must go to Dash and type the following: gparted

Now you must click on the icon and a window that is the main one of gparted should automatically appear on the screen, this is the one that will allow you to manage your hard disk drives.

You must select the Linux partition that has the EXT format, you must place your cursor on it and with your mouse right click, and in the options that were displayed choose the Resize / Move option .

You will be able to see a new window unfold where you will have to modify the partition that you have selected but without damaging the Ubuntu 13.04 operating system that will be hosted there.

For you to be able to resize the Linux partition, you have to go directly into the configuration and write in the text box the amount of space you want on the partition or by moving the upper bar to the left or right until you get the desired size.

When you have finished this procedure and you have the desired size or dimension, you must click again on the Resize / Move option and the process will start .

It will take at least a couple of hours until it is ready. And that will be the whole procedure that you are going to carry out, you will already be able to count on your resized Linux partition . Although it may seem a bit complicated, the truth is that when you start the process you will see that it is not difficult at all.

Do you have a hard drive partition on your Linux PC that you’d like to make bigger or smaller in size? Unsure about how to resize hard drive partitions on Linux? Follow along with this guide and soon you’ll know how to use the Gparted partition editor to resize hard drive partitions on Linux!

Resize a non-OS related partition with Gparted

You may have a hard drive partition on your Linux PC that isn’t in use by an operating system that you want to resize. Thankfully, non-OS related partitions don’t need to be accessed via Live disk. Since no operating system is using this partition, it can be resized directly on your current operating system with the Gparted application.

Resizing hard drive partitions on Linux can be done through the command-line and graphical tools. All of the different hard drive management tools available for Linux work quite well. However, in this guide, we’ll be focusing on the Gparted application, as it’s the easiest to understand for beginner Linux users.

Before we go over how to resize non-OS related partitions, you must install the Gparted app on your Linux system. To start the installation, open up a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Then, follow the installation commands that match the OS you currently use.

Ubuntu

Ubuntu users can install the Gparted app directly from the primary Ubuntu software repository with the following Apt installation command.

Debian

Gparted is in the “Debian Main” software repository for all versions of Debian Linux. To install it, use the Apt-get command below.

Arch Linux

For Arch Linux, the Gparted app is in the “Extra” software repository. To install it on your Arch system, ensure the “Extra” repo is enabled. Then, use the Pacman command below.

Fedora

Gparted is available to Fedora users in the primary Fedora repo. To install it, use the following Dnf command.

OpenSUSE

On OpenSUSE Linux, you’ll find the Gparted application in the “Oss all” repo. To install it, use the Zypper command below.

Once the Gparted application is installed on your Linux PC, press Alt + F2 to open up the quick-launcher, then, run the command below to open the newly installed application.

With the partition editor open, look for the drive that holds the partition you’d like to resize, by selecting it in the drop-down menu at the top-right section of the screen.

How to resize your ubuntu partitions

Let Gparted load the hard drive. After the app is done loading up the drive, find the specific partition you need to re-size, and right-click on it with the mouse to open up the right-click menu.

How to resize your ubuntu partitions

Choose the “resize” option in the right-click menu, and the “Resize/Move” partition will appear. From here, use the graphical resizer to drag the partition to make it bigger or smaller. Alternatively, find “New size (MiB)” and multiply it by 1024 to get it to exactly the right size. For example, to resize a 10 GB partition to 5 GB, you’d do:

When you’re satisfied with the new size of the hard drive partition, click the “Resize/Move” button, followed by the check-mark button at the top to apply the changes.

Resize your OS partitions with Gparted

Needing to resize a partition on your Linux hard drive that contains your current Linux operating system? If so, you must download the Gparted live disk, as it isn’t possible to resize partitions currently in use.

To get your hands on the Gparted live disk, open up a terminal window by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. Then, use the wget download tool to grab the latest live image of Gparted.

When the download for the Gparted live ISO file is complete, plug in a USB flash drive into the USB port and use the Etcher imaging tool to create a bootable live disk.

After making your Gparted bootable live disk, reboot the computer and load up the BIOS settings. Look through the BIOS settings and configure it to load from the Gparted live USB.

Once the Gparted live session is loaded up from your USB, let it load up. When it does, do the following operations outlined in the list below.

  • For “Configuring console-data” select don’t touch keymap.
  • For language, enter a number from the list above. Or, press Enter to go with the default that the OS detected.
  • For “Which mode do you prefer” type in “startx” and press the Enter key.

Soon after writing in “startx” in the shell on screen, a graphical environment will appear, along with the Gparted partitioning tool. Using the tool, click the drop-down menu at the top right, and select the drive you’d like to work with.

Once you’ve selected the hard drive you want to work with, locate the hard drive partition which you’d like to re-size, and right-click on it. Then, look through the right-click menu, find “Resize/Move” and click it to open up the partition “Resize/Move” menu.

Inside of the “Resize/Move” menu, use the graphical tool to drag your hard drive partition to make it smaller or larger. Alternatively, click on “New size (MiB)” and multiply the number 1024 by the number of GB to resize it to an exact size.

How to resize your ubuntu partitions

When you’re happy with the new size of the partition, click the checkmark button at the top of the app to apply the changes.

How to resize your ubuntu partitions

Reboot when done working with the Gparted live disk. Upon logging back into your OS, the partition should be resized to the size you specified!

  • Page History
  • Login to edit

If you wish to create a partition (in which to install Ubuntu Linux, for example) on a hard drive which already contains a Windows partition, or if you need to provide more space in an existing partition that is running out of space, you will need to perform one or more partition resizing operations. You can re-allocate hard drive space from one partition to another, or add previously UnallocatedSpace to a partition.

Resizing Windows Partitions requires special attention and is accomplished in a manner different from that used to resize other types of partitions.

” height=”16″ src=”/moin_static198/light/img/icon_cool.png” title=”Info ” width=”16″ /> When shrinking a partition containing data, attention must be given to the amount of free space left in the partition; especially a Windows partition, but true for any filesystem. The less room left in a partition, the more likelihood of fragmentation of files, and the harder it will be to defragment that partition.

Rule of Thumb: Leave at least 10% free space on any partition to reduce fragmentation and make defragmentation easier.

Note that, in order to expand a partition, you must have free space next to it in which to expand. This can be accomplished either by shrinking another partition next to it, or moving a (or some) partition(s) away from it. See the Moving A Partition page for details on moving a partition.

See notes in Additional Notes on Partitions on the Operating Systems And Primary/Extended Partitions page for additional restrictions on resizing operations.

To resize a partition, first make sure the partition is unmounted. If the partition is mounted, most of the options in the menu will be unavailable, except for one that says “Unmount,” which you should select to unmount the partition.

How to resize your ubuntu partitions

Notice in the image that the partition I am resizing is the Windows NTFS partition that covers the entire hard drive, which I created earlier. A new Windows computer’s hard drive will typically be formatted in this manner; one large partition covering the entire drive.

Once you are sure the partition is unmounted, right click on the partition you wish to resize and select “Resize/Move” from the menu as illustrated above. You will then be presented with the following:

How to resize your ubuntu partitions

Resizing a partition can be done one of two ways:

Dragging and sliding . Position the cursor over the arrow on either side of the graphical bar shown in the screenshot, left click and hold, then drag the arrow; away from the edge for shrinking or towards the edge (into the free space, if available) to expand it.

Changing the “New Size” or the “Free Space Preceding/Following” sizes. This can most easily be done by changing the size of the partition itself. This is done either by using the up/down arrows to the right of the “New Size” window, or by directly editing the size itself in that Window. Alternately, you can shrink the partition by increasing the non-zero side of the partition in either the “Free Space Preceding” or “Free Space Following” window.

If you attempt to expand the partition by decreasing the non-zero side of the partition (“Preceding” or “Following,” depending on where the free space is), it will move the partition instead of increasing it’s size. The same will apply if free space exists on both sides of the partition. See Moving A Partition for details.

After changing the size of the partition, just click the “Resize/Move” button, and the changes will be recorded and visible in a window at the bottom. When you are sure that you have resized it as you desire, you click the “Apply” button at the top and the partition will be resized. Your hard drive will then be as follows:

How to resize your ubuntu partitions

HowtoPartition/ResizingPartition (последним исправлял пользователь ben64 2018-01-15 10:38:20)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

By Irene | Follow | Last Updated November 25, 2020

  • Facebook
  • Twitter
  • Linkedin
  • Reddit

Summary :

How to resize your ubuntu partitions

Some users don’t know how to resize Ubuntu partition when they find the partition size is unreasonably. This article will show you how to resize Ubuntu partition under Windows.

Quick Navigation :

  • What Is Ubuntu
  • Ubuntu Resize Partition
  • Verdict
  • User Comments

What Is Ubuntu

Ubuntu is a kind of Linux operating system, and it is developed by Mark Shuttleworth on the basis of Debian. This operating system is developed to make it easy to use personal computer. At the same time, it also offers server edition for enterprise.

Users who have used Ubuntu know Ubuntu computer can be used once it opens instead of costing much time to install browser, media player, office suite, and other commonly used software, which promotes the ease of use of the system.

Besides, this operating system provides users with many drives of hardware device. Therefore, Ubuntu is preferred by many Linux fans and has become the best Linux operating system.

However, as time goes by, they may find the Ubuntu partition is unreasonable and want to resize the partition. Under this situation, many users don’t know how to resize partition Ubuntu as Ubuntu operating system is different form Windows and some Windows disk partition resizer cannot be used in Ubuntu.

Since Ubuntu and Windows are different operating system platforms, the simplest way to resize Ubuntu partition is that you can do the Ubuntu partition resizing under Windows if your computer is dual-boot.

It is recommended to use a reliable third-party software to resize Ubuntu partition as Windows built-in Disk Management is much limited when you use its Extend Volume or Shrink Volume to resize partition. See: Why Extend Volume Grayed out and How to Quickly Fix It

Ubuntu Resize Partition

Why Do You Choose MiniTool Partition Wizard Free Edtition

As is known to all, there are many excellent partition managers on the market to help Windows users to resize partition and manage disks and partitions. However, most of them do not support Ubuntu partition resizing.

Luckily, nowadays, dual booting Linux with Windows is always suggestible for the beginners. For this kind of users, they can resize Ubuntu partition under Windows operating system with a third-party partition manager.

You can choose MiniTool Partition Wizard Free Edition to resize Ubuntu partition or Windows partition as this partition manager won’t damage data on related partitions, and you can manage Windows partitions and Ubuntu partition at ease with just one partition manager.

How to Resize Ubuntu Partition with MiniTool Partition Wizard?

Step 1. Download MiniTool Partition Wizard Free Edition by clicking the following button. Install it on your Windows operating system and launch it to get the main interface.

Step 2. Select the Ubuntu partition that you want to change size, and click Move/Resize Partition option from left action panel.

How to resize your ubuntu partitions

Step 3. In the resizing interface, drag the partition handle rightwards or leftwards to extend or shrink partition. Then, click OK to go back to the main interface.

How to resize your ubuntu partitions

Step 3. Next, click Apply to perform the pending operation.

How to resize your ubuntu partitions

Verdict

You see, it is not impossible to resize partition in Ubuntu. If you are an Ubuntu and Windows dual-boot user, you can resize Ubuntu easily with MiniTool Partition Wizard under Windows.

If you have any question about Ubuntu resize partition with MiniTool Partition Wizard, you can leave a message on the following comment zone and we will reply as soon as possible. If you need any help when using MiniTool software, you can contact us via [email protected] .

Even though my SD card is 16GB, the image I flashed onto it was only 2GB and now I can only see 2GB of storage space on the disk.

How can I resize the image so that I have more space on my root partition?

5 Answers 5

Assuming you are using Debian.

The Short Version:

  1. Backup your system
  2. Remove the main and swap partitions (leaving the boot partition alone)
  3. Recreate the main partition to utilize the remaining disk space (excluding the boot partiton). Make sure to reuse the same start sector as the original root partition.
  4. reboot the system
  5. resize the new boot root partition to utilize the full partition size.

Step by Step Instructions

First make a backup of your SD Card using the instructions found here in case something goes wrong.

From the command line or a terminal window enter the following

then type p to list the partition table

you should see three partitions. if you look in the last column labeled System you should have

  1. W95 FAT32
  2. Linux
  3. Linux Swap

make a note of the start number for partiton 2, you will need this later. though it will likely still be on the screen (just in case).

next type d to delete a partition.

You will then be prompted for the number of the partition you want to delete. In the case above you want to delete both the Linux and Linux swap partitions.

So type 2

then type d again and then type 3 to delete the swap partition.

Now you can resize the main partition.

type n to create a new partition.

This new partition needs to be a primary partition so type p .

Next enter 2 when prompted for a partition number.

You will now be prompted for the first sector for the new partition. Enter the start number from the earlier step (the Linux partition)

Next you will be prompted for the last sector you can just hit enter to accept the default which will utilize the remaining disk space.

Type w to save the changes you have made.

Next reboot the system with the following command:

once the system has reboot and you are back at the commandline enter the following command:

Note: this can take a long time (depending on the card size and speed) be patient and let it finish so you do not mess up the file system and have to start from scratch.

Once it is done reboot the system with the following command:

You can now verify that the system is using the full capacity of the SD Card by entering the following command:

Why This Works:

The real magic here is that you delete the root and swap partitions, then recreate only the root partition (using the original start sector) before writing the data to the disk. As a result you don’t erase the existing data from the root partition.

By removing the swap partition you allow the root partition room to grow beyond its current size and fill the unused portion of the disk (because of the placement of the partitions -the root partition is sandwiched between the boot and swap partitions – it can’t simply be resized leaving the swap partition alone).

You then resize (which is safe to run on a mounted disk) the file system to use all the space in the new root partition.

Using the Debian-Wheezy Beta image, there is a configuration utility built in that makes this easy:

There is a utility called raspi-config . This runs on first boot if you’re connected directly to the RPi. If you’re over SSH you can run it manually using $ sudo raspi-config . (I think you can re-run the tool manually at any time).

The second option on the blue dialog that follows is titled expand_rootfs , with the description “Expand root partition to fill SD card”.

Selecting this will cause your root partition to be resized to fill the card the next time you boot your RPi.

Update for 2015!

I’m coming back to this answer with a note of caution: I have been using a bunch of 16GB SD cards, and I got caught out by maxxing my partition to fill the card I was using. Doing so caused a bunch of problems when switching to a new card which (even though it was stated as 16GB) was about 200MB smaller than the older card.

This came to a head when I switched a couple of RPis from v1 to the new v2 model, which uses Micro SD cards.

I now leave about 1GB free to make absolutely sure that my images can be switched between SD cards without issue.

If you are not very comfortable working on the command line, like in Steve Robillards excellent answer, there are some GUI applications available. In particular gparted works very well.

I think it’s installed by default on a Ubuntu LiveCD but not on an installed system. There is of course an easy fix for this: apt-get install gparted . You can’t do this on the actual Pi, because to resize partitions they need to be unmounted.

The picture below is in Dutch, but don’t let that spoil the fun. It’s very easy to use. This is the layout of the default debian image on a 8gb sdcard.

How to resize your ubuntu partitions

Right-click the partions to unmount them and then right-click to resize or move the partition. You can also create new partitions and format existing ones. In the picture below I’ve removed the swap partition and now I’m able to resize the root partition to the entire space on the right of it. Don’t fill it entirely, because you still have to add a swap partition.

How to resize your ubuntu partitions

You can play with the partition layout, changes are only written if you apply the changes (the grayed out ‘return’ key in the first picture).

It’s very easy to move partitions but like in Steve’s answer I’d recommend you remove the swap partition entirely, then resize the root and then recreate a swap. Moving a partition can take a very long time and the swap does not contain data you need to keep.