how to configure block size of container partition?

Alibek

Well-Known Member
Jan 13, 2017
102
15
58
44
For example:
have ocfs2 mounted volume as storage on proxmox.
ocfs2 volume have next blocksize
Code:
/sbin/tunefs.ocfs2 -Q 'blocksize: %B\nclustersize: %T\n' /dev/sdd1
blocksize: 4096
clustersize: 4096
and volume on barmetal storage and hdd/ssd have 512 or 4096 bytes blocksize.

After create container, created image have partition with blocksize: 512 bytes
That is not good for align and have penalties on write:
512 -> 4096 -> 512

Code:
fdisk -l /data1/images/100/vm-100-disk-1.raw

Disk /data1/images/100/vm-100-disk-1.raw: 8 GiB, 8589934592 bytes, 16777216 sectors
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: dos
Disk identifier: 0x9bf7d5ca

Device                               Boot Start      End  Sectors Size Id Type
/data1/images/100/vm-100-disk-1.raw1 *     2048 16775167 16773120   8G 83 Linux
or
Code:
fdisk -l /dev/mapper/vg01-vm--104--disk--1

Disk /dev/mapper/vg01-vm--104--disk--1: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

How to setup blocksize for containers on create?
 
For example:
have ocfs2 mounted volume as storage on proxmox.
ocfs2 volume have next blocksize
Code:
/sbin/tunefs.ocfs2 -Q 'blocksize: %B\nclustersize: %T\n' /dev/sdd1
blocksize: 4096
clustersize: 4096
and volume on barmetal storage and hdd/ssd have 512 or 4096 bytes blocksize.

After create container, created image have partition with blocksize: 512 bytes
That is not good for align and have penalties on write:
512 -> 4096 -> 512


How to setup blocksize for containers on create?


Partitioning of root-filesystem is not configurable.

You can mount any prepared partition as additional filesytem in a container's mountpoint by pct commant, e.g.

Code:
pct set 161 -mp1 /dev/sdc6,mp=/mnt/disk2

can be also a file, which has to be presented as loop device, e.g.:

Code:
losetup /dev/loop6 myfile
pct set 161 -mp2 /dev/loop6,mp=/mnt/disk3

For having your self-created root-filesystem device the following workaround should work (even it's not an officially supported method):


- create your own file (e.g. by making a filesystem with 4k blocks on it) which will contain the root-filesystem

- stop your container

- mount both the original container filesystem and the new one in the host system

- copy all files from the original fielesystem to the new one

- unmount both files

- overwrite the original file with the new file

That's it! You can start the container and it will now use the new filesystem (with e.g. 4k blocks).
 
Thx! I known this method but this is wrong way for many times creating container from webui.
I think need field "Block size" in dialog "Create container" (feature request).
 
Also be good if some default parameters may set per DC, per Pool, per Node.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!