1. 程式人生 > 其它 >CentOS掛載NTFS

CentOS掛載NTFS

確認分割槽資訊

fdisk -l


Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x0009ac89

 

Device Boot Start End Blocks Id System

/dev/vda1 * 2048 104857566 52427759+ 83 Linux

 

Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0xa95b85b4

 

Device Boot Start End Blocks Id System

/dev/vdb1 2048 209713151 104855552 7 HPFS/NTFS/exFAT

sudo lsblk -f


NAME FSTYPE LABEL UUID MOUNTPOINT

sr0 iso9660 config-2 2021-06-20-21-44-07-00

vda

└─vda1 ext4 4b499d76-769a-40a0-93dc-4a31a59add28 /

vdb ext4 a0ddb5ef-fcce-4bc5-b284-d577d2af01cb

└─vdb1 ntfs 66D06ACCD06AA1D3

確認NTFS支援

rpm -qa | grep ntfs-3g

yum list installed | grep ntfs-3g

安裝NTFS支援

線上安裝

yum install -y ntfsprogs

離線編譯安裝
官網: https://www.tuxera.com/company/open-source/

穩定版本: https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz

cd /home

wget https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz

tar zxvf ntfs-3g_ntfsprogs-2017.3.23.tgz

cd ntfs-3g_ntfsprogs-2017.3.23

./configure

make & make install

makedir /home2

cd ~

ntfs-3g /dev/vdb1 /home2


The disk contains an unclean file system (0, 0).

Metadata kept in Windows cache, refused to mount.

Falling back to read-only mount because the NTFS partition is in an

unsafe state. Please resume and shutdown Windows fully (no hibernation

or fast restarting.)

這裡掛載,報錯了.

重新掛載下:

sudo mount -o rw,remount /dev/vdb1

嘗試直接掛載,看是啥效果?

sudo mount /dev/vdb1 /home2


mount: unknown filesystem type 'ntfs'

sudo ntfs-3g /dev/vdb1 /home2


Mount is denied because the NTFS volume is already exclusively opened.

The volume may be already mounted, or another software may use it which

could be identified for example by the help of the 'fuser' command.

sudo ntfs-3g /dev/vdb1 /home2


The disk contains an unclean file system (0, 0).

Metadata kept in Windows cache, refused to mount.

Falling back to read-only mount because the NTFS partition is in an

unsafe state. Please resume and shutdown Windows fully (no hibernation

or fast restarting.)

以上方法都試了,還是不行,只能先修復狀態:

sudo ntfsfix /dev/vdb1


Mounting volume... The disk contains an unclean file system (0, 0).

Metadata kept in Windows cache, refused to mount.

FAILED

Attempting to correct errors...

Processing $MFT and $MFTMirr...

Reading $MFT... OK

Reading $MFTMirr... OK

Comparing $MFTMirr to $MFT... OK

Processing of $MFT and $MFTMirr completed successfully.

Setting required flags on partition... OK

Going to empty the journal ($LogFile)... OK

Checking the alternate boot sector... OK

NTFS volume version is 3.1.

NTFS partition /dev/vdb1 was processed successfully.

Reboot

sudo ntfs-3g /dev/vdb1 /home2


ntfs-3g: symbol lookup error: ntfs-3g: undefined symbol: ntfs_xattr_build_mapping

這個錯誤呢,是因為我之前手動下載編譯後,又通過yum安裝了,導致了版本衝突.

刪除或重新命名 /lib/libntfs-3g.so.88

ls /lib | grep ntfs


libntfs-3g.so

libntfs-3g.so.88

libntfs-3g.so.88.0.0

ls /lib64 | grep ntfs


libntfs-3g.so.88

libntfs-3g.so.88.0.0

mv /lib/libntfs-3g.so.88 /lib/libntfs-3g.so.88.del

ls /lib | grep ntfs


libntfs-3g.so

libntfs-3g.so.88.0.0

libntfs-3g.so.88.del

再次執行掛載(OK,沒錯誤了):

sudo ntfs-3g /dev/vdb1 /home2

永久掛載方法

當手動掛載沒有錯誤的時候,才建議永久掛載,否則系統可能會無法啟動.

找到到磁碟GUID然後編輯fstab檔案.

blkid /dev/vdb1


/dev/vdb1: UUID="66D06ACCD06AA1D3" TYPE="ntfs"

vim /etc/fstab

編輯列說明:


#

# /etc/fstab

# Created by anaconda on Thu Mar 7 06:38:37 2019

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=4b499d76-769a-40a0-93dc-4a31a59add28 / ext4 defaults 1 1

UUID=66D06ACCD06AA1D3 /home2 ntfs defaults 0 0

確認掛載資訊

df -TH


Filesystem Type Size Used Avail Use% Mounted on

devtmpfs devtmpfs 2.0G 0 2.0G 0% /dev

tmpfs tmpfs 2.0G 54k 2.0G 1% /dev/shm

tmpfs tmpfs 2.0G 725k 2.0G 1% /run

tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup

/dev/vda1 ext4 53G 14G 37G 28% /

tmpfs tmpfs 398M 0 398M 0% /run/user/0

/dev/vdb1 fuseblk 108G 675M 107G 1% /home2