In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Using NTFS-3G to implement Linux Mount NTFS Partition
But there is a problem with the permissions after mounting!
Reprint: original address:
Http://blog.sciencenet.cn/blog-430991-692444.html
This paper attempts to explore the way to make the mobile hard disk mounted on linux system have executable permissions to sort out the basic knowledge about linux system device mounting, users and groups, and document permissions.
First, ask questions
When inserting a mobile hard disk or U disk in windows partition format, the linux system automatically mounts the mobile hard disk to the / media directory and checks its permissions through ls-al, which shows: drwx-, proves that we can enter the drive letter directory, but when we further check the permissions of an executable file under the drive letter, we find that it is-rw-, to read and write the file. However, the file cannot be executed, and it is useless to change permissions through chmod, so how do I get execution permissions at this time? (for example, there is a source code on the mobile hard disk, which produces the target program through compilation, but when executed through. /, it is told that there is no permission, and sudo chmod + x does not have any effect. In practical work, when you encounter such a situation, you can generally solve the problem by copying the source code to the disk of the linux system for compilation or copying the compiled target program to the disk of the linux system and then using chmod to change the permissions. But sometimes it is time-consuming and laborious to copy back and forth, and it would be much more convenient if you can directly give the mobile hard disk mounted to the linux system the right to execute)
II. Mounting linux equipment
This problem involves hard disk mounting. First of all, we need to understand the two system files related to disk mount in the linux system, namely / etc/fstab and / etc/mtab. The former is the system partition information and the mount parameters of the disk when the system starts, and the file is a static file (it will not be changed after the system starts. If it is artificially changed, the system needs to be restarted). The latter is a list of disks that have been mounted in the current system, and the file is a dynamic file, that is, it changes at any time with the system mount and umount file systems. For example, when a U disk is inserted, the system writes information about the disk in the mtab file, and when the U disk is unplugged, the system deletes the information about the disk in the mtab file.
The format of the fstab file content is as follows:
# / etc/fstab: static file system information.
#
#
……
Proc / proc proc nodev,noexec,nosuid 0 0
……
The format of the mtab file content is as follows:
……
Proc / proc proc rw,noexec,nosuid,nodev 0 0
……
It can be seen that the format in the fstab and mtab files is the same, and the list is organized in the format of "device name-mount point-partition type-mount option-dump option-pass option".
1. The device name refers to the name of the device in the system, such as / dev/sda1 or / etc/sdb1 or / etc/sdc1, which can be viewed by the sudo fdisk-l command. (the proc device in the fstab and mtab file format examples above is a virtual device that does not actually exist on disk, but only in memory, storing information about processes and systems.)
2. The mount point is actually the folder created for mounting the disk, such as. /,. / usr, and. / swap. Of course, we can use mkdir to create a folder as the mount point.
3. Partition types include ext2,ext3,ext4,jfs,jfs2,reiserfs,reiser4,swap under linux, FAT and NTFS under windows, etc.
4. Common mount options include: (1) auto and noauto: auto allows the system to mount automatically or by using mount-a, which is the default option for fstab; noauto enables the system not to mount automatically or when using mount-a; (2) rw and ro:rw means to mount the device with read-write permission, while ro means to mount the device with read-only permission. (3) suid and nosuid:suid indicate that setting operations of uid and gid are allowed on the device. Nosuid does not allow setting uid and gid;. (4) dev and nodev:dev means mounting special devices on the file system at the same time, and nodev means not mounting these special devices. (5) exc and noexc:exec means to allow the execution of binaries under the file system, and noexc of course does not allow the execution of binaries. (6) user, nouser, users and owner:user allow specified ordinary users to mount the device. Nouser forbids ordinary users to mount the device (only root can mount the device), users means all ordinary users are allowed to mount the device, and owner means only the device owner can mount it. Both the user and users options imply the noexec,nosuid,nodev option; (7) sync and asnyc:sync indicate that the device's Icano operation is synchronized without buffering, while async indicates that the device is not synchronized and buffered; (8) defaults: this option is a combination of rw, suid, dev, exec, auto, nouser, and async. In addition, the linux system can also set other special options for different file systems. For example, for the NTFS file system under Windows, you can set utf8 (indicating that the file name is converted by UTF-8) and uid=**** (id, the specified user of the mount device). It can be obtained through id command or viewing / etc/passwd file), gid=**** (specified user group id for mounting devices) and umask=*** (permission masking for mounting devices, octal values). For FAT (including msdos,umsdos,vfat, etc.) file systems under Windows, you can set uid=****,gid=****,umask=***,dmask=*** (permission masking applied to directories when mounting devices Octal values) and fmask=*** (permission masking applied to ordinary files when mounting devices, octal values). More mount options can be found in man mount.
5. The dump option is used to set whether to allow the backup program dump to back up the file system. 0: no backup, 1: backup. If you backed up with dump last time, the number of days since the backup will be displayed.
6, pass option, tells fsck program to boot in what order to check the file system, 0 means no check, (. /) partition can only be 1, other partitions can only be 2, when the number is the same, check at the same time.
III. Linux users and groups and permissions
Knowing the device mount mentioned above, we basically know how to mount the mobile hard drive in windows partition format under linux. The key is to set the mount option to get the appropriate permissions. In linux systems, permission settings are directly related to the concepts of users and groups. For example, when you use the ls-al command above, the information about permissions (10 characters, such as drwx-) can be divided into four parts, that is, directory / file identification (the first character, d for directory,-for file, and the other can be l B and c), owner permissions (2-4 characters), user group permissions that the owner belongs to (5-7 characters), and other user rights (the last 3 characters). Permissions play an important role in the security of linux systems, which are not discussed here. There are two ways to express permissions, namely, character and digital: character uses the three characters, such as r, w and x above, to indicate read, write and execute permissions, respectively, and-to indicate that they do not have any permissions. The digital permission representation method uses 4, 2 and 1 numbers to represent read, write and execute permissions respectively, 0 means no permissions, and when the permissions of document owners, groups and other users are expressed digitally, the permissions of the same group need to be accumulated. for example, if the permission of a document is-rwx rw-, it is digitally expressed as 760.
At this point, we can go back and solve the problem. When mounting a file system in Windows partition format, we can set permissions through uid=****,gid=**** and umask=***/dmask=***/fmask=***. It is not difficult to set uid and gid, just set it to our own uid and gid. The setting of permission mask is digital. Similarly, the first number represents the owner's permission mask, the second number represents the group permission mask, and the third number represents the permission mask of other users. If umask=000, it means that no user has any permissions, that is, all users have read, write and execute permissions. For example, fmask=033 means that the document owner has read, write and execute permissions. On the other hand, groups and other users only have read permissions and mask permissions 3 (the sum of 1 and 2).
Fourth, solve the problem
To sum up, you can add a mount configuration such as the following in / etc/fstab and restart the system to mount the hard drive to gain execution rights.
#
/ dev/sdb1 / media/sdb1 ntfs utf8,uid=1000,gid=1000, umask=000 00
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.