0

Is there a way to use fdisk to define a new partition that is e.g. "100MB less" than the maximum possible size?

Background: Due to deviation between nominal disk size and physical disk size, and the necessity to replace a failed raid unit with one of equivalent size, it is recommended to build an mdadm array over partitions slightly smaller than the physical disk size.

3
  • Yes, there's a way. When fdisk asks for the last sector for the partition, you calculate and provide a value that results in the desired size. Do you need guidance on how to calculate? Or do you mean "automatically"? i.e. without manual calculation? Does it have to be with fdisk? Oct 26, 2020 at 17:48
  • Thanks @KamilMaciorowski, if you want to post your comment as an answer I'd be happy to accept it. I posted a sample formulation below for convenience
    – mkk
    Oct 26, 2020 at 19:05
  • 1
    I don't want to. I commented because it wasn't clear what guidance you wanted. I wasn't aware one can specify -100M; I knew about +100M and such. It probably depends on fdisk implementation or version. E.g. fdisk in my Kubuntu operates on sectors, not cylinders; and it doesn't understand -100M. I usually use a calculator, dc or bc (or a pencil and a piece of paper) to get the exact number for the last sector. Oct 26, 2020 at 19:27

1 Answer 1

0

The following is derived from an example I found this tutorial in TLDP-Partitioning with fdisk:

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-621, default 1):<RETURN>
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-621, default 621): -100M

Please note (as commented by @KamilMaciorowski) that fdisk may have multiple implementations that don't support this size-based positioning.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .