Partition, format, and mount a drive on Ubuntu

List logical disks and partitions

sudo fdisk -l

Partition the disk

sudo fdisk /dev/sdb

  • Press n to create a partition
  • Press p or l to create primary or logical partitions
  • Press w to write your changes or q to quit

Format the partition

  • sudo mkfs -t ext4 /dev/sdb1
  • sudo mkfs -t ext4 -N 2000000 /dev/sdb1 - This will manually set the number of inodes to 2,000,000

Mount disk

  • mount - Shows what is mounted
  • mkdir /mnt/mydrive
  • mount -t ext4 /dev/sdb1 /mnt/mydrive

Get disk's UUID

ls -al /dev/disk/by-uuid/
or
blkid

Mount at boot

Add the following line to your /etc/fstab file adjusting the UUID to your device's id and the directory to where you want to mount:

UUID=811d3de0-ca6b-4b61-9445-af2e306d9999 /mnt/mydrive ext4 defaults 0 0

mount -a - remounts filesystems from /etc/fstab

  • Partition, format, mount, Ubuntu
  • 356 Users Found This Useful
Was this answer helpful?

Related Articles

Custom php settings when you enable Fast-CGI

When you enable fast-cgi, there should be a custom php.ini in the cgi-bin folder of the account.*...

Disk quota exceeded: mailbox is full

Issue:Email fails with the following error message.===Subject: Mail delivery failed: returning...

Can I edit DNS records from my CPanel?

You can edit DNS records from your CPanel by following the instructions in the two CPanel...

CentOS - Hostname Change

Hostname Change There are 4 steps in a hostname change, luckily all the steps are easy....

What Is A Reverse PTR Record?

PTR record or more appropriately a reverse PTR record is a process of resolving an IP address to...

Powered by WHMCompleteSolution