Mount linux only root can do that

UNIX — mount: only root can do that

I need to allow a non-root user to mount/unmount a device. I am a total noob when it comes to UNIX, so please dumb it down for me. I’ve been looking all over teh interwebz to find an answer and it seems everyone is giving the same one, which is to modify /etc/fstab to include that device with the user option (or users , tried both). I did that and it still says mount: only root can do that . Here are the contents of my fstab:

# /etc/fstab: static file system information. # # Use 'vol_id --uuid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # proc /proc proc defaults 0 0 # / was on /dev/mapper/minicc-root during installation UUID=1a69f02a-a049-4411-8c57-ff4ebd8bb933 / ext3 relatime,errors=remount-ro 0 1 # /boot was on /dev/sda5 during installation UUID=038498fe-1267-44c4-8788-e1354d71faf5 /boot ext2 relatime 0 2 # swap was on /dev/mapper/minicc-swap_1 during installation UUID=0bb583aa-84a8-43ef-98c4-c6cb25d20715 none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0 /dev/scd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0 /dev/sdb1 /mnt/sdcard auto auto,user,rw,exec 0 0

My thumb drive partition shows up as /dev/sdb1 . I’m pretty sure my fstab is set up OK, but everyone on the other posts seems to fail to mention how they actually call the mount command once this entry is in the fstab file. I think this is where my problem may be. The command I use to mount the drive is:

/bin/mount is owned by root and is in the root group and has 4755 permissions.
/bin/umount is owned by root and is in the root group and has 4755 permissions.
/mnt/sdcard is owned by me and is in one of my groups and has 0755 permissions. My mount command works fine if I use sudo , but I need to be able to do this without sudo (need to be able to do it from a PHP script using shell_exec ). Any suggestions?

Источник

unixforum.org

Недавно поставил debian и сейчас осваиваюсь. (до этого только с вендой и работал)
Проблема моя вот в чем:
У меня два харда — один с вендой (два раздела SYSTEM и DATA) другой с Debian
Я не могу смонтировать хард с вендой под юзером.
mount -t vfat /dev/hdb1 /SYSTEM
пишет что то вроде:
mount: only root can do that

Помогите пожалуйста разрешить юзеру монтировать эти разделы.

Я слил шаги во мраке трассы
С тяжелым маршем русской расы,
До глаз закованной в броню,
И орден, преданный огню
Я увидал в глазах народа.

Читайте также:  Лучший консольный браузер linux

Re: Разрешить mount юзеру

Сообщение skeletor » 31.07.2008 15:23

причём выполнение комманды будет происходить без запроса пользовательского пароля. Если нужен запрос пароля при выполнении комманды, тогда просто убрать слово NOPASSWD

nesk Сообщения: 2268 Статус: Линукссаксовец ОС: MS Windows XP Home SP3 Контактная информация:

Re: Разрешить mount юзеру

Сообщение nesk » 31.07.2008 15:42

надо добавить стручку монтирования в /etc/fstab
типа
/dev/hdb1 /SYSTEM vfat user,noauto, iocatset iocharset=utf-8 0 1

как то так. Чему равно значения iocatset iocharset зависит от того, какая кодировка в linux
потом любой пользователь сможет сделать
mount /SYSTEM

а можно сделать что бы файловая система подключалась автоматически при загрузки
примерно как то так

/dev/hdb1 /SYSTEM vfat umask=0, iocatset iocharset=utf-8 0 1

то, что предложил skeletor уж больно радикально, и наверно в Вашем случае не нужно.

Внимание: У меня под рукой нет машины с Linux. Я не использую эту ОС. Ответы я даю либо по памяти, либо мне помогает гугл. Тщательно читайте маны по тем командам и конфигурационным файлам, которые я упоминаю.

Источник

Fix error — mount: only root can do that

I am trying to share folders between host OS and guest OS in VirtualBox as shown in this tutorial — http://helpdeskgeek.com/virtualization/virtualbox-share-folder-host-guest/ As instructed in the tut, I go into my linux (L-ubuntu) guest and type the command —

mount -t vboxsf [-o OPTIONS] sharedFolderName mountPoint 

When I do this, I get the error — mount: only root can do that. How do I become root and then execute the above command. I have a non-root solution here which I will try later — How do I mount a drive so that it is readable by me?

2 Answers 2

To run a command as root, use sudo command . (You may want to read this to learn more.)

Creating the Mount Point for the Share

If you mount the share at /media/sharename , that directory must first exist. To create it, run:

sudo mkdir /media/sharename 

You can mount shares anywhere; they do not have to be mounted in /media . However, these days it’s common for filesystems mounted as root, especially if they may be attached and detached, to have subfolders of /media as their mount points.

The more traditional place to put mount points is /mnt . Either way—or elsewhere—will work.

Letting a Normal User Access and Change the Contents of the Share

If the host OS doesn’t use a Unix-style filesystem—for example, if you have a Windows host running an Ubuntu guest—then you might want to specify what user you intend to give full access to the files in the share. Otherwise modifying the files (and possibly accessing them at all) will require you to act as root. You probably don’t want that; you probably want to mount the share as root, but be able to access its contents as a non-rot user.

To do that, include uid=1000 in the , -separated list of options issued after -o :

  • If that’s the only option you’re specifying, no comma is required. Otherwise, all options should be separated with commas, and no spaces.
  • Replace 1000 with your actual user ID. If you’re the first user created on your Ubuntu system (the user created during installation), typically your user ID is 1000. To find out your user ID, run the command id -u in the Ubuntu system.
Читайте также:  Bco system cryptographic plugin linux

Источник

Only root can mount /dev/sdb1 on /media/sdb1 — contribute to external usb drive

I can’t understand why, when I tried plug-in external USB driver in Ubuntu 12.04, I see next message:

Error mounting: mount exited with exit code 1: helper failed with: mount: only root can mount /dev/sdb1 on /media/sdb1 
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # #      proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda1 during installation UUID=5f5d330f-d5f2-4157-9496-94f1dce2f181 / ext4 errors=remount-ro 0 1 # swap was on /dev/sda5 during installation UUID=84747ef4-6f50-49bc-9df1-fcba364ba299 none swap sw 0 0 /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0 /dev/sdc1 /media/sdc1 vfat uid=1000,noauto 0 0 /dev/sdd1 /media/sdd1 vfat uid=1000,noauto 0 0 /dev/sdb1 /media/sdb1 vfat uid=1000,noauto 0 0 
Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000e28b8 Device Boot Start End Blocks Id System /dev/sda1 * 2048 310484991 155241472 83 Linux /dev/sda2 310487038 312580095 1046529 5 Extended /dev/sda5 310487040 312580095 1046528 82 Linux swap / Solaris Disk /dev/sdb: 993 MB, 993001472 bytes 2 heads, 1 sectors/track, 969728 cylinders, total 1939456 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdb1 133 1939455 969661+ 6 FAT16 Disk /dev/sdc: 4009 MB, 4009754624 bytes 16 heads, 32 sectors/track, 15296 cylinders, total 7831552 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xd8e1f237 Device Boot Start End Blocks Id System /dev/sdc1 * 32 7831551 3915760 b W95 FAT32 

sdc and sdb — there are external usb drivers. Can I solve this trouble and mount all external usb drives automatically?

Источник

What regulates user privileges for the `mount` command?

I didn’t notice anything had changed. Reading the man page for mount, I added a new line to fstab :

/dev/sr0 /media/dvd iso9600 ro,users,noauto,unhide 

Then, I added my non-root user ( chris ) to group users ; however, mount continues to be accessible only to root:

$ mount -a mount: only root can do that $ mount /dev/sr0 /media/dvd mount: only root can do that $ mount /dev/sr0 /media/dvd mount: only root can do that 

The only command which is working right now is:

$ sudo mount /dev/sr0 /media/dvd 

What are all the working pieces to granting users permission to mount dvds? BONUS, Why would KDE suddenly stop mounting DVDs?

3 Answers 3

$ mount -a mount: only root can do that 

This command tries to mount all entries in /etc/fstab , and since not all of them have the user / users option, that will not be possible for a user that has no admin privileges.

$ mount /dev/sr0 /media/dvd mount: only root can do that 

This specifies both the device to be mounted and the mountpoint, effectively not requiring /etc/fstab at all (as the filesystem-specific default mount options will be assumed if you don’t specify them on the command line, and filesystem type autodetection will be performed if you don’t specify the filesystem type). This is powerful enough to trivially open all kinds of security holes, and so non-root users are not authorized to use this form of the mount command at all.

When using mount as a non-root user to mount an admin-prepared /etc/fstab entry that has the user / users mount option, you must specify either only the device or only the mountpoint. This will make the mount command look up the missing parts of the full command line in /etc/fstab , and so the command will see that a non-root user has been authorized to perform that specific mount.

So either of these mount commands and only these would allow the non-root user to mount the CD/DVD, given the /etc/fstab line specified in the OP:

When used by a non-root user, the mount command will also check that the user will be able to access both the device and the mountpoint, and will reject the command if this is not true. Often the login session set-up (usually in the form of PAM modules) grants the user access to removable devices when the user is logging in locally. This can be done either by granting a locally-logged-in user some extra group memberships (that fit in with the device permissions configured by udev rules), or on modern Linux distributions, by having the devices tagged in udev with a TAG+=»uaccess» , which will trigger the session setup to add an ACL to those devices on a local login, and to remove it on logout.

If a non-root user needs to be authorized to mount removable devices over a SSH session or other remote login, many distributions provide pre-configured user groups for the purpose (e.g. the cdrom or plugdev groups).

GUI environments usually have their own mechanisms for allowing users to mount removable media, with their own restrictions. At the time of this writing, udisksd is a commonly-used system-level component for this. It communicates over the system D-Bus with the udisksctl command-line tool or any number of GUI file managers and removable media access tools.

Источник

Оцените статью
Adblock
detector