← All posts
January 23, 20242 min read
Disk Management with parted
Creating and formatting partitions with parted, verifying mounts, and making them permanent via /etc/fstab.
#linux#disk#parted
Installation
sudo apt install partedUseful parted commands
print— print the full partition table.select DEVICE— switch to a different device to edit.mklabel gpt— create a GPT label on the partition table.mkpart primary btrfs 1MiB 100%— create a primary partition formatted as BTRFS, spanning from 1MiB to the end of the disk.
Other useful disk management commands
lsblkandfdisk -l— show the disk configuration for every disk.sudo mkfs.btrfs -f /dev/sda1— formatsda1as BTRFS (not always necessary ifpartedalready did it).
Validate the result with df -h, which lists every mount point.
Making a mount permanent
To have a drive mount automatically on boot, add an entry to /etc/fstab:
- Get the partition's UUID with
lsblk -forsudo blkid. - Add a line in this format:
UUID=0f2b8e50-94c0-4385-abed-ce020da2555b /fast btrfs defaults 0 0- Reload the config with
systemctl daemon-reload.
Tip
To mount or unmount a drive temporarily without touching /etc/fstab: sudo mount /dev/sdb1 and sudo umount /mnt/loc.
For adding users and groups to control who can access a mount, see Linux User & Group Management.
Conclusion
parted is the most capable partition tool available at the terminal — used carefully, it can save a lot of time over GUI tools.
References