How to mount a new drive on startup
First of all your /dev/sdb
isn't partitioned. I am assuming this is the disk you want to mount.
WARNING: THIS WILL DESTROY ANY DATA ON YOUR TARGET DISK
Run sudo fdisk /dev/sdb
Press O and press Enter (creates a new table)
Press N and press Enter (creates a new partition)
Press P and press Enter (makes a primary partition)
Then press 1 and press Enter (creates it as the 1st partition)
Finally, press W (this will write any changes to disk)
Okay now you have a partition, now you need a filesystem.
Run
sudo mkfs.ext4 /dev/sdb1
Now you can add it to fstab
You need to add it to
/etc/fstab
use your favourite text editorBe careful with this file as it can quite easily cause your system not to boot.
Add a line for the drive, the format would look like this.
This assumes the partition is formatted as ext4 as per mkfs above
#device mountpoint fstype options dump fsck /dev/sdb1 /home/yourname/mydata ext4 defaults 0 1
Then on the next reboot it will auto mount.
This web page has a lot of useful info on fstab
The GUI solution for me is gnome-disks
sudo gnome-disks
Then with the configuration button you can "edit mount options", feel free to give the destination of your mount point and it will be saved into the /etc/fstab automatically
Note: the nofail
option that causes the system not to hang if this mount point is not available, could be useful in case of potential unreachable filesystem on boot such as USB, NFS, etc.
To set the drive to mount automatically each time you boot the computer
You’ll need to edit /etc/fstab:
Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command below.
gksudo gedit /etc/fstab
Add this line to the end:
/dev/sdaX /media/mydata ext4 defaults 0 0
Note: Make sure to replace the X with the right value for your situation.
Or you can use Storage Device Manager, from the software centre.