You ask — we answer!

Disk partitioning in Linux

Create new partition

Locate the device name within the operating system:

sudo fdisk -a
Disk /dev/sda: 447.13 GiB, 480103981056 bytes, 937703088 sectors
  Disk model: INTEL SSDSC2KB48
  Units: sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 4096 bytes
  I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  …

Next create at least one partition:

sudo fdisk /dev/sda

Press these keys one by one to create a new GPT partition scheme and partition which uses all available space on device:

g → n → Enter → Enter → Enter → w

New partition is the first on /dev/sda and named /dev/sda1. Create EXT4 filesystem in this partition:

sudo mkfs.ext4 /dev/sda1

Now everything is ready to mount.

Temporary disk mount

Attention! This will only work until the server is restarted. If you want the disk to be mounted automatically after a reboot, please proceed to the permanent mount.

Create a directory, which will be used as a disk mount point. For example in /tmp:

mkdir /tmp/ssd

And mount /dev/sda1 partition in this directory:

sudo mount -t ext4 /dev/sda1 /tmp/ssd

Following this, review the outcome:

df -h
Filesystem      Size  Used Avail Use% Mounted on
  …
  /dev/sda1       440G   28K  417G   1% /tmp/ssd
  …

Permanent disk mount

Warning! Please proceed with the following operation with great care. Any mistake made while modifying the fstab file can result in your server being unable to boot normally, and may require a complete reset of the operating system.

Find UUID of created partition:

sudo blkid
/dev/sda1: 
  ...
  UUID="fb2ba455-2b8d-4da0-8719-ce327d0026bc" 
  BLOCK_SIZE="4096" TYPE="ext4" 
  PARTUUID="6e0108df-b000-5848-8328-b187daf37a4f"
  ...

Tell the system that we would like to mount this drive by its UUID automatically at boot time:

sudo nano /etc/fstab

Enter this line before /swap.img… string:

/dev/disk/by-uuid/[PARTITION_UUID] /home/usergpu ext4 defaults defaults

Exit with Ctrl + X keyboard shortcut and confirm the saving file by pressing Enter. New settings will be applied on the next system start.

Reboot the server:

sudo shutdown -r now

Then check the result:

df -h
  Filesystem      Size  Used Avail Use% Mounted on
  …
  /dev/sda1       440G   28K  417G   1% /home/usergpu
  …


Published: 22.04.2024


Still have questions? Write to us!

By clicking «I Accept» you confirm that you have read and accepted the website Terms and Conditions, Privacy Policy, and Moneyback Policy.