Hi Folks, The "parted -m <dev> print" output is quite useful but it lacks the ability to specify an option to control the units which are displayed. The attached source diff for parted 3.0 adds a new command line option '--unit compact|sector|byte|cylinder|chs' which provides the desired behavior.
A typical usage might be: parted -m --unit sector /dev/sda print to get output like: /dev/sda:1465149168s:scsi:512:512:msdos:ATA ST3750640AS; 1:2048s:29296639s:29294592s:fat32::boot; 2:29298686s:1465147391s:1435848706s:::; 5:29298688s:87889919s:58591232s:ext4::; 6:87891968s:146483199s:58591232s:ext4::; 7:146485248s:179685375s:33200128s:linux-swap(v1)::; 8:179687424s:1465147391s:1285459968s:ext4::; I hope the development team will adopt this for future releases. Best regards, mike
*** parted/parted.c.ORIG Sat Feb 18 13:39:29 2012 --- parted/parted.c Sat Feb 18 13:53:40 2012 *************** *** 100,107 **** --- 100,127 ---- ALIGNMENT_MINIMAL, ALIGNMENT_OPTIMAL }; + ARGMATCH_VERIFY (align_args, align_types); + static char const *const unit_args[] = + { + "compact", + "sector", + "byte", + "cylinder", + "chs", + NULL + }; + + static PedUnit const unit_types[] = + { + PED_UNIT_COMPACT, + PED_UNIT_SECTOR, + PED_UNIT_BYTE, + PED_UNIT_CYLINDER, + PED_UNIT_CHS, + }; + typedef struct { time_t last_update; time_t predicted_time_left; *************** *** 114,119 **** --- 134,140 ---- {"machine", 0, NULL, 'm'}, {"script", 0, NULL, 's'}, {"version", 0, NULL, 'v'}, + {"unit", required_argument, NULL, 'u'}, {"align", required_argument, NULL, 'a'}, {"-pretend-input-tty", 0, NULL, PRETEND_INPUT_TTY}, {NULL, 0, NULL, 0} *************** *** 125,130 **** --- 146,152 ---- {"machine", N_("displays machine parseable output")}, {"script", N_("never prompts for user intervention")}, {"version", N_("displays the version")}, + {"unit=[compact|sector|byte|cylinder|chs]", N_("specify units to display")}, {"align=[none|cyl|min|opt]", N_("alignment for new partitions")}, {NULL, NULL} }; *************** *** 1823,1828 **** --- 1845,1851 ---- _parse_options (int* argc_ptr, char*** argv_ptr) { int opt, help = 0, list = 0, version = 0, wrong = 0; + PedUnit unit; while (1) { *************** *** 1841,1846 **** --- 1864,1874 ---- alignment = XARGMATCH ("--align", optarg, align_args, align_types); break; + case 'u': + unit = XARGMATCH ("--unit", optarg, + unit_args, unit_types); + ped_unit_set_default(unit); + break; case PRETEND_INPUT_TTY: pretend_input_tty = 1; break;