博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Identify Linux File System Type
阅读量:4030 次
发布时间:2019-05-24

本文共 2639 字,大约阅读时间需要 8 分钟。

5 Methods to Identify Your Linux File System Type (Ext2 or Ext3 or Ext4)

Question: How do I identify my file system type? I like to upgrade my current file system to the latest ext4. Before that I would like to know what my current file system type is for various mount points I have on my UNIX system.

Answer: Use any one of the five methods mentioned below to identify your file system type.

Method 1: Use df -T Command

The -T option in the df command displays the file system type. 

# df -T | awk '{print $1,$2,$NF}' | grep "^/dev"/dev/sda1 ext2 //dev/sdb1 ext3 /home/dev/sdc1 ext3 /u01

Method 2: Use Mount Command

Use the mount command as shown below.

# mount | grep "^/dev"/dev/sda1 on / type ext2 (rw)/dev/sdb1 on /home type ext3 (rw)/dev/sdc1 on /u01 type ext3 (rw)

As shown in the above example:

  • /dev/sda1 is ext2 file system type. (mounted as /)
  • /dev/sdb1 is ext3 file system type. (mounted as /home)
  • /dev/sdc1 is ext3 file system type. (mounted as /u01)

Method 3: Use file Command

As root, use the file command as shown below. You need to pass the individual device name to the file command.

# file -sL /dev/sda1/dev/sda1: Linux rev 1.0 ext2 filesystem data (mounted or unclean) (large files)# file -sL /dev/sdb1/dev/sda1: Linux rev 1.0 ext3 filesystem data (needs journal recovery)(large files)# file -sL /dev/sdc1/dev/sda1: Linux rev 1.0 ext3 filesystem data (needs journal recovery)(large files)

Note: You should execute the file command as root user. If you execute as non-root user, you’ll still get some output. But, that will not display the file system type as shown below.

$ file -sL /dev/sda1/dev/sda1: writable, no read permission

Method 4: View the /etc/fstab file

If a particular mount point is configured to be mounted automatically during system startup, you can identify its file system type by looking at the /etc/fstab file.

As shown in the example below, / is ext2, /home is ext3, and /u01 is ext3.

# cat /etc/fstabLABEL=/r       /        ext2    defaults    1 1LABEL=/home    /home    ext3    defaults    0 0LABEL=/u01     /u01     ext3    defaults    0 0

Method 5: Use fsck Command

Execute the fsck command as shown below. This will display the file system type of a given device.

# fsck -N /dev/sda1fsck 1.39 (29-May-2006)[/sbin/fsck.ext2 (1) -- /] fsck.ext2 /dev/sda1# fsck -N /dev/sdb1fsck 1.39 (29-May-2006)[/sbin/fsck.ext3 (1) -- /home] fsck.ext3 /dev/sdb1# fsck -N /dev/sdc1fsck 1.39 (29-May-2006)[/sbin/fsck.ext3 (1) -- /u01] fsck.ext3 /dev/sdc1

If you don’t have the root access, but would like to identify your file system type, use /sbin/fsck -N as shown above.

转载地址:http://jehbi.baihongyu.com/

你可能感兴趣的文章
关于共享单车定位不准问题
查看>>
终于搞定CString和string之间转换的问题了
查看>>
用防火墙自动拦截攻击IP
查看>>
补充自动屏蔽攻击ip
查看>>
谷歌走了
查看>>
多线程使用随机函数需要注意的一点
查看>>
getpeername,getsockname
查看>>
让我做你的下一行Code
查看>>
浅析:setsockopt()改善程序的健壮性
查看>>
关于对象赋值及返回临时对象过程中的构造与析构
查看>>
VS 2005 CRT函数的安全性增强版本
查看>>
SQL 多表联合查询
查看>>
Visual Studio 2010:C++0x新特性
查看>>
drwtsn32.exe和adplus.vbs进行dump文件抓取
查看>>
cppcheck c++静态代码检查
查看>>
CLOSE_WAIT和TIME_WAIT
查看>>
在C++中使用Lua
查看>>
在Dll中调用自身的位图资源
查看>>
IP校验和详解
查看>>
C++中使用Mongo执行count和distinct运算
查看>>