What's the command for mounting a partition?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help

What's the command for mounting a partition?

Postby Imagus on Fri Nov 07, 2008 11:34 am

Hello,

One of my data partitions (on an external hard drive) does not automatically mount when I start Mint. That's no big problem, because all I have to do to mount it is open a filemanager and click on its name ("DATA2-D2"). I would now like to write a small batch file (just like in DOS, with which I'm familiar) that contains a command to mount the partition and then make this file run at startup. Is this possible? If so, what is the command to mount a partition? I know practically nothing about "DOS" commands in Linux, so I'd appreciate any help. I have tried a simple "mount DATA2-D2" but that didn't work.

Btw, I have posted this problem here before, and some people kindly gave me the advice to change my fstab-file. Unfortunately that didn't work, so that's why I would like to try it with a simple batch file now.

Thanks in advance.
User avatar
Imagus
Level 3
Level 3
 
Posts: 120
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Linux Mint is funded by ads and donations.
 

Re: What's the command for mounting a partition?

Postby meandean on Fri Nov 07, 2008 12:31 pm

I think you are going about it bass-ackwards but anyway...

in general you mount something somewhere in your filesystem
more specifically
mount partition folder
for example
mount /dev/sda1 /mnt
then I could open my file manager and browse to /mnt to access my partition
meandean
Level 2
Level 2
 
Posts: 50
Joined: Thu Nov 06, 2008 8:38 am

Re: What's the command for mounting a partition?

Postby Husse on Fri Nov 07, 2008 2:05 pm

Change the fstab is what you should do
Perhaps you did not get the right advice like in the post above
Mount the drive with a click as you are used to
Open /etc/mtab
Find the line for that disk - you can also leave mtab open and mount the disk - the line added is your disk
It should look something like
/dev/sdax /media/disk ext3 rw,nosuid,nodev,uhelper=hal 0 0
The important part is /dev/sdax, where of course x is a number (all the way down in this post)
Then you must decide where you want the disk mounted - if it contains data home may be the place
So now we build our line and now I use some other options
/dev/sdax /home/your_name/Data ext3 rw,relatime 0 0
You could use /media/sdax instead Then you must make the same change in the fstab line
Edit fstab
Code: Select all
gksu gedit /etc/fstab

Add the line
Now you need a folder to mount it in (before it used a special folder)
If in home you just make the folder /home/your_name/Data - no problems and no sudo
If you go for the /media option then
Code: Select all
sudo mkdir /media/sdax

Now you're ready. The next time you boot the disk is mounted
To mount now
Code: Select all
sudo mount -t ext3 /dev/sdax  /home/your_name/Data

This looks much more complicated than it is :)
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: What's the command for mounting a partition?

Postby meandean on Fri Nov 07, 2008 3:34 pm

Husse wrote:Perhaps you did not get the right advice like in the post above

excuse me, what was wrong with the advice in the post above?
meandean
Level 2
Level 2
 
Posts: 50
Joined: Thu Nov 06, 2008 8:38 am

Re: What's the command for mounting a partition?

Postby MALsPa on Fri Nov 07, 2008 4:36 pm

Is it necessary to edit /etc/mtab?
User avatar
MALsPa
Level 8
Level 8
 
Posts: 2030
Joined: Mon Nov 19, 2007 10:17 pm
Location: albuquerque

Re: What's the command for mounting a partition?

Postby Husse on Fri Nov 07, 2008 4:56 pm

@ meandean
Nothing really - it was just not complete, no one could fix it based on that
@ MALsPa
You can't edit mtab - or rather any edit you make is ignored. This is an autogenerated file generated by mount
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: What's the command for mounting a partition?

Postby MALsPa on Fri Nov 07, 2008 5:01 pm

Husse wrote:@ MALsPa
You can't edit mtab - or rather any edit you make is ignored. This is an autogenerated file generated by mount


Sorry -- blurry eyes, read thru your post too quickly, thought you were saying to edit both fstab and mtab. :oops:
User avatar
MALsPa
Level 8
Level 8
 
Posts: 2030
Joined: Mon Nov 19, 2007 10:17 pm
Location: albuquerque

Re: What's the command for mounting a partition?

Postby meandean on Fri Nov 07, 2008 6:21 pm

Husse wrote:@ meandean
Nothing really - it was just not complete, no one could fix it based on that

He certainly could of used what I stated as a way to figure things out for himself. He didn't ask someone to do it for him. If you actually notice, he didn't ask for a specific fix.

If he wanted a easy fix I would of suggested using one of the GUI tools that will set everything up for you.
meandean
Level 2
Level 2
 
Posts: 50
Joined: Thu Nov 06, 2008 8:38 am

Re: What's the command for mounting a partition?

Postby Fred on Sat Nov 08, 2008 8:24 am

meandean ?,

Just in case you would like to refine your "mean" skills, I give classes for a nominal fee. :-)

If he wanted a easy fix I would of suggested using one of the GUI tools that will set everything up for you.

I have found the GUIs for this process to be somewhat unreliable, especially for usb and other external devices. My best advice would be to learn to do it manually. Once you understand what you are trying to accomplish and have done it a few times it becomes a simple, straight forward task.


@Imagus,

I think what Husse is saying is that the proper way to mount this partition on boot is through /etc/fstab. If you haven't been successful with that method it is because you have either gotten bad advice or haven't fully understood how to go about it.

There are two parts to auto-mounting a partition. One part is selecting at least one mount point. A mount point is nothing more than a folder located somewhere in the file system. As an example: You could create a folder in /media called usbDrive. And/or a folder in /home/fred/ called Data. It is up to you what you name the folders. To do this, open a terminal and type:

sudo mkdir /media/usbDrive

and/or

mkdir /home/fred/Data

The second part is to put a mounting line in /etc/fstab. If you look in /etc/mtab, with the drive mounted, you will be able to get an idea of what the line in fstab should look like. Just make sure the mount point is set as you made the folder for it above. If you are mounting in two places you will have two entries for that partition with only the mount points being different.

This is a repetition of what Husse said in his post, just said in a different way. Maybe between the two posts it will make more sense to you and you can be successful this time.

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: What's the command for mounting a partition?

Postby MALsPa on Sat Nov 08, 2008 1:13 pm

Might not hurt to take a look at man mount, man umount, and man fstab.
User avatar
MALsPa
Level 8
Level 8
 
Posts: 2030
Joined: Mon Nov 19, 2007 10:17 pm
Location: albuquerque

Re: What's the command for mounting a partition?

Postby Imagus on Sat Nov 08, 2008 5:41 pm

Thank you all very much for your replies, it finally works now!

First I located the line "DATA2" in mtab, which looked like this:
/dev/sdb5 /media/DATA2-D2 fuseblk rw,nosuid,nodev,noatime,allow_other,blksize=4096 0 0

I have no idea what most of this means, but I tried to make it look like the example line from Husse and so I changed it in:
/dev/sdb5 /media/DATA2-D2 ntfs rw,relatime 0 0

I then created a directory /media/DATA2-D2 and pasted the new line in fstab.
It works great now.

Thanks again, I'm very glad this little annoyance is finally solved!
User avatar
Imagus
Level 3
Level 3
 
Posts: 120
Joined: Tue Aug 28, 2007 2:33 pm
Location: Belgium

Re: What's the command for mounting a partition?

Postby Husse on Sat Nov 08, 2008 6:38 pm

Hehe
I did not want to use DATA2-D2 because I could not remember if - was allowed in folder names
For ntfs there is a nice gui tool you can use - can't remember the name of it (either) but I think that once you've understood it's quicker this way
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: What's the command for mounting a partition?

Postby NWAdawg on Sat Nov 08, 2008 7:05 pm

Husse wrote:Hehe

For ntfs there is a nice gui tool you can use - can't remember the name of it (either) but I think that once you've understood it's quicker this way

The gui is ntfs-config. I use it to automount my ntfs data drives
Ubuntu User #24005, Linux User #480025
User avatar
NWAdawg
Level 1
Level 1
 
Posts: 22
Joined: Sun Sep 21, 2008 8:48 am
Location: NW Arkansas

Linux Mint is funded by ads and donations.
 

Return to Newbie Questions

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 17 guests