[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ next ]
parted_server
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.
Synopsis:
cd device_directory open_dialog OPEN device_name read_line status close_dialog case $status in OK) # The device has been opened successfuly ;; failed) # We wasn't able to open the device ;; esac
Here device_name can be for example
/dev/ide/host0/bus0/target0/lun0/disc
.
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.
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
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.
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
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.
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.
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.
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
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.
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
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.
Synopsis:
cd device_directory open_dialog GET_LABEL_TYPE read_line label_type close_dialog if [ "$label_type" = unknown ]; then echo "The disk is unknown or it has no disk label or the disk label is unknown" else echo "The type of the disk label is:" "$label_type" fi
This command returns the type of the disk label (i.e. the partition table) of a disk. It can be used to check if there is a partition table (if not, then it is safe to create a new partition table or to use the entire disk for RAID, LVM, encrypted unit, etc).
Synopsis:
cd device_directory open_dialog NEW_LABEL partition_table_type close_dialog
This command creates in the device a new empty partition table with type partition_table_type. (Of course it won't be written to the disk if you don't use the command COMMIT.)
Synopsis:
cd device_directory open_dialog VALID_FLAGS partition_id meaningful_flags=$(read_list) close_dialog
$meaningful_flags is a comma-separated list of the flags that are meaningful for the partition with id partition_id.
In order to check wether some particular flag xyz is meaningful you can use this code:
cd device_directory xyz_is_meaningful=no open_dialog VALID_FLAGS partition_id while { read_line flag; [ "$flag" ]; }; do if [ "$flag" = xyz ]; then xyz_is_meaningful=yes # you may not use break here fi done close_dialog
Synopsis:
cd device_directory open_dialog GET_FLAGS partition_id active_flags=$(read_list) close_dialog
$active_flags is a comma-separated list of the flags of the partition with id partition_id that are in state 1. This is a sublist of the list returned by the command VALID_FLAGS.
In order to check if some partition is denoted as bootable you can use this code:
cd device_directory is_bootable=no open_dialog GET_FLAGS partition_id while { read_line flag; [ "$flag" ]; }; do if [ "$flag" = boot ]; then is_bootable=yes # you may not use break here fi done close_dialog
Synopsis:
cd device_directory open_dialog SET_FLAGS partition_id for flag in $all_flags_that_should_be_active; do write_line $flag done write_line NO_MORE close_dialog
If you want to denote some partition as non-bootable you can use the following code:
cd device_directory open_dialog GET_FLAGS partition_id new_flags=$( while { read_line flag; [ "$flag" ]; }; do if [ "$flag" != boot ]; then echo $flag fi done ) close_dialog open_dialog SET_FLAGS $id write_line "$new_flags" write_line NO_MORE close_dialog
Synopsis:
cd device_directory open_dialog USES_NAMES read_line supported close_dialog case $supported in yes) # the partition table supports partition names ;; no) # the partition table doesn't support partition names ;; esac
Synopsis:
cd device_directory open_dialog SET_NAME partition_id new_name close_dialog
After this command the name of partition_id will be new_name. It is an error to use this command with a partition table that doesn't support partition names.
Synopsis:
cd device_directory open_dialog GET_MAX_PRIMARY read_line primaries close_dialog logger "This disk may contain up to $primaries primary partitions"
Synopsis:
cd device_directory open_dialog USES_EXTENDED read_line supported close_dialog case $supported in yes) # the partition table supports extended and logical partitions ;; no) # the partition table doesn't support extended and logical partitions ;; esac
parted_server
file systemsSynopsis:
cd device_directory open_dialog FILE_SYSTEM_TYPES known_filesystems=$(read_list) close_dialog
$known_filesystems is a comma-separated list of the file systems that are known
to parted_server
. You probably won't need to use this command.
Synopsis:
cd device_directory open_dialog GET_FILE_SYSTEM partition_id read_line filesystem close_dialog if [ "$filesystem" = none ]; then # no known file system is detected else # a file system of type $filesystem is detected fi
Synopsis:
cd device_directory open_dialog CHANGE_FILE_SYSTEM partition_id new_filesystem close_dialog
libparted assigns every partition some file system. This command can be used to change this file system. The file system assigned to the partition is not necessarily the same as the actual file system. Libparted uses it to determine automatically the type of the partition in some partition tables. For example with msdos partition tables the partitions with file system `ext2' receive type 83. The partitions that are swap spaces receive type 82.
Synopsis:
cd device_directory name_progress_bar some/debconf/template open_dialog CHECK_FILE_SYSTEM partition_id read_line result close_dialog case $result in good) # The file system is in good state ;; bad) # The file system has uncorrected errors ;; n/c) # No file system is detected ;; esac
The command name_progress_bar
may be omitted. The debconf
template must have type text. It will be used to give the user information of
what is being done.
Synopsis:
cd device_directory name_progress_bar some/debconf/template open_dialog CREATE_FILE_SYSTEM partition_id new_filesystem read_line result close_dialog case $result in OK) # the file system is successfuly created ;; failed) # wasn't able to create a file system ;; esac
The command name_progress_bar
may be omitted. The debconf
template must have type text. It is used to give the user some information of
what is being done.
Synopsis:
cd device_directory open_dialog NEW_PARTITION $type $fs $freespace $position $length read_line num id size type fs path name close_dialog if [ "$id" ]; then # the partition is successfuly created else # wasn't able to create the partition fi
$type is either primary or logical. $fs is the type of the file system to be assigned to the partition. $freespace is the id of some free space. $position is either `full', `beginning' or `end' and determines where in $freespace to create the new partition. If $position is not `full' then $length is the length that the new partition should have (in bytes).
If the new file system is succesfully created $num is tne number of the created
partition (for example /dev/hda6
has number 6). $id is the id of
the new partition. $size is the size of the new partition. $size is
approximately $length but not necessarily the same. $type and $fs don't change
their values. $path is a device name, for example
/dev/ide/host0/bus0/target0/lun0/part6
. $name is the name of the
new partition or an empty string if the partition table doesn't support
partition names.
Synopsis:
cd device_directory open_dialog DELETE_PARTITION partition_id close_dialog
Synopsis:
cd device_directory name_progress_bar some/debconf/template open_dialog RESIZE_PARTITION partition_id new_size read_line new_id close_dialog
This command resizes a partition. As usualy new_size is measured in bytes. $new_id is the new id that the partition receives. The resizing is not supported always. If it fails $new_id will be the same as partition_id.
If the partition exists on the storage device and contains some file system, then the data in the partition will be preserved and the new partition table will be written on the storage device. When it is impossible to resize the file system, the partition will be left unresized. When the partition doesn't exist on the storage device, the new version of the partition table will not be written to it.
This command doesn't move the start of the partition but only its end.
The command name_progress_bar
may be omitted. The debconf
template must have type text. It will be used to give the user information of
what is being done.
Synopsis:
cd device_directory open_dialog GET_RESIZE_RANGE partition_id read_line minimal_size current_size maximal_size close_dialog
This command returns the minimal and the maximal size that can be achieved by using the command RESIZE_PARTITION. $minimal_size, $current_size and $maximal_size are measured in bytes.
Synopsis:
cd destination_device_directory name_progress_bar some/debconf/template open_dialog COPY destination_id source_device source_id close_dialog
This command copies into the partition with id destination_id the contents of the partition with id source_id. source_device is $(basename source_device_directory).
The command name_progress_bar
may be omitted. The debconf
template must have type text. It will be used to give the user information of
what is being done.
[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ next ]
Partition Management for the Debian Installer
Anton Zinovievmailto:anton@lml.bas.bg