Got a new hard drive for file server, but don’t want to use all the space for only one partition. And you can’t use GParted because you’re using Ubuntu Server. We can use parted for that purpose, here is how to use it:
-
I got a brand new 2TB hard drive, I want to make several partition from that. For now, I just want to make 1 partition with 25% of hard drive. Use
lsblk
to know location your new hard drive, then useparted /dev/sdb
.
lsblk To Know Your Hard Drive Mount Location
-
After enter the parted command, use
mklabel gpt
to define gpt as our partition table format. Usemkpart primary ext4 0% 25%
then useprint
to check your new partition. then typequit
to exit parted command -
Use
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT
again to check our partition.New Partition, Still in Raw Format
I don’t know why it’s still in raw format/unallocated because I already define it as ext4. Will update this post when I made a new partition, for now I will keep it just like this -
Use
mkfs.ext4 /dev/sdb1
to format partition as ext4. Check again uselsblk
, is it already got a fstype? -
To mount the drive automatically, you have to provide several info at /etc/fstab. Use
blkid
to check the UUID all partition. Make a new folder as a mount point your new partition,/newharddrive/partition1
. -
Add new line at /etc/fstab,
UUID=yourUUID /newharddrive/partition ext4 defaults 0 0
. Usemount -a
to automatically mount new partition. You can check mount partition usingmount -v