Linux автоматическое монтирование ntfs разделов

How to mount a NTFS partition in /etc/fstab?

The ext4 partition mounts fine (owned by me, writable only by me), but the NTFS mounts owned by root with R\W permission for all. How to fix this?

drwxr-xr-x 7 amanda amanda 4096 2012-03-14 19:07 devel drwxrwxrwx 1 root root 4096 2012-03-14 22:38 excess 

The options «noatime» or «relatime» is available and recommended for permanent ntfs mounting (see man mount.ntfs). I had some hdd busy-ness problems with ext3/4 and ntfs too!

7 Answers 7

Permissions for ntfs and vfat file systems must be set with the dmask , fmask and umask options. dmask controls permissions for directories, fmask controls permissions for files, and umask controls both. Since these options set masks, they should be the complement of the permissions you want. For example, rwx for the owner and rx for others is 022 rather than 755.

To set the owner, use the uid and gid options for user and group, respectively. You can find your UID with the command id -u . To find your GID, use id -g . These values are both usually 1000.

A common set of mount options for ntfs is uid=1000,gid=1000,dmask=027,fmask=137 . This sets you as the owner of the drive, and sets the permissions to drwxr-x— .

Here are examples of a working /etc/fstab

UUID=EEA2B69CA2B668AB /WIN_C ntfs-3g defaults,nls=utf8,umask=000,dmask=027,fmask=137,uid=1000,gid=1000,windows_names 0 0 UUID=65AEC0E830EA0497 /WIN_D ntfs-3g rw 0 0 
  • To get the UUID for your partition, you can use ls -l /dev/disk/by-uuid/ or lsblk -f | grep -v loop or gnome-disks
  • If you get no visible error after rebooting and partitions stay readonly or you get an error similar to:
 Error mounting /dev/sda6 at /media/WindowsDrive: Command-line `mount -t "ntfs" -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,dmask=0077,fmask=0177" "/dev/sda6" "/media/rolindroy/Media Center"' exited with non-zero exit status 14: The disk contains an unclean file system (0, 0). Metadata kept in Windows cache, refused to mount. Failed to mount '/dev/sda6': Operation not permitted The NTFS partition is in an unsafe state. Please resume and shutdown Windows fully (no hibernation or fast restarting), or mount the volume read-only with the 'ro' mount option 

This is because Windows 8 and 10 offer a «Fast Startup» option that depends on a «non-complete» shutdown. You can disable fast startup by following these steps under «Power Options».

UUID=01D9318DD8A39810 /run/media/$user/Win11 ntfs-3g uid=$user,gid=$user,umask=0022 0 0 UUID=01D9317B8D647610 /run/media/$user/Storage ntfs-3g uid=$user,gid=$user,umask=0022 0 2 

In the above example win11 will be mounted read-only, while Storage as read-write.

Читайте также:  Linux console external ip

& they will be visible in file manager as drives Since they are mounted in folder /run/media/$user Also don’t forget to replace $user with your username.

Could you possibly provide a more complete example showing those options used in a line from /etc/fstab

@puk, I have UUID=3030BD846F74E514 /media/iam/ntfspartition ntfs-3g uid=1000,gid=1000,dmask=022,fmask=133 0 0 , as I’ve included at askubuntu.com/a/507326/221448 (where I also mention bind ).

This params worked for me: «defaults,rw,nls=utf8,umask=000,dmask=027,fmask=137,uid=1000,gid=1000,windows_names». After this, also run «sudo ntfsfix /dev/sdXX» to fix the partition.

If you mount the ntfs partition with the permissions option, then chmod / chown will work

/dev/sda2 /mnt/excess ntfs-3g permissions,locale=en_US.utf8 0 2 
sudo chown your_user:your_user /mnt/excess 

Easier then uid,dmask,fmask.

The chown command changes the owner of the mount point (/mnt/excess) to the desired user. This step will have to be repeated each time the partition is mounted, in my experience (at least after every reboot) . so, do the proper thing, set uid/gid/umask . I always thought fmask and dmask were optional — like when you wanted different permissions for files and dirs.

I had some trouble with this because when I reboot the disk name changes. (sda0 to sdb2)

I fixed the problem by mounting them by UUID in the fstab, you can view the UUID for your harddrives by entering: sudo blkid

Make a back-up of your fstab file:

sudo cp /etc/fstab /etc/fstab.orig 

Make sure you tripple check the >>, if you place one > you overwrite your fstab!

If you still screwed up you can replace your fstab with the original:

sudo cp /etc/fstab.orig /etc/fstab 
sudo mkdir /media/mydrivename 

Don’t forget to comment the output from the blkid with a ‘#’ on the beginning of the lines!

Add this to the fstab file, you can find the UUID in the block on the bottom you inserted with the command above. media/mydrivename is where the partition should be mounted.

UUID=xxxxxxxxxxxxxxxxx /media/mydrivename ntfs permissions,locale=en_US.utf8 0 2 
# /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). # #      # / was on /dev/sda2 during installation UUID=5d4940cf-5cf5-443a-be11-1f7e551962d1 / ext4 errors=remount-ro 0 1 # swap was on /dev/sda1 during installation UUID=84b7e5e9-08c3-4641-b28b-99e0255e604d none swap sw 0 0 # 500 GB Webserver harddisk from lr-serv-01 UUID=BA9A48D39A488E37 /media/hdd1 ntfs permissions,locale=en_US.utf8 0 2 # 2 TB Movie share harddisk from lr-serv-01 UUID=7EB09666B09624A5 /media/hdd2 ntfs permissions,locale-en_US.utf8 0 2 #/dev/sda1: UUID="10EC004DEC003010" TYPE="ntfs" #/dev/sda2: LABEL="system" UUID="88A4FE47A4FE3772" TYPE="ntfs" #/dev/sda3: LABEL="storage_01" UUID="BA9A48D39A488E37" TYPE="ntfs" #/dev/sdb1: LABEL="storage_02" UUID="7EB09666B09624A5" TYPE="ntfs" #/dev/sdc1: UUID="84b7e5e9-08c3-4641-b28b-99e0255e604d" TYPE="swap" #/dev/sdc2: UUID="5d4940cf-5cf5-443a-be11-1f7e551962d1" TYPE="ext4" #/dev/sdd1: LABEL="storage_spotnet" UUID="EC6E8F416E8F0394" TYPE="ntfs" #/dev/sdd2: LABEL="storage_backup_pcs" UUID="6C2699D026999BA0" TYPE="ntfs" #/dev/sdd5: LABEL="storage_series" UUID="7670ABF770ABBC6D" TYPE="ntfs" #/dev/sdd6: LABEL="storage_winmx" UUID="564AB81B4AB7F5B9" TYPE="ntfs" 

Reboot the system by typing:

Читайте также:  Linux applications command line

To check if the partition is mounted you can type df -k .

Give ownership to yourself:

sudo chown -R USERNAME:USERNAME /media/mydrivename 

Did this on Ubuntu Server 14.04.01!

Hope this answer helps someone 😉

Источник

Как монтировать нестандартные файловые системы в Linux

Обновлено

Обновлено: 09.07.2023 Опубликовано: 09.08.2016

Данную инструкцию можно рассматривать как шпаргалку для работы с некоторыми файловыми системами в системах Linux. По мере возможности, список примеров будет пополняться.

NTFS

Установка компонентов

Для начала необходимо установить пакет ntfs-3g. В противном случае, при попытке запустить команду на монтирование раздела NTFS мы получим ошибку mount: unknown filesystem type ‘ntfs’.

Сначала устанавливаем расширенный репозиторий:

Затем сам пакет ntfs-3g

После установки данного пакета в системе появятся дополнительные команды mount.ntfs-fuse и mount.ntfs-3g., а также команда mount распознает опцию -t ntfs.

Ручное монтирование

Монтирование NTFS на чтение и запись выполняется любой из трех команд:

mount -t ntfs-3g /dev/sdb1 /mnt

* в данном примере, примотировано устройство /dev/sdb1 в раздел /mnt. Понять, какой устройство нужно монтировать можно при помощи команды fdisk -l

Автоматическое монтирование

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

/dev/sdb1 /mnt ntfs defaults 0 0

* в данном примере мы раздел /dev/sdb1 будем монтировать в каталог /mnt.

Чтобы применить настройку и проверить ее, вводим:

Посмотреть примонтированные разделы и файловые системы можно командой:

GeeseFS (Yandex Cloud диск)

Установка компонентов

Сначала устанавливаем утилиты fuse и wget. В зависимости

yum install fuse fuse3 wget

Скачиваем geesefs и сохраняем ее в /usr/bin/geesefs:

wget https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-linux-amd64 -O /usr/bin/geesefs

Выставляем разрешение утилиты geesefs на запуск:

Проверяем работу утилиты, посмотрев ее версию:

Мы должны увидеть что-то на подобие:

Читайте также:  Discovery установить на linux

Авторизация

Yandex Cloud для монтирования диска требует прохождение аутентификации с помощью токена. Его мы получаем в личном кабинете хостера.

Для настройки доступа создаем каталог .aws в домашней директории пользователя, под которым будем монтировать диск. В моем случае, пользователь root:

После создаем файл с токеном:

[default]
aws_access_key_id = H. D
aws_secret_access_key = H. 7

Ручное монтирование

Для монтирования используем команду geesefs:

Автоматическое монтирование

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

fuse.geesefs _netdev,allow_other,—file-mode=0666,—dir-mode=0777 0 0

Если мы хотим, чтобы точке монтирования назвачался определенный владелец и группы, указываем опции uid и gid:

fuse.geesefs _netdev,allow_other,—file-mode=0666,—dir-mode=0777,—uid=1024,—gid=1024 0 0

Чтобы применить настройку и проверить ее, вводим:

Источник

Uninteresting Build Notes

По умолчанию NTFS-разделы, как и флешки, монтируются в директорию /media/<имя пользователя>/ (например, у меня /media/adil/Data) по первому нажатию на соответствующей клавише в левой панели Unity c правами только на чтение и запись для владельца. Мне необходимо иметь автоматическое монтирование в папку /media/ (/media/Data) c полными правами на чтение, запись и выполнение для всех.

Автоматически монтируемые файловые системы перечислены в файлен /etc/fstab. У меня он имеет вид:

#
UUID=cecd69af-7698-4428-9016-5ff1a4b67251 / ext4 errors=remount-ro 0 1
UUID=3cfd2254-05ce-4572-9ad8-22075135fb4f none swap sw 0 0

Для того, чтобы узнать UUID логических дисков выполняем sudo blkid в консоли:

/dev/sda1: LABEL=»WindowsBoot» UUID=»E280AF2E80AF085D» TYPE=»ntfs»
/dev/sda2: LABEL=»Win7″ UUID=»BC74BCE074BC9F18″ TYPE=»ntfs»
/dev/sda3: UUID=»cecd69af-7698-4428-9016-5ff1a4b67251″ TYPE=»ext4″
/dev/sda5: UUID=»3cfd2254-05ce-4572-9ad8-22075135fb4f» TYPE=»swap»
/dev/sda6: LABEL=»Data» UUID=»3EEADC473914B9EA» TYPE=»ntfs»
/dev/sdb1: LABEL=»SANDISK» UUID=»E852-87E4″ TYPE=»vfat»

Мне хочется, чтобы диск Data автоматически монтировался в /media/Data. Мы выбираем папку /media вместо /mnt, так как в первой Unity автоматически ищет новые логические диски и автоматически создаст ссылку в левой панели. В консоли создаем папку для монтирования sudo mkdir /media/Data. Редактируем файл /etc/fstab sudo nano /etc/fstab. Для диска Data добавляем следующую строку в конец файла:

UUID=3EEADC473914B9EA /media/Data ntfs exec,auto,rw,suid 0 0

Делаем себя владельцем директории, к которой будет монтироваться логический диск. Таким пользователь становится владельцем всех папок и файлов из примонтированного NTFS-раздела:

sudo chown adil:adil /media/Data

Источник

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