23.14 Partition and Format

20190118 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. A useful 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 can use the command line and in particular the command cfdisk from the util-linx package which can be used to 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

The disk can then be mounted into the file system of the computer so that we can easily access its contents. A quick way to do so is to simply mount the device onto the temporary mount point:

  $ sudo mount /dev/sdb1 /mnt
  $ ls /mnt

To mount the disk on boot and into a fixed location we will give the disk a name, like sabrina, create a mount point for the disk

  $ sudo mkdir /media/sabrina

and add an entry into /etc/fstab.

UUID=767f41ad-5b32-310f-aa89-54a24e26687 /media/sabrian ext4 defaults,errors=remount-ro,noatime 0 0

The UUID comes from:

  $ sudo -i blkid | grep sdb1

We can manually mount the disk using:

  $ sudo mount /media/sabrina


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