16

I've got a Linux-based OS installed on a partition I want to shrink. Want to avoid reinstallation or losing/corrupting data, if possible.

Oxwivi
  • 17,849

2 Answers2

21

As always:

D O   A   BACKUP. At least of the sensitive data on the partition, you want to shrink. Neither I, nor geparted can be held responsible if you screw up.

Now to the procedure using gparted:

gparted screenshot with steps to do

The picture is a little messy but don't get scared (you'll be moving with your partition to your auntie and uncle in Bel Air. Wait wat? XD). Just stick with this for a moment and follow the instructions below. Start looking at the image in the top right corner. Then follow the numbers in ascending order.

Here is a text version of the steps numbered as in the picture:

  • Install gparted / sudo apt-get install gparted
  • Start gparted
    1. Select the disk in the upper right dropbox
    2. Select the partition in the main list in the middle
      • If mounted: Unmount that partition using the contex menu (right click)
    3. Click the resize button
    4. A dialog will pop up
    5. Resize
    6. Click "Apply" after double checking your changes. That's it.

This will not work with all partitions. It can be more complicated for Mac partitions or logical volumes.

con-f-use
  • 18,813
  • 3
    +1 for the mounted part. If you're trying to shrink the / partition (or something that is essential to be mounted), just boot from a liveCD and then run gparted. – Nemo Jun 07 '11 at 08:25
  • 2
    Er, do you mind dividing the steps into different screenshots? The image is as confusing as your name is. – Oxwivi Jun 07 '11 at 08:51
  • Wait, now that I read the whole thing, just doing the usual shrinking will be fine? It will move the data by itself? – Oxwivi Jun 07 '11 at 08:54
  • It gave me a warning that it could rendered unbootable... – Oxwivi Jun 07 '11 at 09:02
  • 2
    Yes, gparted will move the data by itself as long as you don't shrink the partition to a size that's too small for it. Concerning the 'confusing' bit: The numbers in the pictures correspond to those in the text. As for the unbootable bit: What partition do you resize? – con-f-use Jun 07 '11 at 09:03
  • @Oxwivi Still having problems? If you enter the general chat someone might help you. – con-f-use Jun 07 '11 at 09:05
  • The overlapping lines is the what would confuse anyone. Anyway, I'll report back if I can't actually boot from it. – Oxwivi Jun 07 '11 at 09:07
  • Since you didn't report back, I assume everything went well. Care to accept my answer then? – con-f-use Jun 08 '11 at 11:29
  • @conf-use your picture makes me to confuse. – Avinash Raj Feb 09 '14 at 16:11
  • +1 for Fresh Prince of Bel-Air too, that was amazing. – jvperrin Mar 08 '17 at 21:02
2

I was not able to shrink my partition only by using gparted. Instead, I had to first resize the filesystem with resize2fs:

resize2fs /dev/sdx# 50G

After that, I could shrink the partition with gparted without any problems or loss of data. Note: resize a partition only, not your whole disk. So for example, instead of choosing sda, choose sda1.

Note: you might have to run e2fsck -f /dev/sdx# first.

GChuf
  • 495
  • Apparently parted lost the ability to do FS resizes in 3.0, partially regained it in 3.1 and then lost it for real in 3.2: https://unix.stackexchange.com/questions/169395/how-do-i-resize-partitions-and-filesystems-on-them – Joachim Sauer Sep 07 '23 at 18:57