1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Unmounting/Mounting without being root

Discussion in 'Linux and Unix' started by Omega_Shadow, Jan 22, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. Omega_Shadow

    Omega_Shadow Thread Starter

    Joined:
    Aug 2, 2004
    Messages:
    4,319
    I found out today that I can hotswap my removable drives in linux by Unmounting, removing drive A, putting in drive B and Mounting it. But it requires me to be logged in as root.

    Is there any way to give myself this permission?
     
  2. jiml8

    jiml8 Guest

    Joined:
    Jul 2, 2005
    Messages:
    2,634
    You put the keyword "user" into the mount statement in fstab.

    For instance, if you mount hda1 like this:

    /dev/hda1 /mnt/hda1 ext3 defaults 1 2

    change it to this:

    /dev/hda1 /mnt/hda1 ext3 user defaults 1 2
     
  3. Omega_Shadow

    Omega_Shadow Thread Starter

    Joined:
    Aug 2, 2004
    Messages:
    4,319
    <Edited- I answered my own questions :p :D >

    Alright, Got into Fstab but I must have edited it wrong becuase on restart I could not mount the drive. Here is the unedited fstab, tell me what you think:
    Code:
    /dev/hda6 / ext3 noatime 1 1
    /dev/hda8 /home ext3 noatime 1 2
    /dev/hdc /mnt/cdrom auto umask=0,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec,users 0 0
    /dev/hdd /mnt/cdrom2 auto umask=0,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec,users 0 0
    /dev/hda1 /mnt/win_c ntfs umask=0,nls=iso8859-1,ro 0 0
    /dev/hdb1 /mnt/win_c2 vfat umask=0,iocharset=iso8859-1,codepage=850 0 0
    /dev/hda5 /mnt/win_d ntfs umask=0,nls=iso8859-1,ro 0 0
    none /proc proc defaults 0 0
    /dev/hda7 swap swap defaults 0 0
     
  4. jiml8

    jiml8 Guest

    Joined:
    Jul 2, 2005
    Messages:
    2,634
    fstab is in /etc. You have to be root and you can edit it with a text editor.
     
  5. Omega_Shadow

    Omega_Shadow Thread Starter

    Joined:
    Aug 2, 2004
    Messages:
    4,319
    We ended up jumping eachother because of my edit. :eek: Please see my above post
     
  6. jiml8

    jiml8 Guest

    Joined:
    Jul 2, 2005
    Messages:
    2,634
    Which drive do you want to swap? hda? That'll be a problem because you'll have to chroot first, and you need someplace to chroot to. You also would have to unmount every partition before pulling the drive.

    hdb? That one would be easy enough; just put the word user into the line.

    And what is this "restart" business? You shouldn't have to restart for any of this.
     
  7. Omega_Shadow

    Omega_Shadow Thread Starter

    Joined:
    Aug 2, 2004
    Messages:
    4,319
    The restart business comes from me being a windows user for so long. I will try and remember I dont have to restart after every little change.;)

    I think hdb. I tryed putting user in the line and that didnt work. Will try agian....
     
  8. jiml8

    jiml8 Guest

    Joined:
    Jul 2, 2005
    Messages:
    2,634
    /dev/hdb1 /mnt/win_c2 vfat user,umask=0,iocharset=iso8859-1,codepage=850 0 0
     
  9. Omega_Shadow

    Omega_Shadow Thread Starter

    Joined:
    Aug 2, 2004
    Messages:
    4,319
    I used that code but got this when trying to mount the drive:
     

    Attached Files:

  10. jiml8

    jiml8 Guest

    Joined:
    Jul 2, 2005
    Messages:
    2,634
    Is this a drive that would mount when you didn't have user set?

    Why are you getting this message in a requester? How are you mounting?

    Open a shell and type in mount /dev/hdb1 and see what it says. May say the same thing.

    also, copy/paste your fstab here, with the /dev/hdb1 line showing the user entry.
     
  11. Omega_Shadow

    Omega_Shadow Thread Starter

    Joined:
    Aug 2, 2004
    Messages:
    4,319
    Yes
    Right clicking on the drive and selecting "mount"
    It does.
    Here it is:
    # This file is edited by fstab-sync - see 'man fstab-sync' for details
    /dev/hda6 / ext3 noatime 1 1
    /dev/hda8 /home ext3 noatime 1 2
    /dev/hdc /mnt/cdrom auto umask=0,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec,users 0 0
    /dev/hdd /mnt/cdrom2 auto umask=0,user,iocharset=iso8859-1,codepage=850,noauto,ro,exec,users 0 0
    /dev/hda1 /mnt/win_c ntfs umask=0,nls=iso8859-1,ro 0 0
    /dev/hdb1 /mnt/win_c2 vfat user,umask=0,iocharset=iso8859-1,codepage=850 0 0
    /dev/hda5 /mnt/win_d ntfs umask=0,nls=iso8859-1,ro 0 0
    none /proc proc defaults 0 0
    /dev/hda7 swap swap defaults 0 0
     
  12. jiml8

    jiml8 Guest

    Joined:
    Jul 2, 2005
    Messages:
    2,634
    Alright. man mount is your friend.

    user allows an ordinary user to mount or unmount a drive. The name of the user who mounted is written to mtab so that user can unmount. May be some issue here due to a previous mount with other options, dunno.

    users allows all users to mount or unmount a drive.

    In my system, I have the capability to mount and unmount a drive by setting both user and users. so try this:

    /dev/hdb1 /mnt/win_c2 vfat user,umask=0,iocharset=iso8859-1,codepage=850,noauto,exec,users 0 0

    This exact syntax works fine on my system.
     
  13. Omega_Shadow

    Omega_Shadow Thread Starter

    Joined:
    Aug 2, 2004
    Messages:
    4,319
    Alright, one moment, making the change...

    BTW, For those of you reading though here because you have a similar problem:
    I just figured this out. You don't have to log out and then log in as root to change the /etc/fstab file. Open your konsole, type in "su", your root password, then "kwrite /etc/fstab" This will open fstab as root!
     
  14. Omega_Shadow

    Omega_Shadow Thread Starter

    Joined:
    Aug 2, 2004
    Messages:
    4,319
    Same error. Mind you if I return the code back to the way it was and then log out, log in as root, I can mount it no problem.

    I remember reading somewhere after I googled for an answer about some sort of "mount -r" security issue and there was an update to keep non root's from mounting drives. I didn't think it applied to me at the at the time. Will try to dig up that article.
     
  15. Omega_Shadow

    Omega_Shadow Thread Starter

    Joined:
    Aug 2, 2004
    Messages:
    4,319
    Cant find it anywhere now. Got any other ideas?
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/436339

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice