Skip to content

Powered by Grav

Basic commands

Current storage state

BASH
lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT | grep -E 'sd[a-z]|nvme'
echo "---"
df -h --output=source,size,used,avail,pcent,target | grep -E 'sd[a-z]|nvme|/dev'
  • lsblk lists all disks and partitions, their size, file system and mount points
  • df -h shows used / available space in readable units
  • grep filters physical dissudo partprobeks (SSD/HDD) and their mounted partition
sda                      5,5T LVM2_member 
nvme0n1                  1,8T             
├─nvme0n1p1                1G vfat        /boot/efi
├─nvme0n1p2              120G ext4        /
└─nvme0n1p3               30G ext4        /home
---
/dev/nvme0n1p2                     118G   27G   85G  25% /
tmpfs                               24G     0   24G   0% /dev/shm
/dev/nvme0n1p3                      30G  2,5G   26G   9% /home
/dev/nvme0n1p1                     1,1G  6,2M  1,1G   1% /boot/efi
/dev/mapper/vg--data-lv--video     1,5T  803G  632G  56% /video
/dev/mapper/vg--data-lv--www        30G  3,5G   25G  13% /www
/dev/mapper/vg--data-lv--cloud     1,5T  420G 1015G  30% /cloud
/dev/mapper/vg--data-lv--pub        63G  482M   59G   1% /pub

Add a simple partition

In this example, nvme0n1 is a 2TB SSD with 3 partitions; using gdisk rather than fdisk is best for gpt partitions

BASH
sudo gdisk -l /dev/nvme0n1
GPT fdisk (gdisk) version 1.0.10

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

Found valid GPT with protective MBR; using GPT.
Disk /dev/nvme0n1: 3907029168 sectors, 1.8 TiB
Model: CT2000P3SSD8                            
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 709A2165-E3EC-4C74-9476-D961AF936578
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 3907029134
Partitions will be aligned on 2048-sector boundaries
Total free space is 3590254701 sectors (1.7 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2203647   1.0 GiB     EF00  
   2         2203648       253861887   120.0 GiB   8300  
   3       253861888       316776447   30.0 GiB    8300

Add a 4th Linux Filesystem 128GB partition with

BASH
sudo gdisk /dev/nvme0n1
GPT fdisk (gdisk) version 1.0.10

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/nvme0n1: 3907029168 sectors, 1.8 TiB
Model: CT2000P3SSD8                            
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 709A2165-E3EC-4C74-9476-D961AF936578
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 3907029134
Partitions will be aligned on 2048-sector boundaries
Total free space is 3590254701 sectors (1.7 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2203647   1.0 GiB     EF00  
   2         2203648       253861887   120.0 GiB   8300  
   3       253861888       316776447   30.0 GiB    8300  

Command (? for help): n
Partition number (4-128, default 4): 4
First sector (34-3907029134, default = 316776448) or {+-}size{KMGTP}: 
Last sector (316776448-3907029134, default = 3907028991) or {+-}size{KMGTP}: +128G
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Disk /dev/nvme0n1: 3907029168 sectors, 1.8 TiB
Model: CT2000P3SSD8                            
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 709A2165-E3EC-4C74-9476-D961AF936578
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 3907029134
Partitions will be aligned on 2048-sector boundaries
Total free space is 3321819245 sectors (1.5 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         2203647   1.0 GiB     EF00  
   2         2203648       253861887   120.0 GiB   8300  
   3       253861888       316776447   30.0 GiB    8300  
   4       316776448       585211903   128.0 GiB   8300

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.

Format the new partition

BASH
sudo partprobe
sudo mkfs.ext4 /dev/nvme0n1p4
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done                            
Creating filesystem with 33554432 4k blocks and 8388608 inodes
Filesystem UUID: 0e9eddaf-e35e-4712-a79f-15dd9cca576b
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

Auto-mount the new partition on start

Write down the UUID of the partition

BASH
sudo blkid | grep nvme0n1p4
/dev/nvme0n1p4: UUID="0e9eddaf-e35e-4728-a79f-15dd9cca576b" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="4d53e3fb-c333-423f-a2ff-c0cff05f5410"

Prepare the future mount point

BASH
sudo mkdir -p /cofrap

Edit fstab

BASH
sudo nano /etc/fstab

Add the line

TEXT
/dev/disk/by-uuid/0e9eddaf-e35e-4728-a79f-15dd9cca576b /cofrap ext4 defaults,nofail 0 0

Reload systemd

BASH
sudo systemctl daemon-reload

Check it's working

BASH
sudo mount -a
lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT /dev/nvme0n1
df -h /cofrap
NAME         SIZE FSTYPE MOUNTPOIN
nvme0n1      1,8T        
├─nvme0n1p1    1G vfat   /boot/efi
├─nvme0n1p2  120G ext4   /
├─nvme0n1p3   30G ext4   /home
└─nvme0n1p4  128G ext4   /cofrap
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p4  125G   28K  119G   1% /cofrap

© 2026 howto.cogip.be. All rights reserved.