Identify hard disk
First you need to identified the new hard disk.
press CTRL+ALT+T to open a console then type :
lsblk
You will see something similar with this:
loop0 7:0 0 86.6M 1 loop /snap/core/4486
sda 8:0 0 5G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
└─sda2 8:2 0 4.5G 0 part /
sdb 8:16 0 10G 0 disk
sr0 11:0 1 1024M 0 rom
For example the sdb it’s the new hard disk that you want to add.
Format hard disk
If the sdb it’s a new hard disk , you need to format to ext3 or ext4
sudo mkfs.ext4 -j -L NewHDD /dev/sdb
Keep in mind, command above will delete everything on target hard disk. You can skip this step if there are any data on the hard disk and you want to not lose them.
Now you need the UUID of the new hard disk.
sudo blkid /dev/sdb
You will see something similar with this:
/dev/sdb: LABEL="NewHDD" UUID="5d6c8f68-dcc8-4a91-a510-9bca2aa71521" TYPE="ext4"
Swap on a different disk
You can create a swap partition on a separate drive by using mkswap and swapon.
Eg - To to migrate swap from /dev/sda3
to /dev/sdb1
swapoff /dev/sda3
mkswap /dev/sdb
swapon /dev/sdb
Now chen what we have:
lsblk
and found:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 447.1G 0 disk
├─sda1 8:1 0 431.2G 0 part /
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 16G 0 part
sdb 8:16 0 447.1G 0 disk [SWAP]
sr0 11:0 1 1024M 0 rom
Then edit swap entry in /etc/fstab
.
UUID=2b593f65-8f50-4317-8e0a-c649d5d8ba68 none swap sw 0 0
Or auto mount after reset
next step it’s to add the new hard disk in fstab for auto mount after reset:
sudo vim /etc/fstab
And add new line on bottom, with follow content:
/dev/disk/by-uuid/5d6c8f68-dcc8-4a91-a510-9bca2aa71521 /mnt/NewHDD auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=NewHDD 0 0
Remeber to replace the 5d6c8f68-dcc8-4a91-a510-9bca2aa71521
and /mnt/NewHDD
whit your own UUID and path where will be mounted. Save then exit.
To mount it use: sudo mount -a
, if the result will be:
mount: /mnt/NewHDD: mount point does not exist.
You must create mount point sudo mkdir /mnt/NewHDD
then use again: sudo mount -a
Also you need to change owner and group of the new hard disk using next command:
sudo chown user:user -R /mnt/NewHDD
Replace the: user:user
with your own user and group that you need it.