- Автоматическое монтирование диска в Linux Ubuntu / Mint
- Шаг 1. Узнаем идентификаторы подключенных разделов
- Шаг 2. Оповещаем систему о новом разделе
- Шаг 3. Завершаем дело
- Шаг 4. Гуляем смело
- Вариант 2. Gnome Disk Utility
- Проблемы с удалением в корзину?
- How To Automount File Systems on Linux
- Step 1: Get the Name, UUID and File System Type
- Step 2: Make a Mount Point For Your Drive
- Step 3: Edit /etc/fstab File
- Some Explanation
- Can’t Mount Your Disk Drive?
- Как монтировать NTFS в Linux
- Установка компонентов
- Ручное монтирование
- Автоматическое монтирование
- How To Debian/Ubuntu Linux Auto Mount Windows NTFS File System [ntfs-3g]
- Out sample setup
- A note about ntfs-3g
- Auto mounting a drive containing a Windows (NTFS) file system using /etc/fstab
- Step 1: Edit /etc/fstab
- Step 2: Append the following configuration
- A note about the /dev/sdb1 device name
- Step 3: Create the /mnt/ntfs/ directory
- Step 4: Test it
- Step 5: Unmount NTFS partion
- Optional: Manual mounting using ntfs-3g cli option
Автоматическое монтирование диска в Linux Ubuntu / Mint
Так уж повелось, что по умолчанию Ubuntu монтирует только свой системный раздел, называя его «файловой системой». Остальные разделы (кроме флэшек и других подключаемых устройств) придется монтировать вручную. Нас такой расклад не устраивает и мы хотим иметь доступ к нашему второму (третьему, четвертому. ) разделу сразу после загрузки ОС.
Каждый раздел имеет свой UUID (Universally Unique Identifier), и мы будем подключать разделы с помощью него.
Шаг 1. Узнаем идентификаторы подключенных разделов
Получаем что-то примерно такое:
/dev/sda1: UUID=»b2098d42-3e3d-470c-8ddb-76f74f0f6d44″ TYPE=»ext4″
/dev/sda3: LABEL=»ntfs» UUID=»6798491F3EB8CFC8″ TYPE=»ntfs»
/dev/sda5: LABEL=»FAT32″ UUID=»1D7D-F985″ TYPE=»vfat»
/dev/sda6: LABEL=»ext3″ UUID=»a4f6af01-786f-4bdf-9405-d340fded6580″ TYPE=»ext3″
/dev/sda7: LABEL=»ext2″ UUID=»4b2c5e07-97db-4a65-9147-e6b0dceb1353″ TYPE=»ext2″
/dev/sda8: LABEL=»ext4″ UUID=»b74143c3-6679-4a3a-9a20-b608ba085170″ TYPE=»ext4″
Если Вашему разделу задан Label, то всё отлично, поиски необходимого не займут много времени. Например, нам нужен раздел «ntfs» с UUID «6798491F3EB8CFC8». Для определения UUID для раздела без Label придется воспользоваться программами типа gParted или стандартного менеджера дисков, здесь Вам помогут обозначения /dev/sdaX.
Если же Вам лень искать UUID, то можно воспользоваться порядковым номером: /dev/sda3. Минус такого подхода — порядковый номер может измениться при добавлении или переставлении дисков.
Шаг 2. Оповещаем систему о новом разделе
Вся информация по монтируемым разделам хранится в fstab:
sudo gedit /etc/fstab
Если у Вас не установлен gedit, то можете воспользоваться nano или любым другим текстовым редактором. В этом файле добавляем в конец строку:
UUID=»6798491F3EB8CFC8″ /media/isergium/ntfs ntfs-3g defaults,uid=1000 0 0
Монтировать разделы желательно в /media — так они продолжут распознаваться некоторыми проводниками (например, Nemo) как разделы. Для удобства все разделы можно монтировать в одну папку, например /media/*username* .
Приведённый выше формат действителен для NTFS. Обязательно убедитесь что пакет ntfs-3g установлен в Вашей системе. Он даёт много преимуществ перед использованием обычного ntfs , поэтому просто используйте его. Для других файловых систем рекомендованы другие параметры и обозначения:
NTFS | ntfs-3g | ntfs-3g defaults,uid=1000 0 0 |
FAT16, FAT32 | vfat | user,auto,fmask=0111,dmask=0000 |
Apple HFS | hfsplus | user,auto,file_umask=0177,dir_umask=0077,uid=1000 |
ext2 | ext2 | defaults |
ext3 | ext3 | |
ext4 | ext4 |
Не забудьте подставить свои значение UUID и путь монтирования.
Шаг 3. Завершаем дело
Осталось перезагрузиться или смонтировать несмонтированные диски:
Шаг 4. Гуляем смело
Вот и всё. Отныне для доступа к необходимым файлам не придется вручную монтировать разделы с ними.
Вариант 2. Gnome Disk Utility
В комментариях был предложен более удобный способ автоматического монтирования с помощью стандартной программы «Диски» (gnome-disks). Вот пример работы с ним на Elementary OS Freya (дистрибутив основан на Ubuntu 14.04):
Выбрать диск, выбрать раздел, нажать на кнопку с шестерёнками, в появившемся меню выбрать «Изменить параметры монтирования» («Edit Mount Options»). В настройках выключить верхний переключатель «Параметры автоматического подключения» («Automatic Mount Options»), включить «Подключение при запуске» («Mount at startup») и «Показывать в интерфейсе» («Show in user interface»). В «Идентифицировать как» («Identify as») лучше выбрать что-нибудь связанное с UUID. По желанию можно задать Тип файловой системы («Filesystem Type»), Точку подключения («Mount Point») и что-нибудь ещё.
После сохранения соответствующая запись появится в /etc/fstab:
UUID=3C1D4F9C296DA92C /mnt/3C1D4F9C296DA92C auto nosuid,nodev,nofail,x-gvfs-show 0 0
После перезагрузки и каждого следующего включения диск будет примонтирован автоматически:
Если программа «Диски» не была найдена, то её можно запустить из консоли:
Установить её можно из исходников или командой:
sudo apt-get install gnome-disk-utility
Проблемы с удалением в корзину?
Если при удалении файлов со смонтированных дисков выдаются ошибки вроде «не удалось переместить в корзину», «невозможно удалить в корзину» и подобные, то достаточно добавить в параметры монтирования параметр uid=1000 .
UUID=»6798491F3EB8CFC8″ /media/isergium/ntfs ntfs-3g defaults,uid=1000 0 0
Этот параметр устанавливает владельца примонтированного раздела, по умолчанию это (зависит от файловой системы) либо root, либо владелец процесса. Если Ваш UID иной (что маловероятно), то можете поискать свой в /etc/passwd и прописать его.
Вместо uid можно использовать gid — этот параметр установит группу владельцев. Обычно это тоже 1000, проверить можно в /etc/group.
Источник
How To Automount File Systems on Linux
Today I’m going to show you how to automatically mount a drive at boot time in Linux. My laptop has one SSD and one mechanical drive. I install operating systems on SSD and store files on the mechanical drive. So oftentimes I need to mount the mechanical drive in the file manager manually to access my mp3 and video files. Mounting drive manually is just a waste of time. So I’m going to show you an easy way to automount drive in Linux.
Step 1: Get the Name, UUID and File System Type
Open your terminal, run the following command to see the name of your drive, its UUID(Universal Unique Identifier) and file system type.
In the output of this command, the first column is the name of your drives. The second column is the label of the drive (if you set a label for it) and the third column is the UUID of your drives.
First, you need to know the name of the drive that is going to be automatically mounted. For example, the name of the drive that is going to be automatically mounted on my computer is /dev/sdb9 .
Then you need to know its UUID and file system type. As you can see the UUID of /dev/sdb9 is eb67c479-962f-4bcc-b3fe-cefaf908f01e and the file system of /dev/sdb9 is ext4 which is the standard file system in Linux.
Step 2: Make a Mount Point For Your Drive
We are going to make a mount point under /mnt directory. Enter the following command,
For example, I issued the following command:
Step 3: Edit /etc/fstab File
Run the following command to edit the /etc/fstab file. Nano is a command-line editor on Linux.
We need to append one line of code at the end of the file. The format of this line of code is as follows:
Note that you need to separate these items with Tab key. For example, I added the following line to the end of /etc/fstab .
If you want to automount an NTFS file system, here is an example.
If you want to automount a Btrfs file system, then change the file system type to btrfs.
Save and close the file. Then run the following command to see if it works.
So that’s how you automount a file system in Linux.
Some Explanation
For swap partitions, the mount point field should be specified as none.
The defaults mount option will give users read and write access to the file system.
The value of the dump field is usually zero.
The pass field is used by the fsck program to determine the order in which filesystem checks are done at reboot time. As you can see in this file, the value of the pass field for the root file system is 1. Swap partitions do not need to be checked and the value for them is zero. All other file systems should have a value of 2. So I set the pass value to 2 for my drive.
Can’t Mount Your Disk Drive?
If you see the “can’t read superblock” error when trying to mount your disk drive, please follow the tutorial below to fix this error.
Источник
Как монтировать NTFS в Linux
Инструкция на примере Linux CentOS 7.
Установка компонентов
Для начала необходимо установить пакет ntfs-3g. В противном случае, при попытке запустить команду на монтирование раздела NTFS мы получим ошибку mount: unknown filesystem type ‘ntfs’.
Сначала устанавливаем расширенный репозиторий:
yum install epel-release
Затем сам пакет ntfs-3g
yum install ntfs-3g
После установки данного пакета в системе появятся дополнительные команды mount.ntfs-fuse и mount.ntfs-3g., а также команда mount распознает опцию -t ntfs.
Ручное монтирование
Монтирование NTFS на чтение и запись выполняется любой из трех команд:
mount -t ntfs /dev/sdb1 /mnt
mount -t ntfs-3g /dev/sdb1 /mnt
mount.ntfs-3g /dev/sdb1 /mnt
* в данном примере, примотировано устройство /dev/sdb1 в раздел /mnt. Понять, какой устройство нужно монтировать можно при помощи команды fdisk -l
Автоматическое монтирование
Чтобы раздел автоматически монтировался при перезапуске компьютера, открываем на редактирование файл:
/dev/sdb1 /mnt ntfs defaults 0 0
* в данном примере мы раздел /dev/sdb1 будем монтировать в каталог /mnt.
Чтобы применить настройку и проверить ее, вводим:
Посмотреть примонтированные разделы и файловые системы можно командой:
Источник
How To Debian/Ubuntu Linux Auto Mount Windows NTFS File System [ntfs-3g]
I ‘m dual booting MS-Windows with a Debian / Ubuntu Linux desktop. How can I auto mount a drive containing a MS-Windows NTFS file system on a Linux based systems?
The New Technology File System (NTFS) is a file system developed by Microsoft in 1995 with Windows NT. You can easily auto mount a hard disk drive partition containing a NTFS using the following method on any modern Linux desktop.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | ntfs-3g |
Est. reading time | 2 mintues |
Out sample setup
- /dev/sdb1 = NTFS partition (use fdisk -l command to find out NTFS partitions names)
- Linux user (vivek)
- Linux group (vivek)
- Linux mount point = /mnt/ntfs
- Required package : ntfs-3g (3rd generation read/write NTFS driver
A note about ntfs-3g
Type the following apt-get command to install the same:
Fig.01: Install the ntfs-3g package from the official repositories on a Debian/Ubuntu
Auto mounting a drive containing a Windows (NTFS) file system using /etc/fstab
The file /etc/fstab contains descriptive information about the various file systems. You need to edit this file and append the following information.
Step 1: Edit /etc/fstab
Open the terminal application and type the following command:
Step 2: Append the following configuration
A note about the /dev/sdb1 device name
If /deb/sdb1 path will change due to system configuration, I recommend that you use the UUID (Universally Unique Identifier) of the partition. To find the UUID of /dev/sdb1, enter:
Note down the UUID value and update /etc/fstab as follows:
Save and close the file.
Step 3: Create the /mnt/ntfs/ directory
Type the following mkdir command:
Step 4: Test it
Type the following command:
Step 5: Unmount NTFS partion
Type the following command:
Optional: Manual mounting using ntfs-3g cli option
The syntax is as follows to mount /dev/sdb1 to /mnt/ntfs/:
sudo mkdir -p /mnt/ntfs
Mount it:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
You can mount the ntfs data partition /dev/sda3 to /mnt/data with standard Linux permissions applied :
You can do read-only mount /dev/sda5 to /home/user/mnt and make user with uid 1000 to be the owner of all files:
References
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
It’s worth noting that Windows sometimes makes a small partition at the beginning of the disk and you need to mount the second partition (e.g. /dev/sda2) instead of the usual first one.
I had to figure this out when I was mounting remotely a usb hdd with gpt / ntfs on a debian server.
On a System with often switching configurations it may be helpful to identify the partition by UUID.
sudo blkid
to get something like:
/dev/disk/by-uuid/F656C6B256C67455.
Then replace the /dev/sdb1 from above with /dev/disk/by-uuid/F656C6B256C67455.
The faq has been updated. I appreciate your feedback.
Hi nice article. It previous Ubuntu verions 9.04, 10.04 and 12.04 I used ntfs-config. Can this program be used in later Ubuntu versions, Zorin 9 and Mint 17.1? I can do work using the CLI but I prefer using a GUI application/program as much as possible. I usually only use the CLI as a last resort.
An issue I have with most of the answers to queries on forums etc is that the answers given are almost always the CLI entries. It would be if the GUI route was also given.
The “ro” option stands for read only? Is not possible to have a read write mounted NTFS partition?
Hi Franco normally if you manually mount a NTFS partition it mounts as a read/write so you should also be able to do it automatically. The ntfs-config program automounted NTFS partitions as read/write. I am wondering why a person would want to mount a NTFS partition in read only mode in their home folder.
The ro and umask-0222 both caught my attention. If I’m not mistaken, that would result in a read-only mount where all the directories and files have read and execute bits set, but not write. I’m not sure why you’d want that.
After reading the fstab and mount pages carefully, here’s what I used and it works great:
UUID=2EE63C53E63C1E11 /mnt/windows ntfs defaults,uid=0,gid=0,umask=0000
Note that I didn’t specify the last two fields. They have reasonable defaults.
Источник