diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8 index 0991f6962..44db73bb5 100644 --- a/disk-utils/sfdisk.8 +++ b/disk-utils/sfdisk.8 @@ -133,7 +133,7 @@ Back up the current partition table sectors before starting the partitioning. The default backup file name is ~/sfdisk--.bak; to use another name see option \fB\-O\fR, \fB\-\-backup\-file\fR. .TP -.BR \-\-color [ \fI=when ] +.BR \-\-color[\fI=when] Colorize the output. The optional argument \fIwhen\fP can be \fBauto\fR, \fBnever\fR or \fBalways\fR. If the \fIwhen\fR argument is omitted, it defaults to \fBauto\fR. The colors can be disabled; for the current built-in default @@ -155,6 +155,33 @@ Do not check through the re-read-partition-table ioctl whether the device is in .BR \-O , " \-\-backup\-file " \fIpath\fR Override the default backup file name. Note that the device name and offset are always appended to the file name. +.TP +.BR \-\-move-data[\fI=path] +Move data after partition relocation, for example when move begin of the +partition to another place on the disk. The size of the partition has to be the +same, the new and old location may overlap. The option requires \fB\-N\fR to be +processed on one specified partition only. + +The \fIpath\fR overrides the default log file name +(the default is ~/sfdisk-.move). The log file contains information +about all read/write oprations with the partition data. + +Note that this operation is ricky and not atomic. \fBDon't forget to backup your data!\fR + +The example below creates 100MiB free area before the first partition and moves +data (e.g. filesystem), the next command creates a new partition from the free +space (at offset 2048) and the last command reorder partitions to match disk +order (original sdc1 will be sdc2). +.RS +.sp +.B "echo '+100M,' | sfdisk --move-data /dev/sdc -N 1" +.br +.B "echo '2048,' | sfdisk /dev/sdc --append +.br +.B sfdisk /dev/sdc --reorder +.sp +.RE + .TP .BR \-o , " \-\-output " \fIlist Specify which output columns to print. Use diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 21e90835b..9f4861188 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #ifdef HAVE_LIBREADLINE # include @@ -46,6 +47,7 @@ #include "all-io.h" #include "rpmatch.h" #include "loopdev.h" +#include "xalloc.h" #include "libfdisk.h" #include "fdisk-list.h" @@ -89,9 +91,11 @@ struct sfdisk { const char *label; /* --label