6

Unfortunately all the answers I found involve GParted. I thought I could be using parted, but apparently the "parted resize" command has some limitations with respect to GParted when working on a partition which has already a filesystem in it ( gives a warning and also can't work on filesystem with some special features like journal, etc... )

I was being able to shrink the filesystem ( ext4 ) by using resize2fs command, but now I don't know how to shrink the partition in order to create a new one.

I also compiled parted 3.0, but in this new version the resize command has been removed altogether...

Should I just use fdisk ? In the man I don't see a resize command there, they say to use parted...

Thanks

6
  • Question: why don't you want to use gparted? It is far safer than other tools (though there is always an element of risk, so be prepared for data loss).
    – barrydrake
    May 4, 2012 at 16:36
  • 1
    His server tag seems to indicate he's working with Ubuntu Server, which is command-line only..
    – SirCharlo
    May 4, 2012 at 16:42
  • @SirCharlo: gpartedis just a front-end to the command-line parted tool, which the OP already said it didn't work...
    – MestreLion
    May 4, 2012 at 16:58
  • That's just it; he used the command-line program, which is hard to use and unintuitive to one accustomed to using GUIs.
    – SirCharlo
    May 4, 2012 at 17:02
  • I have nothing aginst GParted :), I have used it on the desktop, but my server is a cheap VPS and as far as I know I cannot boot from a live CD. I can boot from a "rescue system" but also there I have no GUI program, only parted v.2.2 and other utils...
    – castigli
    May 4, 2012 at 18:01

5 Answers 5

2

...answering as best as possibile to my own question:

If for any reason you cannot use GParted, you will have to do it manually using some of these command line tools:

  • parted
  • resize2fs
  • (c)fdisk

The steps can be different according to the filesystem contained in the partition. For example I found that parted cannot resize partitions which contains filesystem like ext4, so I had to destroy and recreate the partition with fdisk, making some calculations about the correct size. Also most of the commands can only used when the partition is not mounted.

Before using fdisk you may want to backup the partition table, i used dd for that task.

Also if you drive is setup with LVM you may use the tools provided.

Some useful links I found:

I will try to improve my answer as I gain more experience.

2

If you really want to use the gui, and you have extra space (or perhaps can provision it on demand, or even temporarily purchase a new VPS briefly), then you could:

  1. Boot in rescue mode
  2. unmount /home, and dd (copy) the raw partition to a new partition (another device for convenience); we will refer to it as 'home2'.
  3. You could now boot into 'full' system with gui if you prefer.
  4. Verify your copy: fsck, mount, check that home2 is okay, then umount home2.
  5. You can now run gparted on home2, verify that it is okay, figure out the exact partition size / blocks required
  6. Boot in rescue mode again
  7. Do the resize with confidence, or just delete that partition and create it again with required size (back up the partition table first though).
  8. Use dd to copy the filesystem image back from home2 to the resized home partition.
  9. Reboot!

Realize that any filesystem changes to /home between steps 2 and 6 will be lost.

Disadvantage: that's an extra step or two, and requires extra disk space.

Advantage: you do have a backup copy of your partition.

For anyone not fluent with dd, fsck, fdisk, parted, mount, and partition tables, experiment with a virtual server and a virtual disk; it's free. Also, try experimenting with LVM, as it allows you to resize dynamically (no reboot or downtime required).

1

Gparted works fine, but, as with any partition manager, you can not resize mounted partitions. And you can not un-mount your root partition while running your OS.

So the trick is: Use a Live CD / USB boot!

Then you can resize any hdd partition, since none will be mounted.

Just be aware that the system must have been properly shut down, as hibernated partitions should not be resized.

Also use fsck prior to resize, just to make sure there are not corrupted structures.

2
  • Thanks, but I can have the partition unomunted, since I can boot from the "rescue system". The problem is that I cannot use GParted, and parted seems not only less user friendly, but more limited in features. Now I am missing only the last step, to resize the partition. I fear I could destroy my data using fdisk...
    – castigli
    May 4, 2012 at 18:10
  • I said fsck, not fdisk. And yes, you should have a backup prior to any partition resize. If you can't afford to lose your data if things go wrong, don't resize.
    – MestreLion
    May 4, 2012 at 18:19
1

I used fdisk to create a small partition before the boot partition then created a new boot partition and deleted small partition, rebooted, then ghosted back the c: drive.

Using the desktop version of gparted I was able to see I was close to the recommended 1024 alignment (1025) which gave me a five fold increase in 4kb read speed on crystal bench mark.

When I was able to get the cd boot version of gparted and do a proper alignment by making a 2 mb space before then creating a 1 mb space, as recommended as the way to get the optimum 1024 figure in gparted, I didn't see any improvement in the crystal bench mark scores. So just going the fdisk way, and using crystal bench sees to me to give just as good results.

0

Download Parted Magic's Live CD and boot using that. You'll then be able to resize your partitions through Gparted's GUI.

1
  • 1
    Thanks, but AFAIK I am unable to boot from a LiveCD, my server is a cheap VPS, and I can boot only from a rescue system which has only CLI.
    – castigli
    May 4, 2012 at 18:03

You must log in to answer this question.

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