Skip to content

Instantly share code, notes, and snippets.

@aliabidzaidi
Created November 16, 2021 06:33
Show Gist options
  • Save aliabidzaidi/77c6844d025ab73b8e59898603330b2f to your computer and use it in GitHub Desktop.
Save aliabidzaidi/77c6844d025ab73b8e59898603330b2f to your computer and use it in GitHub Desktop.
Add Disk to Linux

https://askubuntu.com/questions/125257/how-do-i-add-an-additional-hard-drive

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.

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" next step it's to add the new hard disk in fstab for auto mount after reset:

sudo nano /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, CTRL+X then press Y and ENTER to save it.

UUID=9223a86b-5bd6-4bff-b0b6-d796293b6ffa /opt auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=opt 0 0

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment