I’m trying to resize the partition in such a way that exactly fits for a 4 MiB Physical Extents. This means that the partition sectors must add up to an exact number to fit this criteria. By doing this, I can convert the partition to a LVM partition.
The partition right now looks like this:
sudo fdisk -l /dev/sda Disk /dev/sda: 32 GiB, 34359738368 bytes, 67108864 sectors Disk model: VBOX HARDDISK Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 9A97A1D8-0BC8-494B-9B88-1EC4F8AAE7CE Device Start End Sectors Size Type /dev/sda1 2048 512000 509953 249M BIOS boot /dev/sda2 999424 65107967 64108544 30.6G Linux filesystem /dev/sda3 65107968 67106815 1998848 976M Linux swap
I’m using a spreadsheet I made to see what size the partition needs to be. The partition right now is:
So I need to round it down to 7825 PE so it becomes:
Resizing it in GParted from 31303 MiB to 31300 MiB doesn’t work. It becomes 31299 MiB.
Maybe there is some basic knowledge I just don’t know of? Atleast I would expect GParted to not give an option to resize between 1-3 MiBs.
Same applies to resize2fs.
What is the reason this is not possible with GParted?
Is there any way to partition the size by 1 or 3 MiBs at all?
Partitions need to be aligned and when misaligned will error out so tools will align it automatically. parted the backend of gparted has an automatic alignment but also an option to turn it off.
parted /dev/sda align-check opt n
where n is the partition. Also from the manual there are options for this:
-a alignment-type, –align alignment-type
Set alignment for newly created partitions, valid alignment types are:
- none Use the minimum alignment allowed by the disk type.
- cylinder Align partitions to cylinders.
- minimal Use minimum alignment as given by the disk topology information. This and the opt value will use layout information provided by the disk to align the logical partition table addresses to actual physical blocks on the disks. The min value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.
- optimal Use optimum alignment as given by the disk topology information. This align to a multiple of the physical block size in a way that guarantees optimal performance.
Most tools use a default 1Mb alignment. But…
- on MBR disks: the size or offset parameters are rounded up to cylinder alignment.
- On GPT disks: the size or offset parameters are rounded up to sector alignment.