GNU bug report logs - #24167
Way to tell parted to resize partition to max size?

Previous Next

Package: parted;

Reported by: Petter Reinholdtsen <pere <at> hungry.com>

Date: Sat, 6 Aug 2016 07:00:02 UTC

Severity: normal

To reply to this bug, email your comments to 24167 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-parted <at> gnu.org:
bug#24167; Package parted. (Sat, 06 Aug 2016 07:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Petter Reinholdtsen <pere <at> hungry.com>:
New bug report received and forwarded. Copy sent to bug-parted <at> gnu.org. (Sat, 06 Aug 2016 07:00:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Petter Reinholdtsen <pere <at> hungry.com>
To: bug-parted <at> gnu.org
Subject: Way to tell parted to resize partition to max size?
Date: Sat, 06 Aug 2016 08:58:07 +0200
Hi.

I checked the manual page, texinfo documentation and the source, but
were unable to find a way to do this.

Is there a way to tell parted to resize a partition to the maximum
possible.  In other words, to the end of the disk or until it meet a new
partition on the disk geometry?

With btrfs I can do like this to extend to the end of the partition:

  btrfs filesystem resize max /

Could parted be changed to allow something similar?  Perhaps

  resizepart 1 max

I had a look at the code, and suspect something like this might work,
but I do not know the parted inner workings enough to figure out where
to get the max_end value.


--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -1522,6 +1522,7 @@ do_resizepart (PedDevice** dev, PedDisk*
         PedSector               start, end, oldend;
         PedGeometry             *range_end = NULL;
         PedConstraint*          constraint;
+        char                    *end_raw;
         int rc = 0;
 
         if (!disk) {
@@ -1543,8 +1544,12 @@ do_resizepart (PedDevice** dev, PedDisk*
 
         start = part->geom.start;
         end = oldend = part->geom.end;
-        if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, NULL))
-                goto error;
+        if (!command_line_get_sector (_("End?"), *dev, &end, &range_end, &end_raw))
+                if (0 == strcmp('max', end_raw) {
+                        end = max_end;
+                } else {
+                        goto error;
+                }
         /* Do not move start of the partition */
         constraint = constraint_from_start_end_fixed_start (*dev, start, range_end);
         if (!ped_disk_set_partition_geom (disk, part, constraint,



-- 
Happy hacking
Petter Reinholdtsen




Information forwarded to bug-parted <at> gnu.org:
bug#24167; Package parted. (Fri, 12 Aug 2016 23:37:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tom Roche <Tom_Roche <at> pobox.com>
To: bug-parted <at> gnu.org, 
Subject: Re: bug#24167: Way to tell parted to resize partition to max size?
Date: Fri, 12 Aug 2016 16:36:21 -0700
[footnotes after .sig]

Petter Reinholdtsen[1]
> With btrfs I can do like this to extend to the end of the partition:

>   btrfs filesystem resize max /

> Could parted be changed to allow something similar?  Perhaps

>   resizepart 1 max

WARNING: I have not tried this! but I believe you want `-1`, e.g.

    resizepart 1 -1

I am basing this on the knowledge that

    sudo parted ${DRIVE_DEV} --script -- mkpart primary 0 -1

I concur (presuming it works :-) that note of the semantics of `-1` should be added to the manual, e.g. here[2] and here[3]. Note the manual[2] does state clearly

>> When growing a partition you will want to grow the filesystem afterwards, but
>> when shrinking, you need to shrink the filesystem before the partition. 

HTH, Tom Roche <Tom_Roche <at> pobox.com>

[1]: http://lists.gnu.org/archive/html/bug-parted/2016-08/msg00001.html
[2]: https://www.gnu.org/software/parted/manual/parted.html#resizepart
[3]: https://www.gnu.org/software/parted/manual/parted.html#mkpart




This bug report was last modified 8 years and 312 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.