Linux下文件系统有很多种类型, 比如ext2/ext3/ext4/btrfs/aufs等,系统所能支持哪些文件系统,不同的设备上的文件系统都是哪种,这篇文章总结了几条常见的命令进行确认。
/proc/filesystems中保存着OS所支持的文件系统。以下是cento7.4和ubuntu 17.10的此文件的例子
root@ubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 17.10
Release: 17.10
Codename: artful
root@ubuntu:~# cat /proc/filesystems
nodev sysfs
nodev rootfs
nodev ramfs
nodev bdev
nodev proc
nodev cpuset
nodev cgroup
nodev cgroup2
nodev tmpfs
nodev devtmpfs
nodev configfs
nodev debugfs
nodev tracefs
nodev securityfs
nodev sockfs
nodev dax
nodev bpf
nodev pipefs
nodev hugetlbfs
nodev devpts
ext3
ext2
ext4
squashfs
vfat
nodev ecryptfs
fuseblk
nodev fuse
nodev fusectl
nodev pstore
nodev mqueue
btrfs
nodev autofs
nodev overlay
nodev aufs
root@ubuntu:~#
[root@devops ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core
[root@devops ~]#
如果没有此命令的话,可以使用yum install -y redhat-lsb安装一下,或者直接确认如下文件也可
[root@devops ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@devops ~]#
/proc/filesystems
[root@devops ~]# cat /etc/filesystems
xfs
ext4
ext3
ext2
nodev proc
nodev devpts
iso9660
vfat
hfs
hfsplus
*
[root@devops ~]#
使用不带参数的mount命令,mount则会将所有挂载点相关的文件系统都列出来,由于在linux所有的设备都是以文件的形式存在,文件相关的卷基本都在/dev/下,所以使用/dev/进行过滤则可以看到主要的卷相关的文件系统,
devops@ubuntu:~$ mount |grep '^/dev/'
/dev/mapper/ubuntu--vg-root on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
/dev/mapper/ubuntu--vg-root on /var/lib/docker/plugins type ext4 (rw,relatime,errors=remount-ro,data=ordered)
devops@ubuntu:~$
[root@devops ~]# mount |grep '^/dev/'
/dev/mapper/centos_devops-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda1 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/mapper/centos_devops-root on /var/lib/docker/plugins type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
[root@devops ~]#
liumiaocn:~ liumiao$ mount |grep '^/dev/'
/dev/disk1s1 on / (apfs, local, journaled)
/dev/disk1s4 on /private/var/vm (apfs, local, noexec, journaled, noatime, nobrowse)
liumiaocn:~ liumiao$
devops@ubuntu:~$ df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
udev devtmpfs 479848 0 479848 0% /dev
tmpfs tmpfs 101248 3260 97988 4% /run
/dev/mapper/ubuntu--vg-root ext4 19475088 1775324 16687440 10% /
tmpfs tmpfs 506224 4 506220 1% /dev/shm
tmpfs tmpfs 5120 0 5120 0% /run/lock
tmpfs tmpfs 506224 0 506224 0% /sys/fs/cgroup
tmpfs tmpfs 101244 0 101244 0% /run/user/1000
/home/devops/.Private ecryptfs 19475088 1775324 16687440 10% /home/devops
devops@ubuntu:~$
[root@devops ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos_devops-root xfs 36805060 19709416 17095644 54% /
devtmpfs devtmpfs 2012428 0 2012428 0% /dev
tmpfs tmpfs 2023304 0 2023304 0% /dev/shm
tmpfs tmpfs 2023304 8592 2014712 1% /run
tmpfs tmpfs 2023304 0 2023304 0% /sys/fs/cgroup
/dev/sda1 xfs 1038336 127044 911292 13% /boot
tmpfs tmpfs 404664 0 404664 0% /run/user/0
[root@devops ~]#
lsblk用于列出块设备信息,-f选项则可以同时列出其filesystem的相关信息
[root@devops ~]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
├─sda1 xfs adeb0dff-4c25-44fb-abd4-57d4b5aa395f /boot
└─sda2 LVM2_member 2rs850-HMFM-PwS9-GCK5-pwYI-kduL-Vcm2Jo
├─centos_devops-root xfs d33c1253-99ce-4abd-97f5-6de361bc5d42 /
└─centos_devops-swap swap dcfcfce8-782d-48b5-a346-caec12937abb [SWAP]
sdb LVM2_member SarHQr-RJK0-mGiQ-sH0m-3mnv-QVLi-g68D88
├─docker-thinpool_tmeta
│ └─docker-thinpool
└─docker-thinpool_tdata
└─docker-thinpool
sr0
[root@devops ~]#
devops@ubuntu:~$ lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
`-sda1 LVM2_member 209aCb-VQUB-Jcfd-saRg-aYDg-Hfze-3jWq9q
|-ubuntu--vg-root ext4 89b9983f-d1db-4295-9195-1b912a044494 /
`-ubuntu--vg-swap_1 swap feb92abe-88df-4cd2-9b7b-603d196b18e6
`-cryptswap1 swap 54c9f545-c7ee-45a4-9c52-b3841e24acfc [SWAP]
sr0
devops@ubuntu:~$
[root@devops ~]# blkid /dev/sda1
/dev/sda1: UUID="adeb0dff-4c25-44fb-abd4-57d4b5aa395f" TYPE="xfs"
[root@devops ~]#
root@ubuntu:/home/devops# blkid /dev/ubuntu-vg/root
/dev/ubuntu-vg/root: UUID="89b9983f-d1db-4295-9195-1b912a044494" TYPE="ext4"
root@ubuntu:/home/devops#
使用file -sL 也可以从快设备文件读取文件系统的信息
[root@devops ~]# file -sL /dev/sda1
/dev/sda1: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)
[root@devops ~]#
root@ubuntu:/home/devops# file -sL /dev/ubuntu-vg/root
/dev/ubuntu-vg/root: Linux rev 1.0 ext4 filesystem data, UUID=89b9983f-d1db-4295-9195-1b912a044494 (needs journal recovery) (extents) (64bit) (large files) (huge files)
root@ubuntu:/home/devops#