Linux mount only root

Только root может подключаться /dev /sdb1 on /media /sdb1 — вносить вклад в внешний USB-накопитель

Я не могу понять, почему, когда я попробовал подключаемый внешний USB-драйвер в Ubuntu 12.04, я вижу следующее сообщение:

Вот содержание /etc/fstab :

И это мой текущий sudo fdisk -l :

sdc и sdb — там являются внешними драйверами USB.

Могу ли я решить эту проблему и автоматически смонтировать все внешние USB-накопители?

2 ответа

Вам нужно добавить опцию user к вашему fstab

Параметр user позволяет любому пользователю монтировать устройство, как сказано в man:

Обычно, только суперпользователь может монтировать файловые системы. Однако, когда fstab содержит параметр user в строке, любой может установить соответствующую систему.

Или, если вы хотите, чтобы какой-либо пользователь монтировал /размонтировал диски, используйте users вместо:

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

Примечание. опция user также подразумевает noexec , nosuid и nodev , поэтому, если вам нужны эти параметры, вам нужно будет добавить их аналоги. Например, если вам потребуется выполнить двоичные файлы с диска, вы должны добавить опцию exec , поэтому ваши варианты be uid=1000,noauto,user,exec , и то же самое касается двух других.

Дополнительная литература: Fstab — Документация Ubuntu

Если у вас есть запись для устройства в /etc /fstab, это не позволит автоматическому монтажу Ubuntu устанавливать это устройство при подключении.

Я только что проверил это на своей системе, которая автоматически устанавливала мой накопитель большого пальца при вставке:

Когда я добавил строку

в /etc /fstab и вставил накопитель большого пальца, произошел поток активности с помощью процесса gvfsd-udisks2-volume-monitor , который включал открытие и чтение /etc /fstab (как показано strace ). Флеш-диск не монтировался.

Когда я изменил /etc /fstab, добавив один символ, чтобы прокомментировать запись:

gvfsd-udisks2-volume-monitor снова занялся работой и установил флэш-накопитель. Мне не пришлось вынимать накопитель большого пальца и снова вставлять его, мне не нужно было посылать сигнал на gvfsd, поэтому демон сбоев, похоже, просматривает /etc /fstab для изменений.

Я не знаю, почему он ведет себя таким образом, но тест был прост и повторяем.

Источник

unixforum.org

Форум для пользователей UNIX-подобных систем

  • Темы без ответов
  • Активные темы
  • Поиск
  • Статус форума
Читайте также:  Статическая компиляция qt linux

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

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

Сообщение RobinHood » 31.07.2008 15:01

Доброго времени суток, Господа!

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

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

Спасибо за внимание.

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

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

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. Я не использую эту ОС. Ответы я даю либо по памяти, либо мне помогает гугл. Тщательно читайте маны по тем командам и конфигурационным файлам, которые я упоминаю.

Источник

External drive mounts only as root

I’m having trouble with a USB drive. It used to automount just fine but for some reason those good old days are over. Not only does it not automount but mounting it as a regular user from Nautilus or the terminal gets me a

You do not have the permissions necessary to view the contents of “Elements”.

I can totally mount it as root with

I suspected (and still do) a problem with permissions and, even though Nautilus gave them as being r+w for my user, the admin group, and others, changed them to:

which propped up my hopes as the whole output was similar to

. but no. Still can’t mount unless I sudo mount.

Here’s the fstab content:

The disks look like this for fdisk -l ; ls -l /dev/disk/by-uuid/

6 Answers 6

you need to add user option to your fstab ( /etc/fstab ) like this

Normally, only the superuser can mount filesystems. However, when fstab contains the user option on a line, anybody can mount the corresponding system.

Or if you want any user to mount/unmount the drives use users instead:

Only the user that mounted a filesystem can unmount it again. If any user should be able to unmount, then use users instead of user in the fstab line.

NOTE — Find original answer here by Braiam

Ok, I got it. All of the above did not work but I noticed that /media/username was also out of bounds, which was really weird as as was logged in as username. I guess it all has to do with changing the UID a while back. Anyhow, deleting /media/username let it be recreated automatically upon the next plug-in with the right permissions.

Читайте также:  Как разделить файл linux

Unplugg the usb

Open a terminal:

Press Ctrl + Alt + T

Auto-mounting from terminal with sudo mount -t ntfs-3g /dev/sdb1 /media/Elements mounts as root. Since ntfs does not have explicit permission management on a file-system basis, there’s no point in using chown , chmod or chgrp . To mount it so it is user accessible from terminal, you need to use the user mount option, like this:

You might also look into the uid , gid and umask options of the mount command for fine control.

You can create a udev rule, to do that automatically, every time your media is plugged in. Your exact rule depends on whether you want the rule to apply to all usb-media or just this specific stick. But my link to the other answer should get you started.

Not sure if it will work because I can’t test it myself but here is what I would try.

First make sure that the USB is not plugged in and mounted. Check /media/Elements and see if it exists. If it does I would delete it then insert the USB again and see whats in the /media/ folder. If Elements isn’t in there and some other folder is .. then the Label on the USB has changed. If the label on the USB has been removed it will mount the USB as its UUID

If the above still didn’t fix anything check again to see that your USB is not plugged in and Create the /media/Elements leave it as root/root but change the permissions on the folder to 777 sudo chmod 777 /media/Elements

Hopefully now when you plug in the USB labeled Elements it will mount in a usable way.

Источник

unixforum.org

Форум для пользователей UNIX-подобных систем

  • Темы без ответов
  • Активные темы
  • Поиск
  • Статус форума

Решено: mount без root’a (всё равно не даёт, хоть убей)

Модератор: Bizdelnick

Решено: mount без root’a

Сообщение Чучок » 26.03.2007 01:42

Re: Решено: mount без root’a

Сообщение serzh-z » 26.03.2007 01:58

Re: Решено: mount без root’a

Сообщение elide » 26.03.2007 04:02

Re: Решено: mount без root’a

Сообщение 4yKoTkA » 26.03.2007 08:23

Re: Решено: mount без root’a

Сообщение Juliette » 26.03.2007 09:06

Re: Решено: mount без root’a

Сообщение elide » 26.03.2007 17:13

Re: Решено: mount без root’a

Сообщение BiG_NoBoDy » 26.03.2007 17:21

ja toze dumaju mozet dobavit v /etc/fstab

/dev/hda5 / ext3 defaults 1 1

/dev/hda5 / ext3 defaults ,users 1 1

Re: Решено: mount без root’a

ja toze dumaju mozet dobavit v /etc/fstab

/dev/hda5 / ext3 defaults 1 1

/dev/hda5 / ext3 defaults ,users 1 1

Читайте также:  Как улучшить качество шрифтов windows 10

Сегодня пятна на солнце, что ли?
Человек хочет смонтировать iso образ через loop. Вот ему уже предложили монтировать корневой каталог с опцией users. Скоро предложат на лошади покататься.

Автор, ответь на вопрос elide, какие ошибки выскакивают при попытке примонтирования?

Re: Решено: mount без root’a

Сообщение BiG_NoBoDy » 26.03.2007 17:48

# mount /home/shark/dbox/Heroes.of.Might.and.Magic.III.-.The.Shadow.of.Death.iso /home/shark/dbox/hcd -t iso9660 -o loop

em paskolku ja slab v kirilice :] nitak ponial :/ bivajet :]

no fstab :] bil primer 🙂 ja dumaju kazdij kotorij ni durak ponial sto eto example 🙂 i kazdij example nisoodtvedstvujet realnim vesciam a podciorknutaja, v etom sluceje bold ciast imejet znocenije ;]

em dlia togo stob user mok primountirivat eto :] nuzno v fstab zanisti :/ ni tolko vot leva sto tolko odin iso smozet primountirvat :/ heh nu ja hatiabi tak delal :] ili prosto zapisal na CD 🙂 CD vet nidorogoje udovolstvije 😉

Источник

mount: only root can do that — why ?

‎07-27-2009 10:35 PM

‎07-27-2009 10:35 PM

# ls -l /bin/mount
-rwsr-xr-x 1 root root 330028 2008-04-22 05:56 /bin/mount

sticky bit is set on ‘mount’, and others has ‘r-x’ permission on ‘mount’ command.. i.e anyone can run ‘mount’ with root privilidges

but
# su — test
test@ins01:

> mount /dev/sda7 /mnt
mount: only root can do that

permission wise /bin/mount and /usr/bin/passwd are equivalent
-rwsr-xr-x 1 root shadow 73300 2007-05-04 17:30 /usr/bin/passwd
and any user can run ‘passwd’ command, so why not ‘mount’ ?

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

‎07-27-2009 11:06 PM

‎07-27-2009 11:06 PM

You need to allow normal users to mount it in fstab file — see man fstab.

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

‎07-27-2009 11:52 PM

‎07-27-2009 11:52 PM

Any user can run the «passwd» command too, but a non-root user can only change his/her own passwords, not anyone else’s.

A non-root user running a «setuid root» program has root privileges, but is otherwise not a true «root user». A program can tell the difference if necessary.

The message «mount: only root can do that» comes from the mount command itself: it allows non-root users to only mount and unmount those filesystems that have the special mount option «user» in the /etc/fstab file. In effect, the non-root users can only run mount operations that have been pre-approved by root.

If root configures the /etc/fstab to include the line:

/dev/sda7 /mnt ext3 user,noauto 0 0

then a non-root user could mount the filesystem with either «mount /dev/sda7» or «mount /mnt».

The full form «mount /dev/sda7 /mnt» will still be restricted to root user only, because it implies overriding any mount options specified in the /etc/fstab file.

Источник

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