Best way to create a 10 terabyte partition

I need to create a 10 terabyte partition on a Rocky 9.4 server. There is no GUI installed, it’s a minimal install, so gparted can’t be used. Fdisk gags on the size of the partition.
It’s going to be one huge partition, no need to segment it into smaller sizes.
What’s the best way to go about this?
Thanks, PG

You can use parted to do so. Use commands such as mklabel gpt and mkpart to help you.

[root@router ~]# parted /dev/sdf
GNU Parted 3.2
Using /dev/sdf
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA SAMSUNG MZHPV512 (scsi)
Disk /dev/sdf: 512GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name                  Flags
 1      1049kB  525MB   524MB   fat16        EFI System Partition  boot, esp
 2      525MB   1599MB  1074MB  ext4
 3      1599MB  512GB   510GB                                      lvm

(parted) unit B
(parted) print
Model: ATA SAMSUNG MZHPV512 (scsi)
Disk /dev/sdf: 512110190592B
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start        End            Size           File system  Name                  Flags
 1      1048576B     525336575B     524288000B     fat16        EFI System Partition  boot, esp
 2      525336576B   1599078399B    1073741824B    ext4
 3      1599078400B  512000000511B  510400922112B                                     lvm

(parted) help mkpart
  mkpart PART-TYPE [FS-TYPE] START END     make a partition

        PART-TYPE is one of: primary, logical, extended
        FS-TYPE is one of: btrfs, nilfs2, ext4, ext3, ext2, fat32, fat16, hfsx, hfs+, hfs, jfs, swsusp, linux-swap(v1), linux-swap(v0), ntfs, reiserfs, hp-ufs,
        sun-ufs, xfs, apfs2, apfs1, asfs, amufs5, amufs4, amufs3, amufs2, amufs1, amufs0, amufs, affs7, affs6, affs5, affs4, affs3, affs2, affs1, affs0,
        linux-swap, linux-swap(new), linux-swap(old)
        START and END are disk locations, such as 4GB or 10%.  Negative values count from the end of the disk.  For example, -1s specifies exactly the last
        sector.

        'mkpart' makes a partition without creating a new file system on the partition.  FS-TYPE may be specified to set an appropriate partition ID.

There is also gdisk command which should be able to do what fdisk cannot.

That looks like fdisk,which I’m more familiar with.
Would the appropriate hex code be “8300 Linux filesystem” if the final file system type is going to be xfs?

Yes, if a standard partition it should be 8300. Quick look at my partition type confirms that.

[root@rocky8 ~]# gdisk /dev/sda
GPT fdisk (gdisk) version 1.0.3

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): p
Disk /dev/sda: 83886080 sectors, 40.0 GiB
Model: Virtual disk    
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 16959302-A6A5-4766-848E-F2CC040E858E
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 83886046
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00  EFI System Partition
   2         1050624        83884031   39.5 GiB    8300  

and:

[root@rocky8 ~]# mount | grep sda2
/dev/sda2 on / type xfs (rw,noatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)

Ok, getting a little confused here. I created a primary 10TB partition using gdisk, gave it a hex label of 8300. When I go to put a file system on the drive, I used pvcreate, and lvcreate, which was maybe a mistake.
The ‘blkid’ command shows this as a “TYPE=LVM2_member” and "PARTLABEL-“Linux filesystem”
The server this is replacing shows that equivalent partition as TYPE=xfs and PARTLABEL=“primary”
I don’t necessarily want LVM partitions on this new system - the partitions won’t get expanded or shrunk - I’m more concerned about performance and reliability.
Is it better to go with LVM partitions, or to go with a regular basic primary partitions?

Obviously, if you do use the partition as PV, then the type code should be something else than 8300. (Perhaps 8e00.)
The gdisk can list known codes (just like fdisk does).


On some disk where I did create multiple partitions, the gdisk did give same name for each. (Probably shown as PARTLABEL.) Kernel was barfing at those names, so I’ve changed those names to be unique and descriptive ever since.


If you don’t need LVM there, then don’t use LVM.
Note: it is not possible to shrink exisitng XFS. That detail people do stumble on with and without LVM.

As @jlehtone says, if you don’t need LVM, don’t use it. All you needed to do is create the partition with type 8300, and then format the partition with xfs instead of creating LVM on it. If the disk is being used for a single partition, then at this point it’s up to you whether you use LVM or not. I would probably use LVM on it, if I was going to have multiple partitions, since I could then resize any one of them. If they were standard partitions, I could only resize the last partition on the disk. If it was a single partition, I would probably just create a single standard partition without LVM.

There is also growpart which can help resize partitions as well, so if you do go for a single partition, and then decide you want to resize it later (assuming you didn’t use the full disk), then you can do that easily enough and doesn’t require rebooting either. So similar to how LVM resizes inasmuch that the reboot is not needed. Unlike before when we used to go into fdisk, delete the partition and recreate it, ensuring the start sector was the same.

Generally, it’s personal preference and flexibiltiy depending on whether you want LVM for resizing say multiple partitions, or if it will be just a single partition, just create a standard one.

Unless there’s a performance advantage with LVM, I’d prefer not to use it.
After creating the partition with gdisk, how do you go from the raw partition and put a file system on it?
I ran mkfs.xfs /dev/sdb1, and got a message that “device or resource is busy”
I then ran “parted /dev/sdb1 print” and got an error about “unrecognized disk label”
Model: Unknown
Disk /dev/sdb1: 11.0TB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:

Actually, if I run “parted /dev/sdb print” (note its ‘/dev/sdb’ and not ‘/dev/sdb1’), I get
Model VMware Virtual disk (scsi)
Disk /dev/sdb: 11.0TB
Sector size (logical/physical0: 512B512B
Partition Table: gpt
Disk Flags

Number Start End Size File system Name Flags
1 1049kB 11.0TB 11.0TB Linux filesystem

Can you try the multipath stuff on this link, just in case it’s because of this: mkfs.xfs: cannot open /dev/sda1: Device or resource busy | Kenno's Open Note as they had similar error message.

Seems like something is accessing this partition, even though you didn’t want it to. I’ve never had that personally, so a bit strange.

You had LVM already on it? The LVM could hang on to the partition? Did you clear out that? (PV no longer in VG and PV metadata erased.)

1 Like

Well, now.

I deleted the whole partition to get back to a fresh start again, and then rebooted.
When it came back up again, I did a “pvs” and a “lvs” to see if there was anything that still thought it was an LVM partition, and only /dev/sda had LVM references on it.
Without doing any gdisk magic or parted magic, I just ran “mkfs.xfs /dev/sdb” and it worked.
I could mount /dev/sdb to a folder named /shared, and in df -h, it shows up as a 10TB partition.
I copied a couple of gigabytes of data over to that folder to make sure it was accepting data correctly and it seemed to work fine.
I suspect not rebooting before maybe made it fail to clear out some file holds LVM had on that space before, and that’s why it kept complaining “resource is busy”
Thank you to jlehtone, nazunalike, and iwalker for your patience and helpful info - it’s much appreciated.

Some partition tools show a warning saying that the kernel is still using the old vallues.

The only problem with this, or at least for me is you don’t see a partition table on the disk and assume it’s empty. I would at least have created /dev/sdb1 and then formatted this.

As long as you remember that there is no partition on it, and you don’t pull the disk out and put it in a pile of a few 10TB disks and then cannot remember which one was what, then you will be OK.

I remember a discussion once where people did similar with LVM on a disk without partitions, and most people suggested that creating a partition on the disk first was the better way to go. I apply the same logic for standard partitions as well rather then formatting an empty disk without a partition on it.

It’s on a vmware server, so there isn’t any physical disk to pull out. :slightly_smiling_face:

1 Like

Ah fair enough, so maybe not too much of a problem :slight_smile:

Regarding the concept of a “whole disk device”, this is a good intro

https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/8/html/configuring_and_managing_logical_volumes/managing-lvm-physical-volumes_configuring-and-managing-logical-volumes#managing-lvm-physical-volumes_configuring-and-managing-logical-volumes

If you can’t use gparted, then parted, the non-graphical version should work, you will need to use a gpt partition table. Also, you can use another machine and redirect the display to use gparted. I just use ssh -X target from a machine with a graphical display and launch it.