Download the following tools using your package manager, for Debian/Ubuntu (in case you are using a very streamlined version):
sudo apt install parted e2fsprogs
parted: "is a program to manipulate disk partitions. It supports multiple partition table formats, including MS-DOS and GPT. It is useful for creating space for new operating systems, reorganisā ing disk usage, and copying data to new hard disks." (from man parted
)
mkfs.ext4: Allows creation of Ext4 partitions (like a formatting tool)
df: Report disk space usage
sudo parted -l
The output will be similar to:
Model: Micon_2450_M123132
Disk /dev/sda: 1024GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 316MB 315MB fat32 EFI system partition boot, esp
2 316MB 450MB 134MB Microsoft reserved partition msftres
3 450MB 999GB 999GB ntfs Basic data partition msftdata
4 999GB 1000GB 944MB ntfs Basic data partition hidden, diag
5 1000GB 1024GB 24.1GB ntfs Basic data partition hidden, diag
Model: SSD 970 EVO Plus 1TB
Disk /dev/sdb: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
6 1049kB 886GB 886GB ext4
1 886GB 887GB 524MB fat32 boot, esp
Note the Disk names, they might be /dev/nvme0n1
or something like /dev/sda
, read more about devices at
Open parted pointing to the disk you will edit.
sudo parted /dev/sdb
Warning Make sure you are pointing to the correct device, otherwise you might lose data forever.
(parted) mkpart
(parted) Partition type? primary/extended? primary
(parted) File system type? [ext2]? ext4
(parted) Start? 0
(parted) End? 100%
(parted) print
You can use %
values for start and end.
The command is quite simple, not much to change around:
sudo mkfs.ext4 /dev/sdb1
You should be able to mount at any empty directory, for this example we will mount at /mnt/sdb1
:
sudo mkdir /mnt/sdb1
sudo mount /dev/sdb1 /mnt/sdb1
fstab
to mount it every time you bootAdd the mount to your fstab
file, make sure to point to the proper mount folder:
sudo echo /dev/sdb1 /mnt/sdb1 ext4 defaults 0 0 >>/etc/fstab
You can restart your and you should keep seeing the disk available.
df -h
Of course there is a graphic version for parted
, try gparted
.