4

I've recently run into an issue where I need to resize a partition on a server, but the issue is, it has no GUI so I cannot use gparted. What should I do in this case?

So I get it that you should use parted. However, how exactly do you use the parted command? What does it mean by start and end?

Braiam
  • 67,791
  • 32
  • 179
  • 269
  • Use parted (gparted is a graphical front end). See http://askubuntu.com/questions/390769/resize-my-root-partion-in-ubuntu-server – Panther Jul 25 '14 at 20:14
  • That doesn't help much.. I get that parted is the answer, but what does it mean by start and end..? – VoidWhisperer Jul 25 '14 at 20:20
  • You should update your question then , ask for clarification – Panther Jul 25 '14 at 20:42
  • Done, it should be more clear now. – VoidWhisperer Jul 25 '14 at 20:57
  • @VoidWhisperer I've added a bounty to the other question, so someone will improve its answer. In the meantime I will reopen this. It'll probably be closed again as soon as a) you get an answer (then I'll merge the two) or b) the other question gets a in depth answer. Just a heads up :) – Seth Jul 26 '14 at 00:57
  • @Seth are you still going to merge them? What's the status on that? The answers on the other question are for 1)resizing the root partition, or 2)creating a swap space without partitioning. If VoidWhisperer wants to resize a non-root partition, those answers won't do him any good. I can post a step-by-step answer here on how to resize a non-root partition through the command line. My answer won't apply to the other question because that question is for resizing the root partition. – Alaa Ali Aug 08 '14 at 17:57
  • @VoidWhisperer are you looking to resize the root partition? Or another partition on the disk? Resize root partition = you have to use liveCD (mentioned in the answers on the other question). Resize another partition = I'll post a detailed answer. – Alaa Ali Aug 08 '14 at 17:58
  • @AlaaAli (Sorry for the late reply). Hm, you're right. That is something I hadn't taken into account. I guess I will just leave them now. – Seth Aug 30 '14 at 15:36

1 Answers1

2

Use parted:

parted device resize minor start end

Resizes the partition with number minor from device device. The partition will start start from the beginning of the disk, and end end from the beginning of the disk. resize never changes the minor number. Extended partitions can be resized, so long as the new extended partition completely contains all logical partitions.

Note that parted does not require a file system to be "defragged" (parted can safely move data around if necessary).

Supported file systems:

  • ext2, ext3 - restriction: the new start must be the same as the old start.
  • fat16, fat32
  • linux-swap
  • reiserfs (if libreiserfs is installed)

Example:

sudo parted -i /dev/sda resize 3 200 850

Resize partition 3 from /dev/sda, so that it begins 200 megabytes and ends 850 megabytes from the beginning of the disk. -i (--interactive) prompt for your intervention, where necessary.

Source: Parted User's Manual.

See also man parted for more info.

Radu Rădeanu
  • 169,590
  • I'm kind of confused on how I would change the partition size with this.. Why isn't it just simple like giving it a new size to change it to? – VoidWhisperer Jul 26 '14 at 16:57
  • @VoidWhisperer In the given example 850-200=650 is the new size :). Use sudo parted /dev/sda print command to find out the current start and the current end. – Radu Rădeanu Jul 26 '14 at 17:13