Mount a new hard drive as a folder under home [solved]

Forum rules
Before you post please read this
Post Reply
WildPhydeaux
Level 1
Level 1
Posts: 8
Joined: Mon Mar 27, 2017 5:59 pm

Mount a new hard drive as a folder under home [solved]

Post by WildPhydeaux » Wed Jul 03, 2019 7:02 pm

I've spent a fair amount of time searching for answers but can't seem to find what I'm looking for. Hoping someone here can assist.

LM 19.1 Cinnamon

I added a second hard drive and have partitioned and formatted it. I can see it in Nemo and connect to it fine. Mounts under /Media as you would expect, but that's not what I want.

The reason for the new drive is to store my Virtualbox VMs on a separate drive instead of under /home/robert/VMs like they are now (/home and all system file are all on the same physical drive).

Can I have the /home/robert/VMs just refer to the new drive? In other words mount the drive there (moving the actual VMs to the drive first)? And NOT have the drive separately visible in Nemo? I assume Virtualbox wouldn't know or care...

Cheers,
Robert
Last edited by WildPhydeaux on Fri Jul 05, 2019 9:53 am, edited 1 time in total.

User avatar
kyphi
Level 9
Level 9
Posts: 2624
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Mount a new hard drive as a folder under home

Post by kyphi » Wed Jul 03, 2019 11:38 pm

I have several drives and one of these is divided to house (1) all Home backups and (2) Timeshift backups. These appear in my file system hierarchy.
If you use an external drive then you have to mount the drive every time you want to use it, whereas by having these partitions always mounted, they can be accessed instantly. For example, an executable icon on the panel will activate the backup program (grsync) and Timeshift is set to automatically run when scheduled. They do not appear in the Home folder in Nemo but are revealed under File System. If that is what you want to do then please advise.

My VirtualBox VMs are stored in a folder in my home directory but are duplicated in my home backup. VirtualBox does not appear to mind this arrangement :D
Linux Mint 19.2 Cinnamon - 64bit

User avatar
AndyMH
Level 9
Level 9
Posts: 2501
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Mount a new hard drive as a folder under home

Post by AndyMH » Thu Jul 04, 2019 5:03 am

Can I have the /home/robert/VMs just refer to the new drive?
Yes you can, you have to edit your fstab file and add a line similar to

Code: Select all

UUID=95cc8b9f-d95d-4bbb-918e-56f36856b1b6	/home/robert/VMs      ext4	defaults               0	2
Replace the UUID in the example above with the UUID for your partition. You get the UUID by typing blkid in a terminal.
Before you do this you will need to copy the contents of /home/robert/VMs somewhere else, e.g. rename the folder to /home/robert/VMs-old and then copy them back when finished. When you have made the changes to fstab you will need to reboot.

It is also good practice to make a copy of fstab before you change it - if you screw up, potentially the system will not boot. fstab lives in /etc and has to be edited as root.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate

WildPhydeaux
Level 1
Level 1
Posts: 8
Joined: Mon Mar 27, 2017 5:59 pm

Re: Mount a new hard drive as a folder under home

Post by WildPhydeaux » Thu Jul 04, 2019 6:41 pm

Thank you both for quality replies. I've decided that it would be no great effort for me to reinstall LM and choose to simply have my home directory located on the second drive. This is likely a best practice anyway for future OS version upgrades.

However I'm still interested in the original question and I played around a bit with it using the Disks utility that came with LM. Not entirely successfully however. A mount point was created under /home/robert/VMs but:
1) I had no access to it (may have had read, but was empty and definitely did not have write).
2) I could still see the drive (the Label anyway) listed in Nemo on the left along with USB thumb drives etc. I did choose the option in Disks to "Hide in file system" (or similar name, I'm not near the PC right now). I really don't want to see it there or necessarily at all. Seems it's being treated like removable device...

So when I undid the above, now I can no longer access the disk (read/write) when I click on it in Nemo like I could before. Weird.

On my previous LM 18 system I had a hot swap bay for a SATA drive that I would pop a drive into once in a while and back up some stuff to. I don't recall having to do anything special to access that drive, just click to mount in Nemo and run my little backup app. Granted, that is not what I was asking for in my original question, it's just odd I could do that and now I can't. Could the format of the drive make a difference? This current drive is ext4 and I believe the before I was using an NTFS drive. This one is an SSD mounted internally and the other was a spinner in the hot swap Bay (but the OS doesn't care about location or storage type does it?).

Anyway, I digress. As I say I would like to understand better.

Cheers,
Robert

User avatar
kyphi
Level 9
Level 9
Posts: 2624
Joined: Sat Jul 09, 2011 1:14 am
Location: The Hunter Valley, Australia

Re: Mount a new hard drive as a folder under home

Post by kyphi » Fri Jul 05, 2019 12:30 am

External storage media, when plugged in, mount automatically in a default system. To have an internal drive mounted at all times you have to type the blkid of that drive into fstab as outlined by AndyMH.
There are a few further steps to take, so here is the complete sequence:
Assuming that your new drive has been formatted (e.g. ext4), first make a new directory with the command sudo mkdir /VM
Then (using AndyMH's example UUID as a representative guide only) enter the your new drive's UUID into /etc/fstab so that it reads like this:
UUID=95cc8b9f-d95d-4bbb-918e-56f36856b1b6 /VM ext4 defaults 0 0
Note that there is a space before /VM.
Don't forget to save your edited fstab file.
Then sudo mount -a
Then sudo chown -R robert:robert /VM
Then sudo chmod -R 755 /VM

The above commands specify you as the owner and set access permissions.
You now have a permanently mounted and accessible directory in your file system called VM.
Linux Mint 19.2 Cinnamon - 64bit

User avatar
AndyMH
Level 9
Level 9
Posts: 2501
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Mount a new hard drive as a folder under home

Post by AndyMH » Fri Jul 05, 2019 2:47 am

On my previous LM 18 system I had a hot swap bay for a SATA drive that I would pop a drive into once in a while and back up some stuff to.
You can mount removable media in fstab, but it is useful to add the options nofail - so you are not presented with a 90sec delay on boot while linux searches for a drive that isn't there, and noauto so it doesn't automatically mount.

I'm not a fan of the disks utility and don't use it. Whatever you want to do in disks you can generally do in gparted.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate

WildPhydeaux
Level 1
Level 1
Posts: 8
Joined: Mon Mar 27, 2017 5:59 pm

Re: Mount a new hard drive as a folder under home

Post by WildPhydeaux » Fri Jul 05, 2019 9:52 am

Thank you both very much, this has been really helpful for me and I appreciate you taking the time to respond and educate me.

Cheers,
Robert

User avatar
JerryF
Level 11
Level 11
Posts: 3831
Joined: Mon Jun 08, 2015 1:23 pm
Location: Rhode Island, USA

Re: Mount a new hard drive as a folder under home [solved]

Post by JerryF » Fri Jul 05, 2019 10:26 am

Is creating a link at /home/robert/VMs pointing to a folder on the other disk possible?

EDIT:
The above is possible.
  • I renamed the default folder that Oracle's VirtualBox uses VirtualBox VMs to VirtualBox VMs ORIGINAL
  • I created a folder on my mounted second drive named VMs
  • Then created a link to that folder by right-clicking on the folder VMs and selecting Create a Link
  • Renamed that link to VirtualBox VMs
  • Moved the link to my /home/jerry
Now, anytime I create a VM, it gets created on the second drive.
IF your problem has been solved, please edit your original post and add [SOLVED] to the beginning of the Subject Line. It helps other members when browsing posts.

WildPhydeaux
Level 1
Level 1
Posts: 8
Joined: Mon Mar 27, 2017 5:59 pm

Re: Mount a new hard drive as a folder under home [solved]

Post by WildPhydeaux » Sat Jul 06, 2019 11:23 am

Thanks Jerry, that's a good alternative option also. Appreciate you bringing this to my attention.

Cheers,
Robert

Post Reply

Return to “Mounting Partitions”