parted:   Interface to GNU Parted Disk Partion Utility
1 Introduction
2 Interface
parted-unit?
parted-disk
parted-partition
get-parted-disk
parted-mklabel
parted-mkpart
parted-partition/  unit-byte?
parted-mkpart/  partition
parted-mkpartfs
3 Known Issues
4 History
5 Legal
2:1

parted: Interface to GNU Parted Disk Partion Utility

Neil Van Dyke

 (require parted) package: parted

1 Introduction

Warning: This is alpha-testing software. Use with caution. It is easy to lose all the data on a hard disk drive accidentally. This package uses GNU Parted with the Racket sudo package, so literally one line of code can obliterate either your doctoral dissertation, or received love-letters (nobody has both). Don’t even think of suing the author.
This package provides a Racket interface to the GNU Parted disk-partitioning utilities. You must have GNU Parted installed, for this package to function.
This package calls the command-line parted program, sometimes using the poorly-documented machine-parseable output interface. It does not use the FFI, nor otherwise add native code to the Racket host process. It is developed with GNU Parted 2.3.
This package was originally written for the RackOut firmware updater.

2 Interface

procedure

(parted-unit? x)  boolean?

  x : any/c
Predicate for whether x is a valid “unit” argument for certain procedures, and for representing the units in structs. Currently this must be a symbol: 'byte or 'cylinder. CHS is not currently supported.

struct

(struct parted-disk (unit
    path
    end
    transport
    sector-size
    physical-sector-size
    type-name
    model
    cylinders
    heads
    sectors
    cylinder-size
    partitions)
    #:extra-constructor-name make-parted-disk)
  unit : parted-unit?
  path : path?
  end : nonnegative-real?
  transport : string?
  sector-size : nonnegative-real?
  physical-sector-size : nonnegative-real?
  type-name : string?
  model : string?
  cylinders : (or/c #f nonnegative-integer?)
  heads : (or/c #f nonnegative-integer?)
  sectors : (or/c #f nonnegative-integer?)
  cylinder-size : (or/c #f nonnegative-integer?)
  partitions : (list-of parted-partition?)
Struct representing a disk drive.

struct

(struct parted-partition (unit
    number
    start
    end
    size
    filesystem
    name
    flags
    type)
    #:extra-constructor-name make-parted-partition)
  unit : parted-unit?
  number : nonnegative-integer?
  start : nonnegative-real?
  end : nonnegative-real?
  size : (or/c #f nonnegative-real?)
  filesystem : string?
  name : string?
  flags : string?
  type : string?
Struct representing a partition of a disk drive.

procedure

(get-parted-disk #:disk disk-or-path    
  [#:unit unit])  parted-disk?
  disk-or-path : parted-disk-or-path?
  unit : parted-unit? = 'byte
Yields a parted-disk struct for the disk given by disk-or-path. (A parted-disk struct may be given for disk-or-path to get updated information for the same disk.)

procedure

(parted-mklabel #:disk disk-or-path    
  [#:label-type label-type])  void?
  disk-or-path : parted-disk-or-path?
  label-type : string? = "msdos"
Perform the GNU Parted mklabel operation.

procedure

(parted-mkpart #:disk disk-or-path    
  [#:partition-type partition-type    
  #:filesystem-type filesystem-type    
  #:unit unit]    
  #:start start    
  #:end end)  void?
  disk-or-path : disk-or-path?
  partition-type : string? = #f
  filesystem-type : string? = #f
  unit : parted-unit? = 'byte
  start : nonnegative-integer?
  end : nonnegative-integer?
Perform the GNU Parted mkpart operation.

procedure

(parted-partition/unit-byte? x)  boolean?

  x : any/c
Predicate for whether x is a parted-partition and uses “byte” units (as opposed to “cylinder”). It is equivalent to:
(and (parted-partition? X)
     (eq? 'byte (parted-partition-unit X)))

procedure

(parted-mkpart/partition #:disk disk-or-path    
  #:partition partition)  void?
  disk-or-path : disk-or-path?
  partition : nonnegative-integer?
Perform the GNU Parted mkpart operation, but using a parted-partition struct to specify the properties of the partition.
This is useful as part of a pattern of using get-parted-disk to save the current partition information for a disk, performing some operation that results in the partition table being corrupted or lost, and then restoring the partitions (restoring either all, or selectively).

procedure

(parted-mkpartfs #:disk disk-or-path    
  #:partition-type partition-type    
  #:filesystem-type filesystem-type    
  [#:unit unit]    
  #:start start    
  #:end end)  void?
  disk-or-path : disk-or-path?
  partition-type : string?
  filesystem-type : string?
  unit : parted-unit? = 'byte
  start : nonnegative-integer?
  end : nonnegative-integer?
Perform the GNU Parted mklabel operation.
Note that the GNU Parted 2.3 documentation discourages use of this operation; separate filesystem-specific tools are usually better suited to filesystem creation.

3 Known Issues

4 History

5 Legal

Copyright 2012, 2016 Neil Van Dyke. This program is Free Software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See http://www.gnu.org/licenses/ for details. For other licenses and consulting, please contact the author.