bug#24167: Way to tell parted to resize partition to max size?

Petter Reinholdtsen <[email protected]>
Newsgroups gmane.comp.gnu.parted.bugs
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.