[Ubuntu] 00. How to add a 2nd HDD - achishis2/achishis2.github.io GitHub Wiki
Note: If you do not need to format your HDD, skip to all the way down to the mount, directly.
$ sudo fdisk -l
$ sudo fdisk /dev/sdb
After the fdisk menu comes up, you might get the following warning message:
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u')
Command (m for help):
Press “u” like it is telling you. Then press “n” to create a new partition. It will respond with:
Command action e extended p primary partition (1-4)
Tell it “p” for “primary partition”. Next it will ask you which partition (1 – 4). In my case, I just want one big partition, so I just accept the default responses for the first and last sectors.
Next we need to tell fdisk which type of formatting we want. As of this writing, we want type code 83 for Linux. For a complete list of all drive types, just press “L”.
When everything is configured press “w” to write the partition changes to the disk. Important! If you don't write the changes to the disk, the changes won't be saved! Finally press “q” to quit fdisk.
Command (m for help): u
Changing display/entry units to sectors
Command (m for help): d
No partition is defined yet!
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-488397167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-488397167, default 488397167):
Using default value 488397167
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Update the kernel with the changes
$ sudo partprobe /dev/sdb
Format HDD
$ sudo mkfs /dev/sdb1 -t ext4
Create a directory for a mount point
$ sudo mkdir /mnt/sdb1
$ sudo chmod 777 /mnt/sdb1
Mount 2nd HDD
$ sudo mount /dev/sdb1 /home/tk/z -t ext4
In case, you did not have permission...
$ sudo chown <your_ID>. -Rf /media/<mounted_drive>
Mount 2nd HDD permanently
$ sudo vi /etc/fstab
Add following line at the end of the file:
/dev/sdb1 /home/tk/z ext4 defaults 0 0
Reboot or
$ sudo mount -a