Partitioning Namespaces
It is possible to partition raw, sector, and fsdax devices (namespaces) using tools such as fdisk, parted, or gparted, etc. This is useful to meet application space requirements.
The following shows how to partition a new namespace with no existing partition table using fdisk and parted. If an existing partition table exists, delete or modify the entries first. The example uses a 256GB FSDAX device (namespace) and creates 2 x 100GB and 1 x ~50GB partitions on which filesystems can be created.
WARNING: Data could or will be lost. Backup the data before proceeding.
Print the current partition table, if any, using fdisk -l:
$ sudo fdisk -l /dev/pmem0
Disk /dev/pmem0: 245.1 GiB, 263182090240 bytes, 514027520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes1) Launch fdisk for the device (/dev/pmem0)
$ sudo fdisk /dev/pmem0
Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0xc637b85f.
Command (m for help):2) Create the first new 100GB partition using the '(n)ew' command
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-514027519, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-514027519, default 514027519): +100G
Created a new partition 1 of type 'Linux' and of size 100 GiB.3) Create the second new 100GB partition using the '(n)ew' command:
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (2-4, default 2):
First sector (209717248-514027519, default 209717248):
Last sector, +sectors or +size{K,M,G,T,P} (209717248-514027519, default 514027519): +100G
Created a new partition 2 of type 'Linux' and of size 100 GiB.4) Create the last partition using the remaining space:
5) Print the new partition table to verify the changes using the '(p)rint' command:
6) Commit the changes using the '(w)rite' command and return to the shell prompt:
1) Launch parted and select the device (/dev/pmem0)
2) Create the first new 100GB partition using the 'mkpart' command
3) Create the second new 100GB partition using the 'mkpart' command:
4) Create the last partition using the remaining space (-1MiB):
5) Print the new partition table to verify the changes using the 'print' command:
6) Quit parted and return to the shell prompt:
The partitions can now be used with DAX enabled filesystems such as EXT4 and XFS and mounted with the -o dax option. The following shows how to create and mount an EXT4 or XFS filesystem.
Last updated