From c64061c9b306f2db49ba97d066b8487f66a914fa Mon Sep 17 00:00:00 2001 From: Vincent Deffontaines Date: Tue, 16 Sep 2008 13:08:12 +0200 Subject: [PATCH] fdisk: suggest partprobe(8) and kpartx(8) when BLKRRPART failed Signed-off-by: Vincent Deffontaines Signed-off-by: Karel Zak Co-Author: Karel Zak --- fdisk/cfdisk.8 | 17 +++++++++++------ fdisk/cfdisk.c | 8 ++++---- fdisk/fdisk.8 | 4 +++- fdisk/fdisk.c | 12 +++++------- fdisk/sfdisk.8 | 4 +++- fdisk/sfdisk.c | 13 +++++++------ 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/fdisk/cfdisk.8 b/fdisk/cfdisk.8 index 3cf8c894..0eaf5ab3 100644 --- a/fdisk/cfdisk.8 +++ b/fdisk/cfdisk.8 @@ -349,11 +349,14 @@ Write partition table to disk (must enter an upper case W). Since this might destroy data on the disk, you must either confirm or deny the write by entering `yes' or `no'. If you enter `yes', .B cfdisk -will write the partition table to disk and the tell the kernel to -re-read the partition table from the disk. The re-reading of the -partition table works in most cases, but I have seen it fail. Don't -panic. It will be correct after you reboot the system. In all cases, -I still recommend rebooting the system -- just to be safe. +will write the partition table to disk and the tell the kernel to re-read the +partition table from the disk. The re-reading of the partition table does not +work in some cases, for example for device-mapper devices. In +particular case you need to inform kernel about new +partitions by +.B partprobe(8), +.B kpartx(8) +or reboot the system. .TP .I Up Arrow .TP @@ -419,9 +422,11 @@ command (above) for more information on the print formats. 3: cannot get geometry; 4: bad partition table on disk. .SH "SEE ALSO" .BR fdisk (8), +.BR sfdisk (8), .BR mkfs (8), .BR parted (8), -.BR sfdisk (8) +.BR partprobe (8), +.BR kpartx(8) .SH BUGS The current version does not support multiple disks. .SH AUTHOR diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c index 300518d6..b0e18836 100644 --- a/fdisk/cfdisk.c +++ b/fdisk/cfdisk.c @@ -413,7 +413,7 @@ fdexit(int ret) { fprintf(stderr, _("Reboot the system to ensure the partition " "table is correctly updated.\n")); #endif - + fprintf( stderr, _("\nWARNING: If you have created or modified any\n" "DOS 6.x partitions, please see the cfdisk manual\n" "page for additional information.\n") ); @@ -1423,7 +1423,7 @@ new_part(int i) { { ESC, N_("Cancel"), N_("Don't create a partition") }, { 0, NULL, NULL } }; - + c = menuSimple( menuPartType, 0 ); if (toupper(c) == 'P') num = find_primary(); @@ -1918,7 +1918,7 @@ write_part_table(void) { if (changed) print_warning(_("Wrote partition table to disk")); else - print_warning(_("Wrote partition table, but re-read table failed. Reboot to update table.")); + print_warning(_("Wrote partition table, but re-read table failed. Run partprobe(8), kpartx(8) or reboot to update table.")); } else print_warning(_("Wrote partition table to disk")); @@ -2254,7 +2254,7 @@ print_tables(void) { { ESC, N_("Cancel"), N_("Don't print the table") }, { 0, NULL, NULL } }; - + while (!done) switch ( toupper(menuSimple( menuFormat, 2)) ) { case 'R': diff --git a/fdisk/fdisk.8 b/fdisk/fdisk.8 index ea829784..5798a539 100644 --- a/fdisk/fdisk.8 +++ b/fdisk/fdisk.8 @@ -243,9 +243,11 @@ The option `dump partition table to file' is missing. .\" and many others. .SH "SEE ALSO" .BR cfdisk (8), +.BR sfdisk (8), .BR mkfs (8), .BR parted (8), -.BR sfdisk (8) +.BR partprobe (8), +.BR kpartx (8) .SH AVAILABILITY The fdisk command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/. diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index add1a088..a8dfe5d2 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -1470,7 +1470,7 @@ change_sysid(void) { /* If sgi_label then don't use get_existing_partition, let the user select a partition, since get_existing_partition() only works for Linux like partition tables. */ - if (!sgi_label) { + if (!sgi_label) { i = get_existing_partition(0, partitions); } else { i = get_partition(0, partitions); @@ -2289,11 +2289,9 @@ reread_partition_table(int leave) { } if (i) { - printf(_("\nWARNING: Re-reading the partition table " - "failed with error %d: %s.\n" - "The kernel still uses the old table.\n" - "The new table will be used " - "at the next reboot.\n"), + printf(_("\nWARNING: Re-reading the partition table failed with error %d: %s.\n" + "The kernel still uses the old table. The new table will be used at\n" + "the next reboot or after you run partprobe(8) or kpartx(8)\n"), errno, strerror(errno)); } @@ -2599,7 +2597,7 @@ main(int argc, char **argv) { * fdisk [-b sectorsize] [-u] device * * Options -C, -H, -S set the geometry. - * + * */ while ((c = getopt(argc, argv, "b:C:H:lsS:uvV")) != -1) { switch (c) { diff --git a/fdisk/sfdisk.8 b/fdisk/sfdisk.8 index c2c8d98e..45819096 100644 --- a/fdisk/sfdisk.8 +++ b/fdisk/sfdisk.8 @@ -554,7 +554,9 @@ There is no support for non-DOS partition types. .BR cfdisk (8), .BR fdisk (8), .BR mkfs (8), -.BR parted (8) +.BR parted (8), +.BR partprobe (8), +.BR kpartx (8) .SH AVAILABILITY The sfdisk command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/. diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c index e52e3282..83be9ecc 100644 --- a/fdisk/sfdisk.c +++ b/fdisk/sfdisk.c @@ -809,7 +809,7 @@ reread_ioctl(int fd) { } static int -is_blockdev(int fd) { +is_blockdev(int fd, ) { struct stat statbuf; return(fstat(fd, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)); @@ -824,8 +824,9 @@ reread_disk_partition(char *dev, int fd) { sleep(3); /* superfluous since 1.3.20 */ if (reread_ioctl(fd) && is_blockdev(fd)) - do_warn(_("The command to re-read the partition table failed\n" - "Reboot your system now, before using mkfs\n")); + do_warn(_("The command to re-read the partition table failed.\n" + "Run partprobe(8), kpartx(8) or reboot your system now,\n" + "before using mkfs\n")); if (close(fd)) { perror(dev); @@ -1588,7 +1589,7 @@ msdos_partition(char *dev, int fd, unsigned long start, struct disk_desc *z) { } } } - + return 1; } @@ -1912,7 +1913,7 @@ max_length(int pno, int is_extended, struct part_desc *ep, int format, pp = outer_extended_partition(ep); } fu = pp ? (pp->start + pp->size) / unit : get_disksize(format); - + for(pp = partitions; pp < partitions+pno; pp++) if (!is_parent(pp, ep) && pp->size > 0 && pp->start / unit >= start && pp->start / unit < fu) @@ -1963,7 +1964,7 @@ compute_start_sect(struct part_desc *p, struct part_desc *ep) { } p->p.nr_sects = p->size; return 1; -} +} /* build the extended partition surrounding a given logical partition */ static int -- 2.39.5