Using fdisk to create a partition!
Using fdisk to create a partition on a hard drive for your Ubuntu server is easy!
First determine the drive you want to format, the easiest way to figure that out is by using “sudo lshw -C disk” to figure out the exact drive name and “sudo fdisk -l” to list drives + any partitions that may already be created
You will get a similar output like this for the first command “sudo lshw -C disk“:
You will get a similar output like this for the second command “sudo fdisk -l“:
We are going to format our drive partition “/dev/sdb” note that this “sdb” corresponds to the sata connection it is plugged into on the motherboard.
Now lets create a fresh partition that uses the whole drive by typing the following; but first read the example of each line we will go through just so you understand which each does:
d = delete a partition
n = add a new partition
w = write table to disk and exit
sudo fdisk /dev/sdb
Primary (Accept Defaults)
1 (Accept Defaults)
First Sector (Accept Defaults)
Last Sector (Accept Defaults)
You should now have a new partition called “/dev/sdb1” you can check this by using “df -H” again.
If you would like to create a file system for your new partition you can find my guide here.
Also to auto mount on boot please follow my fstab guide found here
- Additional fdisk information can be found here