This example is from Adding a new EBS volume to a running AWS EC2 instance.
cat /proc/partitionsmajor minor #blocks name
259 0 314572800 nvme0n1
259 1 1024 nvme0n1p1
259 2 204800 nvme0n1p2
259 3 512000 nvme0n1p3
259 4 313853935 nvme0n1p4
259 5 524288000 nvme1n1 # <-- this is the new disk which has no partitions yet
If you can't see it yet, run partprobe
sudo partprobeand then repeat the above cat /proc/partitions (it has also appeared after a few seconds on EC2 without this)
You can create partitions using fdisk, gdisk or parted.
I prefer parted now because it's easier to script than fdisk, which I used to use interactively in the early to mid
2000s.
Create a new GPT partition table on the new disk:
sudo parted /dev/nvme1n1 --script mklabel gptCreate a new partition that spans the entire disk:
sudo parted /dev/nvme1n1 --script mkpart primary 0% 100%See the new partition:
cat /proc/partitions...
259 7 524285952 nvme1n1p1
Ext4:
sudo mkfs.ext4 /dev/nvme1n1p1or
XFS:
sudo mkfs.xfs /dev/nvme1n1p1lsblk -f /dev/nvme1n1or
sudo blkid /dev/nvme1n1p1Since device numbers can change on rare occasion such as when adding IDE/SCSI/SAS disks to cables / disk controller cards shunting the ordering of device numbers, find and use the UUID instead using one of these commands:
I like this one best for scripting due to its simple 2 column output format which is easy to parse:
lsblk -o NAME,UUIDthis one requires root permission:
sudo blkidls -l /dev/disk/by-uuid/findmnt -o TARGET,UUIDrequires root:
sudo fdisk -lotherwise gets this error as regular user:
fdisk: cannot open /dev/nvme0n1: Permission denied
requires root or returns blank:
sudo parted -lAdd it to /etc/fstab with a line like this, substituting the UUID from the above commands:
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /tmp xfs defaults 0 2If you're using a new mount point instead of /tmp that doesn't exist yet, then create it:
sudo mkdir -p /mnt/newdiskIf the mount point is /tmp make sure you shut down any processes that might be using it first like
Informatica agent.
Then mount it using this short form of the mount command which tests the fstab at the same time:
sudo mount /tmpmount: (hint) your fstab has been modified, but systemd still uses
the old version; use 'systemctl daemon-reload' to reload.sudo systemctl daemon-reloadCheck new mounted partition and space is available:
df -Th /tmpFilesystem Type Size Used Avail Use% Mounted on
/dev/nvme1n1p1 xfs 500G 3.6G 497G 1% /tmp
If you've just mounted a new /tmp make sure to set a sticky bit and world writable permissions for people and apps
to be able to use it:
sudo chmod 1777 /tmp