[sf-lug] problem using gnu parted

Michael Paoli Michael.Paoli at cal.berkeley.edu
Tue Jan 30 17:13:42 PST 2018


Maybe this will give you some ideas/hints:

$ man parted | col -b | expand | fgrep -i default
                      default  in megabytes).  part-type should be one of "pri-
$ man parted | col -b | expand | sed -ne '/unit/,/^$/{/^$/q;p;}'
               unit unit
                      Set unit as the unit to use when displaying locations and
                      sizes,  and for interpreting those given by the user when
                      not suffixed with an explicit unit.  unit can be  one  of
                      "s"  (sectors),  "B"  (bytes),  "kB",  "MB", "MiB", "GB",
                      "GiB", "TB", "TiB",  "%"  (percentage  of  device  size),
                      "cyl"  (cylinders), "chs" (cylinders, heads, sectors), or
                      "compact" (megabytes for input, and a human-friendly form
                      for output).
$ expr 5574007 \* 1000000
5574007000000
$ expr 5574007 \* 1024 \* 1024
5844769964032
$ expr 7744511 \* 512
3965189632
$

> From: "Alex Kleider" <akleider at sonic.net>
> Subject: [sf-lug] problem using gnu parted
> Date: Tue, 30 Jan 2018 10:08:50 -0800

> I'm working on a script that can shrink an .img file created by  
> 'dd'ing an sd card to the .img file.
> 'parted' is telling me something that seems inconsistent with the  
> facts- here's some output to illustrate:
>
> """
> Partition 2 file system size is now (684975 * 4096) 2805657600 bytes.
> Use GNU parted to list partitions...
>   $ parted /dev/loop0  unit 's' print
> ...and pipe it into ./get_parted_info.py  (a script to extract the  
> sector boundaries)
> For each partition:
>   #  Begin    End
>   1  8192     93236
>   2  94208     7744511
> About to run following command:
>   $ parted -s /dev/loop0 resizepart 2 5574007
> ...to resize the second partition.
> Error: The location 5574007 is outside of the device /dev/loop0.
> Error setting last sector of 2nd partition!
> """
> ... but 5574007 is considerably less than 7744511!!
>
> I switched from fdisk to parted so that I could automate the  
> procedure (with in a script.) When doing it manually using fdisk, it  
> went fine. Using parted manually resulted in the same error.
>
> Any ideas welcome!




More information about the sf-lug mailing list