3

I am using ubuntu 20.04 and I want to create new partition disk with exactly 500 MB. However, the fdisk adjusted it to 512MiB is there any way that I can create exactly 500MB disk size?

fdisk output

ric@Eric:~/Downloads$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.34). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.

Command (m for help): n All primary partitions are in use. Adding logical partition 7 First sector (2359260-10288994, default 2359260): 2359260 Last sector, +/-sectors or +/-size{K,M,G,T,P} (2359260-10288994, default 10288994): +500M

Created a new partition 7 of type 'Linux' and of size 512 MiB.

Command (m for help): p Disk /dev/sda: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors Disk model: Portable SSD T5 Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 33553920 bytes Disklabel type: dos Disk identifier: 0xd13fa933

Device Boot Start End Sectors Size Id Type /dev/sda1 * 1952501760 1953523711 1021952 499M ef EFI (FAT-12/16/32) /dev/sda2 1950453760 1952501759 2048000 1000M 83 Linux /dev/sda3 1704693760 1950453759 245760000 117.2G 83 Linux /dev/sda4 65536 10288994 10223459 4.9G 5 Extended /dev/sda5 131071 1179629 1048559 512M 83 Linux /dev/sda6 1245165 2293724 1048560 512M 83 Linux /dev/sda7 2359260 3407819 1048560 512M 83 Linux

Partition table entries are not in disk order.

Command (m for help):

  • hello i am using ubuntu 20.04 i used the command +500M however the result is 512MiB is it possible to actuallly made exactly 500M parition ? – Eric Steven Jan 03 '21 at 07:58

1 Answers1

3

This can be solved with math! The sectors are 512 bytes in size, which means you need a million to have 500MB.

First sector (2359260-10288994, default 2359260): 2359260
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2359260-10288994, default 10288994): 3359260

However, be prepared for the number to not be exactly 500MB if:

  • the storage controller on the SSD does not like the number
  • the storage controller on the main board does not like the number

A lot of math has gone into how data is written and organized on storage devices over the years and there are some situations that are suboptimal for the long-term use of a device.