Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow reformatting of nvmes to different blocksizes #188

Open
fionera opened this issue Mar 24, 2023 · 8 comments
Open

Allow reformatting of nvmes to different blocksizes #188

fionera opened this issue Mar 24, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@fionera
Copy link

fionera commented Mar 24, 2023

I run servers with NVMes that are formatted to a block size of 512b by default. It would be cool to have the ability to reformat these to a 4k block size. Is this in the scope of this project?

For now I will implement this by using a hook but a native way would be very nice

@Mic92
Copy link
Member

Mic92 commented Mar 24, 2023

Should this not already be possible by having additional mkfs arguments passed when formatting a partition?

extraArgs = lib.mkOption {

It takes an extraArgs which could be set to -b 4096.

@fionera
Copy link
Author

fionera commented Mar 25, 2023

Afaik thats only for the filesystem and not the nvme itself

@Mic92
Copy link
Member

Mic92 commented Mar 25, 2023

Are you talking about aligning partitions to a 4k boundary? Can you give an example of what arguments to what command would needs to be changed?

@fionera
Copy link
Author

fionera commented Mar 25, 2023

I am talking about the lbaf parameter at eg nvme-cli https://www.mankier.com/1/nvme-format

@Mic92
Copy link
Member

Mic92 commented Mar 25, 2023

Ah. I see nvme namespaces could be a thing in disko. The api would probably looks similar to partitions?

@Lassulus
Copy link
Collaborator

I guess we would need a different table implementation. But I want to split the current one into a gpt and dos table type anyway. The namespaces could be an attrsOf in the new nvme_table type. An nvme_table would only work with nvme drives though. So we would need an assertion for that. For just blocksizes we could also add a option to the current table type. Not sure what reformatting means in this context though

@fionera
Copy link
Author

fionera commented Mar 26, 2023

when you call nvme format it is possible to change the blocksize. Its just a call to the internal nvme formatting function. there is an annoying side effect of having to rebind the devices, as the addressing on pcie is different afterwards

nix-shell -p pciutils nvme-cli jq
# the nvmes we use have 1 as 4k format. thats disk dependend tho
nvme list -o json | jq -r .Devices[].DevicePath | xargs -I{} nvme format -l 1 --force {}

for i in $(lspci | grep NVMe | awk '{print $1}'); do \
 echo 0000:$i > /sys/bus/pci/drivers/nvme/unbind; \
 echo 0000:$i > /sys/bus/pci/drivers/nvme/bind; \
done

@iFreilicht
Copy link
Contributor

From my understanding, this would either require an extension to the disk type, or to clone the disk type into a new nvme type that then has additional options for running and passing arguments to nvme-format, right?

@iFreilicht iFreilicht added the enhancement New feature or request label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants