Mount a USB drive automatically under Home.

Questions about hardware, drivers and peripherals
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
eddiecurrent

Mount a USB drive automatically under Home.

Post by eddiecurrent »

I have a 1 TB usb hard drive for my tablet PC. It mounted well the first time, and there's no issues putting stuff on/ reading it.

It's mounted itself by default to /media/New Volume. I'd like it to mount as ~/New Volume (or some other name under my home) when I hook it up.

What's the best way to do this?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
altair4
Level 20
Level 20
Posts: 11458
Joined: Tue Feb 03, 2009 10:27 am

Re: Mount a USB drive automatically under Home.

Post by altair4 »

Assuming your username is eddie I would do it this way:

(1) Create a mount point in your home directory called NewVolume:

Open Terminal
Type mkdir /home/eddie/NewVolume

Note: I have purposely removed the space between "New" and "Volume" in the mount point. Linux hates spaces. It will accommodate spaces as you will see below but it's awkward and something to be avoided if possible.

(2) Add a line in fstab which will automatically mount the partition of the external HD to the mount point whenever it's plugged in:

Open Terminal
Type sudo su
Type

Code: Select all

echo "LABEL=New\040Volume /home/eddie/NewVolume ntfs user,umask=007,utf8,flush,noauto 0 0" >> /etc/fstab
Notes:
(1) The "\040" in the "LABEL=" of the last command is the way linux handles spaces in this type of situation.
Note: That's a zero - 4 - zero
(2) I assumed that the partition on the external hard drive is formatted in NTFS.
If it's formatted in FAT32 the command would be:

Code: Select all

echo "LABEL=New\040Volume /home/eddie/NewVolume vfat user,umask=007,utf8,flush,noauto 0 0" >> /etc/fstab
If it's formatted in ext3 the command would be:

Code: Select all

echo "LABEL=New\040Volume /home/eddie/NewVolume ext3 defaults,user,noatime,noauto 0 0" >> /etc/fstab
(3) "noauto" in the last command will enable fstab to mount the partition when the drive is plugged in verses on boot.
(4) "user" in the last command will allow you to mount and unmount the device without being root.

If I haven't made a typo that should work :wink:

If it doesn't work, post the output of the following command:
Open Terminal
Type sudo blkid
Note: that "l" is a lower case "L"
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
viking777

Re: Mount a USB drive automatically under Home.

Post by viking777 »

echo "LABEL=New\040Volume /home/eddie/NewVolume ext3 defaults,user,noatime,noauto 0 0" >> /etc/fstab
That looks pretty good to me altair barring one thing. I would lose the 'defaults' mount option because it implies 'auto' and 'nouser' , which you contradict later on so I am not sure what would happen in that case.
altair4
Level 20
Level 20
Posts: 11458
Joined: Tue Feb 03, 2009 10:27 am

Re: Mount a USB drive automatically under Home.

Post by altair4 »

viking777 wrote:
That looks pretty good to me altair barring one thing. I would lose the 'defaults' mount option because it implies 'auto' and 'nouser' , which you contradict later on so I am not sure what would happen in that case.
I'm fairly certain ( although not 100% ) that any explicit option stated in fstab will override what's in the default. Besides, that fstab entry matches my own ( different label and mount points of course ) for my own external USB thumb drive. :wink:
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
viking777

Re: Mount a USB drive automatically under Home.

Post by viking777 »

altair4 wrote:
viking777 wrote:
That looks pretty good to me altair barring one thing. I would lose the 'defaults' mount option because it implies 'auto' and 'nouser' , which you contradict later on so I am not sure what would happen in that case.
I'm fairly certain ( although not 100% ) that any explicit option stated in fstab will override what's in the default. Besides, that fstab entry matches my own ( different label and mount points of course ) for my own external USB thumb drive. :wink:
Well I am 'certainly' not certain, so you could well be right. It might make things a little easier if it is true, so for example if you wanted the 'user' option but everything else default you could write 'default, user' instead of writing each option individually - I hope you are right.
olivertreend

Re: Mount a USB drive automatically under Home.

Post by olivertreend »

viking777 wrote:
altair4 wrote:
viking777 wrote: I'm fairly certain ( although not 100% ) that any explicit option stated in fstab will override what's in the default. Besides, that fstab entry matches my own ( different label and mount points of course ) for my own external USB thumb drive. :wink:
Well I am 'certainly' not certain, so you could well be right. It might make things a little easier if it is true, so for example if you wanted the 'user' option but everything else default you could write 'default, user' instead of writing each option individually - I hope you are right.
Just to say, I too am 100% certain that altair4 is correct in saying that options stated after 'defaults' overwrites what is set in the defaults. Fstab definitely does this.

Oliver
Locked

Return to “Hardware Support”