24.12 Formatting and Partitioning Disks


Connecting a new disk to a computer may require the disk to be partitioned and then the partitions of the disks to be formatted before it can be used. The default Ubuntu graphical disk utility is simply called Disks. It can also be run as the command gnome-disks from the gnome-disk-utility package, which also provides the gnome-disk-image-mounter command. gnome-disks can format and partition drives, mount and unmount partitions including LUKS encrypted partitions, and query S.M.A.R.T. attributes.

An older graphical tool for managing disks and their partitions is gparted. Running gparted with sudo (super user do) is required as the operations it performs are privileged and potentially can overwrite current data on disk.

Alternatively we use the command line and in particular the command cfdisk from the util-linx package which can partition a disk. Then use mkfs.ext4 from e2fsprogs to format the disk:

sudo cfdisk /dev/sdb
sudo mkfs.ext4 /dev/sdb1

To give a partition a label that is visible to the operating system we can use e2label

sudo e2label /dev/sdc1
sudo e2label /dev/sdc1 frederick

To now mount the disk, and have it take effect on a reboot see Section24.13.

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0