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?
Mount a USB drive automatically under Home.
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Mount a USB drive automatically under Home.
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.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Mount a USB drive automatically under Home.
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
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:
If it's formatted in ext3 the command would be:
(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
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"
(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
(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
Code: Select all
echo "LABEL=New\040Volume /home/eddie/NewVolume ext3 defaults,user,noatime,noauto 0 0" >> /etc/fstab
(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
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.
Re: Mount a USB drive automatically under Home.
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.echo "LABEL=New\040Volume /home/eddie/NewVolume ext3 defaults,user,noatime,noauto 0 0" >> /etc/fstab
Re: Mount a USB drive automatically under Home.
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.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.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
Re: Mount a USB drive automatically under Home.
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.altair4 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.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.
Re: Mount a USB drive automatically under Home.
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.viking777 wrote:altair4 wrote: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.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.
Oliver