Chapter 5. The commands of parted_server

Table of Contents

5.1. Open a new device
5.2. Close a device
5.3. Does the partition exist on the disk?
5.4. Remember the partition table as unchanged
5.5. Report whether the partition table is changed
5.6. Dump the partitions
5.7. Write partitioning to the disk
5.8. Undo the changes
5.9. Get the partitions
5.10. Getting info about a partition
5.11. Getting cylinder/head/sector geometry of a partition/free space
5.12. Getting the supported partition table types
5.13. Get the type of the disk label
5.14. Create a new empty partition table
5.15. Getting the meaningful flags for a partition
5.16. Getting the active flags of a partition
5.17. Set the flags of a partition
5.18. Check if partition names are supported
5.19. Set the name of a partition
5.20. Get the maximum number of primary partitions
5.21. Check if extended and logical partitions are supported
5.22. Get the known to parted_server file systems
5.23. Try to detect the file system in a partition
5.24. Change the filesystem of a partition
5.25. Create a new partition
5.26. Delete a partition
5.27. Resize a partition
5.28. Get resize range

You should be very careful when you communicate with the parted_server. If parted_server detects any error it will exit immediately. This is safer approach then to try to resolve somehow the error. However this also means that the user will not be shown any information about what happened and why the installer freezed. The log-file /var/log/partman can be used to see the reasons why parted_server exited.

5.1. Open a new device

Synopsis:

cd device_directory
open_dialog OPEN device_name
read_line status
close_dialog
case $status in
    OK)
        # The device has been opened successfully
        ;;
    failed)
        # We wasn't able to open the device
        ;;
esac

Here device_name can be for example /dev/ide/host0/bus0/target0/lun0/disc.

5.2. Close a device

Synopsis:

cd device_directory
open_dialog CLOSE
close_dialog

After this command you may not issue commands regarding the device of device_directory. This command does not invoke the command COMMIT.

5.3. Does the partition exist on the disk?

Synopsis:

cd device_directory
open_dialog VIRTUAL partition_id
read_line virtuality
close_dialog
case $virtuality in
    yes)
        # the partition does not exist on the disk
        # probably because it is newly created
        ;;
    no)
        # the partition exists on the disk
        ;;
esac

5.4. Remember the partition table as unchanged

Synopsis:

cd device_directory
open_dialog DISK_UNCHANGED
close_dialog

After this command parted_server will know that the partition table in its onw internal data structures is the same as the partition table actualy existing on the device. The main purpose of this command is to be used for partition tables with type loop.

5.5. Report whether the partition table is changed

Synopsis:

cd device_directory
open_dialog IS_CHANGED
read_line changed
close_dialog
case $changed in
    yes)
        # the partition table is changed
        ;;
    no)
        # the partition table is not changed
        ;;
esac

5.6. Dump the partitions

Synopsis:

cd device_directory
open_dialog DUMP
close_dialog

This command prints in /var/log/partition_dump all the data regarding the device. It is used for debugging.

5.7. Write partitioning to the disk

Synopsis:

cd device_directory
open_dialog COMMIT
close_dialog

This command transfers the partitions in the device of device_directory from the internal structures of parted_server to the disk.

5.8. Undo the changes

Synopsis:

cd device_directory
open_dialog UNDO
close_dialog

This command destroys the internal data structures in parted_server for a device and then rereads them from the device.

5.9. Get the partitions

Synopsis:

cd device_directory
open_dialog PARTITIONS
while { read_line num id size type fs path name; [ "$id" ]; }; do
    # do something for this partition
done
close_dialog

The body of the loop is executed for every partition and free space. $num is the number of the partition (for example /dev/hda6 has number 6). $id is the id of the partition. $size is the size of the partition (in bytes). If this is an active partition then $type is either `primary' or `logical'. If this is a free space then $type shows what partition can be created in it. In this case $type can be `primary', `logical', `pri/log' or `unusable'. $fs is `free' if this is a free space. Otherwise $fs is the type of the file system of this partition as known to parted_server. $path is a device name for the partition, for example /dev/ide/host0/bus0/target0/lun0/part6. $name is the name of the partition or the empty string if the partition table doesn't support partition names.

Notice that in the loop-body you may not initiate another dialog with parted_server. If you need this you can use the following construction instead:

cd device_directory
open_dialog PARTITIONS
partitions=$(read_paragraph)
close_dialog

echo "$partitions" |
while { read num id size type fs path name; [ "$id" ]; }; do
    # do something for this partition
done

5.10. Getting info about a partition

Synopsis:

cd device_directory
open_dialog PARTITION_INFO partition_id
read_line num id size type fs path name
close_dialog

Here partition_id is the id of the partition to get info. The meaning of the variables are the same as in the command PARTITIONS.

5.11. Getting cylinder/head/sector geometry of a partition/free space

Synopsis:

cd device_directory
open_dialog GET_CHS partition_id
read_line start_cyl start_head start_sector end_cyl end_head end_sector
close_dialog

5.12. Getting the supported partition table types

Synopsis:

cd device_directory
open_dialog LABEL_TYPES
supported=$(read_list)
close_dialog

For the result of this command device_directory is irrelevant. Despite this device_directory must be a valid device directory.

This command is used to read which types partition tables are supported by parted_server (i.e. by libparted). $supported is a comma-separated list of the supported types. At the time of writting the following types are supported: bsd, gpt, mac, dvh, msdos, pc98, sun and loop.

5.13. Get the type of the disk label

Synopsis:

cd device_directory