14

(Just upgraded to 16.04; still getting things working...)

Right now, I have two hard drives.

I have the 2nd internal hard drive mount location symbolically linked, and I don't really want to change anything at this point.

The only problem is, it does not mount until I click on the hard drive icon in the unity launcher. Only after I click it do the symbolic links start working.

How do I make it automatically do whatever it is going to do when I click it...on start up?

4
  • Why don't you just add an entry to the /etc/fstab file? May 9, 2016 at 21:22
  • More info on fstab. help.ubuntu.com/community/Fstab But if you change mount from default /media/$USER you may have to update links. What format is partition? NTFS or ext4. You may be able to use Disks, gears icon, & edit mount options but its default settings are usually not optimal.
    – oldfred
    May 9, 2016 at 21:35
  • ext4...I just need it to be in a mount location and stay there. I saw the fstab stuff...but my config file does not look the way it should...there is no entry for the drive that I'm trying to add, for instance...but I will check it out, thanks (I think something screwed up might have happened, since I had cuda installed when I upgraded to 16, and after that failed, I formatted the second hard drive and installed 16 there).
    – Chris
    May 9, 2016 at 22:30
  • @CiroSantilli刘晓波死六四事件法轮功 alright but perhaps you can explain/translate the jargon (“partitions” and “mount”) and why it is a duplicate for everyone (by appending a statement to the original post) if you decide to mark it a duplicate... because otherwise it is a meaningless step.
    – Chris
    Nov 22, 2017 at 12:32

1 Answer 1

28

If you want to mount the second hard drive automatically you will have to change things at this point :D. There should be no reason to have it symbolically linked anywhere for a second hard drive.

If it is mounted at /media/username/a bunch of numbers and you have that linked to a folder off the root called /SecondDrive ... you don't need to do that you can actually automatically mount it on the root called /SecondDrive. It isn't that difficult I will run you through the steps and if you want.. after you see the answer you can reply with where you want it mounted, the information you gathered from following the steps and I will tell you the exact line that has to be added to your /etc/fstab

First terminal and type sudo blkid this will spit out a bunch of lines which may be wrapped and hard to read .. i suggest opening the terminal full screen or making it quite wide so you can get all the lines without wrapping. You will have an output that looks something like this

dev/sda1: LABEL="boot" UUID="e8b77b10-fd99-4c90-845d-310e8afc25df" TYPE="ext2" PARTUUID="00098acd-01"
/dev/sda5: UUID="c5653896-3d1b-48b4-855a-e76e6d88711a" TYPE="swap" PARTUUID="00098acd-05"
/dev/sda6: LABEL="root" UUID="0ae6d08b-d9c5-4109-9100-9a18fb068b2e" TYPE="ext4" PARTUUID="00098acd-06"
/dev/sda7: LABEL="home" UUID="ddffd3ed-205b-447d-852d-4552619e35d3" TYPE="ext4" PARTUUID="00098acd-07"
/dev/sdb1: UUID="720824B65B01A6C4" TYPE="ntfs" PARTUUID="21039491-01"
/dev/sdc1: LABEL="storage" UUID="0AED64E911A2FB1E" TYPE="ntfs" PARTUUID="e071ab3f-01"

Look for the partition you want to automatically mount and take note of the UUID and TYPE of the partition.

For example if I wanted to mount /dev/sdc1 I would open gedit or something you are familiar with to type text .. and copy the UUID and TYPE UUID="0AED64E911A2FB1E" TYPE="ntfs" then paste it into the editor so I can easily copy it when I need it

Now say I want it mounted right off / and I want to call it storage

I would first have to make an empty folder located at /storage if one didn't already exist .. if one does exist it needs to be an empty folder.

sudo mkdir /storage

We now have everything we need

Now we need to open /etc/fstab. This has to be done as root and I myself like to use gedit over a terminal to edit this so next in terminal type

sudo gedit /etc/fstab

This will contain all the partitions that mount at boot. You would need to add a line after all the others

The prefered format of the fstab that you have to worry about is UUID, mount point and type

So at the end of the file after everything else we would add the UUID a space then the mount point a space then the type .. .there is more but you don't have to concern yourself about it just remember to add the stuff I printed out after the type in my example full fstab line :D With the information we got from block id (blkid) and where we decided to make our mount point the line would look like this

UUID=0AED64E911A2FB1E /storage ntfs defaults 0 2

note that there is no quotes like blkid printed out so make sure if you paste in the UUID and type from the information we pasted into the editor for later use, that you remember to remove the quotes.

save the file and .. make sure the partition/drive isn't already mounted previously .. then type

sudo mount -a

you should not get any errors and you should see the drive/partition mounted at /storage (if you already had files on it you would see them now and the drive would be mounted) ... at this point every reboot the drive/partition would be mounted at /storage

Do not use this method to automatically mount a USB partition because if it is not plugged in during boot it can majorly slow the boot process or even cause the system to stop responding. This method should only be used for permanently installed hardware

2
  • Thanks for the answer, you got my +1! A bit off topic, but in fstab what are the <dump> and <pass> fields you left as 0 and 2 respectively? Jan 8, 2017 at 15:00
  • 1
    the <dump> enables backing up of the partition.. 0 disables it. and the <pass> controls fsck checks at boot .. the root should always be 1 and the other partitions are 2 or disabled using 0
    – John Orion
    Jan 9, 2017 at 15:16

Not the answer you're looking for? Browse other questions tagged .