又是一轮对ubuntu的折腾。装了双系统,在ubuntu下想开机自动mount windows的ntfs分区。主要两个目标:
开机自动mount
将mount的磁盘指定给当前登录用户(挂在磁盘own为当前登录用户和用户组)
达到目标1很简单,只需要编辑/etc/fstab文件即可,而且具体怎么配置,fstab中已经有很详细的说明文档了,内容如下:
dongchao@linux4dongchao:~$ cat /etc/fstab # /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). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda6 during installation UUID=431a0d34-9cc7-4a0e-ab10-a8b699d53fb4 / ext4 errors=remount-ro 0 1 # /opt was on /dev/sda7 during installation UUID=1ba482e6-f0c7-4766-a532-25b09bf2e4dc /opt ext4 defaults 0 2 # /var was on /dev/sda8 during installation UUID=0ca0e8ba-5d79-408e-8cb8-5a02924dc93d /var ext4 defaults 0 2 # swap was on /dev/sda9 during installation UUID=d1b28d9f-7704-4dd9-8f8d-b7b252da27eb none swap sw 0 0 # Data partation in windows will be mounted to /mnt/Data UUID=1222D3C822D3AF4B /media/dongchao/Data ntfs rw,dev,exec,auto,user,uid=1000,gid=1000 0 0 # Program partation in windows will be mounted to /media/dongchao/Program UUID=0E0CA2FE0CA2E047 /media/dongchao/Program ntfs rw,dev,exec,auto,user,uid=1000,gid=1000 0 0
关键点:使用blkid可以得到各个磁盘分区的UUID,剩余的配置可以参照已有的内容操作。
问题就出现在最后两行配置。比如,在Program分区中我希望使用wine执行nyfedit.exe文件,就会出现如下报错:
err:virtual:map_image failed to set 60000020 protection on section .text, noexec filesystem?
一直提示是在noexec类型的文件系统上执行的,然后开始怀疑各种,比如重装wine、配置WINPREFIX等等,实际仔细查看mount的man文档之后就发现了问题:mount的options顺序有问题。
user Allow an ordinary user to mount the filesystem. The name of the mounting user is written to mtab (or to the private libmount file in /run/mount on system without regular mtab) so that he can unmount the filesystem again. This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid).
会发现user选项本身就代表了noexec,nosuid,nodev,开启user后可以在其后添加新的配置来覆盖这三项,比如user,exec等。这样的话原来的配置: rw,dev,exec,auto,user,uid=1000,gid=1000,最终exec和dev会被user所覆盖,也就是最终还是noexec的属性。所以只要调整一下options顺序即可rw,user,dev,exec,auto,uid=1000,gid=1000
所以...仔细看文档....