[CentOS] Command line partition manipulation
William L. Maltby
CentOS4Bill at triad.rr.com
Fri Aug 8 15:01:45 UTC 2008
On Fri, 2008-08-08 at 15:10 +0100, Plant, Dean wrote:
> Karanbir Singh wrote:
> > Plant, Dean wrote:
> >> Is there a way to use a non-interactive command to create the new 2nd
> >> partition in the free space?
> > parted works well for such situations, and if python is your thing,
> > pyparted is already included in the distro.
> Sorry, I should have worded my first email better.
> I know there are command line tools like fdisk, sfdisk and parted.
Sfdisk is your friend.
> start or end point but im not interested in that, I just want to use the
> free space.
> Hope this is clearer.
Having made my living for some months doing this, I offer the general
1. Study sfdisk man page closely.
2. Look especially for the parts where it can output disk and partition
information in the form that can be re-read by sfdisk.
3. Use that information in a script (with your preferred combo of bash,
perl, (g)awk, bc, dc, ...) to locate total size, amount used, start/end
4. Calculate desired changes.
5. Apply to the saved information.
6. Run sfdisk reading the modified output from sfdisk.
7. sfdisk -R (IIRC) to re-read the partition information.
Alternately, steps 6/7 could be replaced with gparted if you structure
the results properly.
> <snip sig stuff>
More information about the CentOS