Linux下载编译ntfs-3g、安装移植、挂载ntfs格式的U盘

Linux下载编译ntfs-3g、安装移植、挂载ntfs格式的U盘

目录

前言

1、NTFS-3G 简要说明

2、NTFS-3G 工具安装

2.1 离线下载 ntfs-3g

2.2 在线下载 ntfs-3g(推荐优先)

2.3 解压安装 ntfs-3g

3、NTFS-3G 工具移植到文件系统(rootfs)

4、NTFS-3G 工具挂载

4.1 查看U盘盘符

4.2 U盘挂载

5、NTFS-3G 源码编译报错问题记录

5.1 问题1:参数配置报错及解决方法

5.2 问题2:工具安装过程报错及解决方法

5.3 问题3:使用超级权限安装工具报错及解决方法

5.4 问题4:fuse device is missing

前言

一般 Linux 系统默认都支持挂载 FAT32 格式的移动硬盘,但并不支持挂载 NTFS 格式的。那么我们在开发产品过程中,怎么应对这些需求呢?

有人可能第一时间会想到修改内核配置,以达到支持挂载 NTFS 格式的移动硬盘。在此只能说很遗憾,虽然内核支持 NTFS 格式的挂载,但是它只支持可读,不支持可写。

也正因为如此,我们如果想要让系统支持挂载 NTFS 格式的移动硬盘,并且让它可读可写,一般都需要移植第三方开源的工具:ntfs-3g。

1、NTFS-3G 简要说明

NTFS-3G 是一个开源的软件,可以实现 Linux、Free BSD、Mac OSX、NetBSD 和 Haiku 等操作系统中的 NTFS 读写支持。它可以安全且快速地读写 Windows 系统的 NTFS 分区,而不用担心数据丢失。

2、NTFS-3G 工具安装

2.1 离线下载 ntfs-3g

https://github.com/tuxera/ntfs-3g/releases

2.2 在线下载 ntfs-3g(推荐优先)

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

2.3 解压安装 ntfs-3g

# 如果是在根目录的路径下安装,需要使用超级权限

sudo su

# 使安装交叉编译器的环境变量生效

source /etc/profile

# 解压压缩包

tar -zxf ntfs-3g_ntfsprogs-2022.10.3.tgz

# 进入解压目录

cd ntfs-3g_ntfsprogs-2022.10.3/

# 配置编译参数

./configure CC=arm-hisiv400-linux-gcc --host=arm-hisiv400-linux --prefix=/my_work/tools/ntfs-3g_ntfsprogs-2022.10.3/install --exec-prefix=/my_work/tools/ntfs-3g_ntfsprogs-2022.10.3/install

# 编译生成工具与库文件

make clean;make

make install

./configure 参数配置说明:

./configure CC=arm-hisiv400-linux-gcc --host=arm-hisiv400-linux --prefix=/my_work/tools/ntfs-3g_ntfsprogs-2022.10.3/install --exec-prefix=/my_work/tools/ntfs-3g_ntfsprogs-2022.10.3/install

CC=arm-hisiv400-linux-gcc // 交叉编译器;

--host=arm-hisiv400-linux // 交叉编译工具链;

--prefix=/my_work/tools/ntfs-3g_ntfsprogs-2022.10.3/install // 指定二进制文件、库文件、配置文件的安装路径(必须要填写实际安装的绝对路径)

--exec-prefix=/my_work/tools/ntfs-3g_ntfsprogs-2022.10.3/install // 指定可执行文件的安装路径(必须要填写实际安装的绝对路径)

3、NTFS-3G 工具移植到文件系统(rootfs)

cd ntfs-3g_ntfsprogs-2022.10.3/install

cp ./bin/ntfs-3g rootfs/bin //ntfs硬盘挂载工具

cp ./bin/ntfsfix rootfs/bin //ntfs硬盘修复工具

cp ./sbin/mkntfs rootfs/bin //ntfs格式化分区工具

cp ./lib/libntfs-3g.so.89.0.0 rootfs/lib //ntfs依赖的动态库

cd rootfs/lib //创建软链接libntfs-3g.so.89 和 libntfs-3g.so

ln -s libntfs-3g.so.89.0.0 libntfs-3g.so.89

ln -s libntfs-3g.so.89.0.0 libntfs-3g.so

arm-hisiv400-linux-strip xxx (xxx表示目标文件) 可以去掉相应的符号和调试信息来节省空间,例如:

arm-hisiv400-linux-strip ./install/bin/ntfs-3g

arm-hisiv400-linux-strip ./install/lib/libntfs-3g.so.89.0.0

4、NTFS-3G 工具挂载

4.1 查看U盘盘符

fdisk -l

# Device Boot Start End Blocks Id System

# /dev/sda1 * 355462 51298533 16180960 7 HPFS/NTFS

4.2 U盘挂载

mkdir -p /mnt/usb

ntfs-3g /dev/sda1 /mnt/usb

5、NTFS-3G 源码编译报错问题记录

5.1 问题1:参数配置报错及解决方法

问题描述:执行 ./configure 配置报错如下:

/bin/rm: cannot remove 'libtoolT': No such file or directory You can type now 'make' to build ntfs-3g.

问题原因:在根目录下安装工具,没有使用超级权限,或者没有执行 make。

解决方法:(若在根目录下安装需要超级权限)执行 make:

sudo make

5.2 问题2:工具安装过程报错及解决方法

问题描述:执行 make install 报错如下:

ln -s -f /tools/ntfs-3g_ntfsprogs-2022.10.3/install/sbin/mkntfs /sbin/mkfs.ntfs ln: failed to create symbolic link '/sbin/mkfs.ntfs': Permission denied Makefile:1427: recipe for target 'install-exec-hook' failed make[3]: *** [install-exec-hook] Error 1 make[3]: Leaving directory '/tools/ntfs-3g_ntfsprogs-2022.10.3/ntfsprogs' Makefile:1346: recipe for target 'install-exec-am' failed make[2]: *** [install-exec-am] Error 2 make[2]: Leaving directory '/tools/ntfs-3g_ntfsprogs-2022.10.3/ntfsprogs' Makefile:1283: recipe for target 'install-am' failed make[1]: *** [install-am] Error 2 make[1]: Leaving directory '/tools/ntfs-3g_ntfsprogs-2022.10.3/ntfsprogs' Makefile:494: recipe for target 'install-recursive' failed make: *** [install-recursive] Error 1

问题原因:ntfs-3g 工具在根目录下安装,需要超级权限执行。

解决方法:使用超级权限执行安装命令:

sudo make install

5.3 问题3:使用超级权限安装工具报错及解决方法

问题描述:执行 sudo make install 报错如下:

../libtool: line 1085: arm-hisiv400-linux-ranlib: command not found Makefile:433: recipe for target 'install-libLTLIBRARIES' failed make[2]: *** [install-libLTLIBRARIES] Error 127 make[2]: Leaving directory '/tools/ntfs-3g_ntfsprogs-2022.10.3/libntfs-3g' Makefile:930: recipe for target 'install-am' failed make[1]: *** [install-am] Error 2 make[1]: Leaving directory '/tools/ntfs-3g_ntfsprogs-2022.10.3/libntfs-3g' Makefile:494: recipe for target 'install-recursive' failed make: *** [install-recursive] Error 1

问题原因:切换到超级权限后找不到对应的工具链 arm-hisiv400-linux。

解决方法:临时配置交叉工具链环境,再重新安装即可:

sudo su

source /etc/profile

make install

5.4 问题4:fuse device is missing

问题描述:ntfs-3g /dev/sda1 /mnt/usb 挂载报错如下:

# ntfs-3g /dev/sda1 /mnt/usb modprobe: module fuse not found in modules.dep ntfs-3g-mount: fuse device is missing, try 'modprobe fuse' as root

问题原因:内核默认没有加载 fuse 驱动。

解决方法:打开内核配置界面(make menuconfig),配置如下:

File systems --->

<*> FUSE (Filesystem in Userspace) support

上一篇: 订一份《陇东报》,开启您的2023年!
下一篇: 正版Windows系统在哪里买?

相关文章

习近平会见韩国团长 郑梦准:帮中国申办世界杯
笔记本多久清理一次灰尘
谍怎么读
轻松升级!平安金管家APP版本更新完整指南
C4D怎么旋转视角? - 菜鸟C4D
广州白云国际机场航班时刻表