When editing MBR partitions under fdisk(8), you always get asked whether you want to edit the MBR in C/H/S or LBA mode.
On modern non-x86 platforms using MBR-style partitions, C/H/S doesn't make any sense. What about adding a `always use LBA' option to fdisk(8) (to later be used in the installation media for, say, loongson)? Miod Index: sbin/fdisk/cmd.c =================================================================== RCS file: /cvs/src/sbin/fdisk/cmd.c,v retrieving revision 1.45 diff -u -p -r1.45 cmd.c --- sbin/fdisk/cmd.c 2 Jul 2010 02:54:09 -0000 1.45 +++ sbin/fdisk/cmd.c 19 Nov 2010 21:28:05 -0000 @@ -144,6 +144,7 @@ Xedit(cmd_t *cmd, disk_t *disk, mbr_t *m { int pn, num, ret; prt_t *pp; + extern int l_flag; ret = CMD_CONT; @@ -179,7 +180,7 @@ Xedit(cmd_t *cmd, disk_t *disk, mbr_t *m } /* Change table entry */ - if (ask_yn("Do you wish to edit in CHS mode?")) { + if (!l_flag && ask_yn("Do you wish to edit in CHS mode?")) { int maxcyl, maxhead, maxsect; /* Shorter */ Index: sbin/fdisk/fdisk.8 =================================================================== RCS file: /cvs/src/sbin/fdisk/fdisk.8,v retrieving revision 1.72 diff -u -p -r1.72 fdisk.8 --- sbin/fdisk/fdisk.8 5 Jul 2010 21:57:13 -0000 1.72 +++ sbin/fdisk/fdisk.8 19 Nov 2010 21:28:05 -0000 @@ -31,7 +31,7 @@ .Nd MBR partition maintenance program .Sh SYNOPSIS .Nm fdisk -.Op Fl eiuy +.Op Fl eiluy .Oo .Fl c Ar cylinders .Fl h Ar heads @@ -119,6 +119,10 @@ In the default template, MBR partition n MBR partition spanning the entire disk, except for a zone left at the start for booting. This mode is designed to initialize the MBR the very first time. +.It Fl l +In the +.Nm +interactive editor, always use LBA values for partition boundaries. .It Fl u Update MBR bootcode, preserving existing MBR partition table. The MBR bootcode extends from offset 0x000 to the start of the MBR partition table Index: sbin/fdisk/fdisk.c =================================================================== RCS file: /cvs/src/sbin/fdisk/fdisk.c,v retrieving revision 1.51 diff -u -p -r1.51 fdisk.c --- sbin/fdisk/fdisk.c 25 May 2010 18:51:02 -0000 1.51 +++ sbin/fdisk/fdisk.c 19 Nov 2010 21:28:05 -0000 @@ -42,6 +42,7 @@ static unsigned char builtin_mbr[] = { #include "mbrcode.h" }; +int l_flag; int y_flag; static void @@ -50,11 +51,12 @@ usage(void) extern char * __progname; fprintf(stderr, "usage: %s " - "[-eiuy] [-c cylinders -h heads -s sectors] [-f mbrfile] disk\n" + "[-eiluy] [-c cylinders -h heads -s sectors] [-f mbrfile] disk\n" "\t-i: initialize disk with virgin MBR\n" "\t-u: update MBR code, preserve partition table\n" "\t-e: edit MBRs on disk interactively\n" "\t-f: specify non-standard MBR template\n" + "\t-l: edit partitions in LBA mode\n" "\t-chs: specify disk geometry\n" "\t-y: do not ask questions\n" "`disk' may be of the forms: sd0 or /dev/rsd0c.\n", @@ -79,7 +81,7 @@ main(int argc, char *argv[]) mbr_t mbr; char mbr_buf[DEV_BSIZE]; - while ((ch = getopt(argc, argv, "ieuf:c:h:s:y")) != -1) { + while ((ch = getopt(argc, argv, "ieuf:c:h:s:yl")) != -1) { const char *errstr; switch(ch) { @@ -114,6 +116,9 @@ main(int argc, char *argv[]) case 'y': y_flag = 1; break; + case 'l': + l_flag = 1; + break; default: usage(); } @@ -129,6 +134,8 @@ main(int argc, char *argv[]) /* Put in supplied geometry if there */ if (c_arg | h_arg | s_arg) { + if (l_flag) + errx(1, "-l and -chs can't be used together"); usermetrics = malloc(sizeof(DISK_metrics)); if (usermetrics != NULL) { if (c_arg && h_arg && s_arg) {