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

  1. Press O and press Enter (creates a new table)

  2. Press N and press Enter (creates a new partition)

  3. Press P and press Enter (makes a primary partition)

  4. Then press 1 and press Enter (creates it as the 1st partition)

  5. Finally, press W (this will write any changes to disk)


Okay now you have a partition, now you need a filesystem.

  1. Run sudo mkfs.ext4 /dev/sdb1

  2. Now you can add it to fstab

    You need to add it to /etc/fstab use your favourite text editor

    Be 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

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 enter image description here

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.

Tags:

Fstab