What's the command for mounting a partition?
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. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
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. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
What's the command for mounting a partition?
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.
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.
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: What's the command for mounting a partition?
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
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
Re: What's the command for mounting a partition?
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
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
Now you're ready. The next time you boot the disk is mounted
To mount now
This looks much more complicated than it is
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
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
To mount now
Code: Select all
sudo mount -t ext3 /dev/sdax /home/your_name/Data
Re: What's the command for mounting a partition?
excuse me, what was wrong with the advice in the post above?Husse wrote: Perhaps you did not get the right advice like in the post above
Re: What's the command for mounting a partition?
Is it necessary to edit /etc/mtab?
Re: What's the command for mounting a partition?
@ 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
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
Re: What's the command for mounting a partition?
Sorry -- blurry eyes, read thru your post too quickly, thought you were saying to edit both fstab and mtab.Husse wrote:@ MALsPa
You can't edit mtab - or rather any edit you make is ignored. This is an autogenerated file generated by mount
Re: What's the command for mounting a partition?
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.Husse wrote:@ meandean
Nothing really - it was just not complete, no one could fix it based on that
If he wanted a easy fix I would of suggested using one of the GUI tools that will set everything up for you.
Re: What's the command for mounting a partition?
meandean ?,
Just in case you would like to refine your "mean" skills, I give classes for a nominal fee.
@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
Just in case you would like to refine your "mean" skills, I give classes for a nominal fee.
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.If he wanted a easy fix I would of suggested using one of the GUI tools that will set everything up for you.
@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
Re: What's the command for mounting a partition?
Might not hurt to take a look at man mount, man umount, and man fstab.
Re: What's the command for mounting a partition?
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!
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!
Re: What's the command for mounting a partition?
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
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
Re: What's the command for mounting a partition?
The gui is ntfs-config. I use it to automount my ntfs data drivesHusse 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