Home  >  Article  >  System Tutorial  >  Linux loads ntfs and fat32 partitions

Linux loads ntfs and fat32 partitions

PHPz
PHPzforward
2024-02-09 20:40:03670browse

There are many articles about loading NTFS and FAT file systems, but sometimes it is not clear enough and newbies may be confused. By re-experimenting and explaining some commonly used commands, I hope it can help novices.

The most basic commands

Command to check disk partition status fdisk -l

for example:

[root@localhost beinan]# /sbin/fdisk -l

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 7751 39728745 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux

From the above we can know that /dev/hda1 is in NTFS format; /dev/hda2 is in FAT32 format;
linux 加载ntfs和fat32分区

mount command

is the mount command of the disk partition. If the kernel supports it, the mount command can mount almost all file systems, such as reiserfs; ext2; ext3; ntfs; fat32; jfs, etc.; in Linux systems, we commonly use The main ones are reiserfs; ext3; ext3; in Windows systems, we mainly use NTFS; FAT32; FAT, etc.;
How to mount a disk partition:

mount -t 文件格式 -o 选项参数 磁盘分区 挂载点目录名

Maybe novices don’t quite understand what is a file format and what is a mount point directory name. If we want to load a partition into Linux, does it have to be somewhere to store it? For example, we mount /dev/hda1 to the /mnt/winc directory; first we need to check whether winc exists in the /mnt directory; if there is no winc, we must create one; of course, the mount point directory name is If you choose a random name, it’s best to use English. Examples are given later. Novice brothers just need to know this first;

df -lh disk usage command

[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 5.9G 4.5G 57% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda1 5.9G 3.2G 2.7G 55% /mnt/winc
/dev/hda2 16G 8.1G 7.7G 52% /mnt/wind
/dev/hda5 7.9G 5.8G 2.1G 74% /mnt/slack

Permissions on files and directories

I have written about this in the forum, and I will sort it out when I have time; just know that umask=000 can be read, written and executed by any user. Some things will gradually become clear to you, and it will be OK if you execute a few more commands.

Kernel version

[root@localhost beinan]# uname -a
Linux localhost.localdomain 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux

From the above, I learned that the version of the kernel I am currently using is 2.6.11-1.1369_FC4

The command to obtain the root user is su

[beinan@localhost ~]$ su
Password: 在这里输入您的root密码,即使输入了,也不会显示出来;我们要安装RPM包,要用到root的超级权限;
[root@localhost beinan]#

Loading of NTFS file system

We must first confirm the kernel of the system; we must download the kernel patch that supports ntfs according to the kernel version of the system

We have already learned through fdisk -l that /dev/hda1 is an NTFS partition; how do we load it? In Fedora core 4.0, the system does not support NTFS loading by default; we can only install the ntfs plug-in of the third-party kernel or compile the kernel to achieve it. Compared with compiling the kernel, the plug-in is the most convenient and simplest;

[root@localhost beinan]# uname -a
Linux localhost.localdomain 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux

Be sure to look carefully. It is 2.6.11-1.1369_FC4, which is for i686. It does not have the word smp. smp is a kernel that supports multi-processors. If you use such a kernel, you must download the corresponding version of smp. ;
Where can we download it?
The kernel ntfs project is at http://linux-ntfs.sourceforge.net
The RPM package of kernel NTFS for Fedora core 4.0 is at:
http://linux-ntfs.sourceforge.net/rpm/fedora4.html
According to the above kernel information, we need to download: 2.6.11-1.1369_FC4 i686. The download should be:
kernel-module-ntfs-2.6.11-1.1369_FC4-2.1.22-0.rr.6.0.i686.rpm
Address: http://prdownloads.sourceforge.net/…rr.6.0.i686.rpm
Choose a mirror to download here.
Install kernel ntfs module:

[root@localhost beinan]# rpm -ivh kernel-module-ntfs*

Determine which partition is in NTFS format and load the NTFS partition

[root@localhost beinan]# /sbin/fdisk -l

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/dev/hda3 2806 7751 39728745 5 Extended
/dev/hda5 2806 3825 8193118+ 83 Linux
/dev/hda6 3826 5100 10241406 83 Linux
/dev/hda7 5101 5198 787153+ 82 Linux swap / Solaris
/dev/hda8 5199 6657 11719386 83 Linux
/dev/hda9 6658 7751 8787523+ 83 Linux

We have installed the kernel ntfs mode and now enter the loading process of the NTFS partition; through the above view, we know that /dev/hda1 is in NTFS format;

  • We need to create a directory for the mount point, for example, create a winc directory under the /mnt/ directory:
[root@localhost beinan]# mkdir /mnt/winc
  • Mount /dev/hda1 to /mnt/winc, so that if we view the contents of the /dev/hda1 disk, we will find it in /mnt/winc;
[root@localhost beinan]# mount -t ntfs -o nls=utf8,umask=000 /dev/hda1 /mnt/winc

Note: -t ntfs indicates that the file system format is ntfs; -o is the option. What are the options? There is nls=utf8, which means that the Native Language Support (local language support) is utf8, which is the language encoding that everyone often talks about; the default language encoding of Fedora core 4.0 is utf8, so that Chinese can be displayed; umask=000 means all All user groups can read and write, but because NTFS is not safe to write in Linux, it can only be read but not written. If you want to write, you can only compile the kernel yourself to achieve it; but the significance is not too big;
Is it mounted?

[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 5.9G 4.5G 57% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda1 5.9G 3.2G 2.7G 55% /mnt/winc

It seems that it is mounted; we will know if there is content after entering /mnt/winc;

[root@localhost beinan]# cd /mnt/winc
[root@localhost beinan]# ls
  • 如何开机自动加载NTFS文件系统的分区;

我们要根据磁盘的位置,上面我们看到了是/dev/hda1,对不对?所以我在/etc/fstab文件中找加如下的一行;

/dev/hda1 /mnt/winc ntfs umask=000,nls=utf8
  • 如何将这个磁盘分区放在GNOME或者KDE的桌面上呢?

在KDE下,只需要点一下鼠标,在桌面的空白处按鼠标右键就可以找得到了;不多说了,太简单;
在GNOME下也是极简单的:
比如我是以beinan这个用户登入的系统,想在放在 beinan 这个用户的GNOME桌面上;

[beinan@localhost ~]$ ln -s /mnt/winc/ ~beinan/Desktop/winc

FAT32文件系统的分区的加载

通过fdisk -l ,我们也知道了 /dev/hda2是FAT32格式的;

/dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)

Linux对FAT32的支持是可读可写的,所以没有必要再安装什么模块之类的;

我们要建一个挂载点的目录,比如是在/mnt/目录下建一个wind的目录

[root@localhost beinan]# mkdir /mnt/wind

挂载 /dev/hda2 到/mnt/wind上

[root@localhost beinan]# mount -t vfat -o iocharset=utf8,umask=000 /dev/hda2 /mnt/wind/

看一下是不是挂载好了?

[root@localhost beinan]# df -lh
Filesystem 容量 已用 可用 已用% 挂载点
/dev/hda8 11G 5.9G 4.5G 57% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/hda1 5.9G 3.2G 2.7G 55% /mnt/winc
/dev/hda2 16G 8.1G 7.7G 52% /mnt/wind

看来是挂载好了;应该进去看看;

[root@localhost beinan]#cd /mnt/wind
[root@localhost beinan]#ls -lh

drwxrwxrwx 3 root root 8.0K 7月 27 11:45 抓图
drwxrwxrwx 2 root root 8.0K 8月 12 10:21 测试文件
drwxrwxrwx 4 root root 8.0K 7月 27 11:45 电脑硬件
drwxrwxrwx 5 root root 8.0K 7月 27 11:45 网际快车

中文支持没有问题;这是我机器中的;

如何开机自动加载NTFS文件系统的分区

我们要根据磁盘的位置,上面我们看到了是/dev/hda1,对不对?所以我在/etc/fstab文件中找加如下的一行;

/dev/hda2 /mnt/wind ntfs umask=000,nls=utf8

如何将这个磁盘分区放在GNOME或者KDE的桌面上呢

在KDE下,只需要点一下鼠标,在桌面的空白处按鼠标右键就可以找得到了;不多说了,太简单;
在GNOME下也是极简单的:
比如我是以beinan这个用户登入的系统,想在放在 beinan 这个用户的GNOME桌面上;

[beinan@localhost ~]$ ln -s /mnt/wind/ ~beinan/Desktop/wind

对于文本文件乱码处理

比如我们看到有些文本文件内容是乱码,我们可以用gedit 打开,然后另存为utf8格式就OK了;

总结

虽然写的详细,但我不敢保证所有初学者都能会操作,但我感觉80%初学者还是按步骤操作不会有问题;希望大家多点耐心,戒骄戒躁能够成为这个领域的佼佼者。

The above is the detailed content of Linux loads ntfs and fat32 partitions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete