When I was building a personal computer, I had several opportunities to add HDDs, and each time I was investigating how to add HDDs. So here are the steps you took in your environment.
In addition, the environment is
Ubuntu 20.04LTS, and we will proceed assuming that the HDD is already connected.
First, check how the HDD you want to add is recognized on the Ubuntu side.
dmesg | lv
When you hit
[ 2.547103] EXT4-fs (nvme0n1p2): mounted filesystem with ordered data mode. Opts: (null)
[ 1.196264] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300) [ 1.196984] ata2.00: ATA-10: WDC WD40EFAX-68JH4N0, 82.00A82, max UDMA/133 [ 1.196985] ata2.00: 7814037168 sectors, multi 16: LBA48 NCQ (depth 32), AA [ 1.197574] ata2.00: configured for UDMA/133 [ 1.197712] scsi 1:0:0:0: Direct-Access ATA WDC WD40EFAX-68J 0A82 PQ: 0 ANSI: 5 [ 1.197885] sd 1:0:0:0: [sda] 7814037168 512-byte logical blocks: (4.00 TB/3.64 TiB) [ 1.197886] sd 1:0:0:0: [sda] 4096-byte physical blocks [ 1.197889] sd 1:0:0:0: [sda] Write Protect is off [ 1.197890] sd 1:0:0:0: [sda] Mode Sense: 00 3a 00 00 [ 1.197895] sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
It is displayed as. Below, we will proceed as adding
HDDs of 2TB or more need to be formatted in GPT format instead of the usual format.
sudo parted /dev/sda
Now that you can access
/ dev/sda, allocate GPT.
Then create a partition.
At this point, you will be asked to start and end the sector, so you can allocate disk space as needed.
sudo mkfs.ext4 /dev/sda1
Format as ext4 format.
The HDD is ready, but ubuntu has not been set up yet. First, check the UUID of the disk.
sudo blkid /dev/sda1 /dev/sda1: UUID="2745c617-1428-4d4d-ab18-hogehoehoed9" TYPE="ext4" PARTLABEL="pub" PARTUUID="hogehoge-1416-4c61-b6a3-hoehoe"
Copy the UUID value to fstab. Here, assuming that/dev/sda1 is mounted as/pub,
UUID=22745c617-1428-4d4d-ab18-hogehoehoed9 /pub ext4 defaults 0 2
sudo mount -a
The HDD will be mounted with.
With a HDD of 2TB or more, the entire capacity cannot be used up with the normal format. It is necessary to allocate GPT to HDD and then format it with ext4 etc.