linux下USB移動硬碟NTFS格式自動掛載

來源:互聯網
上載者:User

 

買了個1T的硬碟,因為要和WINDOWS交換,所以只能用NTFS格式。

 

安裝hal和dbus就不說了。

一、安裝軟體
# emerge ntfs-3g

二、配置,並編譯核心
# cd /usr/src/linux
# make menuconfig
勾選 File systems ---> <M> Filesystem in Userspace support
# make clean && make && modules_install

三、載入核心模組
# modprobe fuse
當然可以再開啟 /etc/modules.autoload.d/kernel-2.6,把fuse加進去。

四、手動mount NTFS分區的命令

然後就可以mount ntfs分區了:

# mount -t ntfs-3g -o locale=zh_CN.UTF-8,silent /dev/sdc1 /mnt/usb

 

五、配置/etc/fstab

在/etc/fstab中加上以下行

/dev/sdc1       /home/crob/1TDisk    ntfs-3g    auto,user,rw,locale=zh_CN.UTF   -8,silent    0  0

 

六、非root使用者不能自動mount,提示示“only root can do this”的解決方案

fstab中的user選項在ntfs3g上不管用,查了ntfs-3g官網後發現以下回答:

http://ntfs-3g.org/support.html#useroption2


Why don't the 'user' and 'users' options work in /etc/fstab?

The 'mount' command doesn't invoke the ntfs-3g binary with the needed
privilege after it has checked and approved the user is entitled
to mount a given device on a specified mount point, hereby the
user can't open the device he got the approval in /etc/fstab.
This is a problem in the 'mount' utility.


Solution: Use at least NTFS-3G 1.2506 with setuid-root
set and make sure the user has access rights to the volume and mount point.

 

emerge ntfs3g加上了suid參數後,還是不能自動mount,會報無許可權。

 

做了以下動作,使普通使用者有mount和unmount許可權

建立mount使用者組編輯/etc/group,添加如下內容:

mount:*:1000:username1,username2

dotc crob # chmod 4710 /bin/mount

dotc crob # chown root:mount /bin/mount

dotc crob # chmod 4710 /bin/umount
dotc crob # chown root:mount /bin/umount

至此,一切搞定,插入USB,自動掛載。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.