3.创建一个xfs文件系统
a) Lsmod | grep xfs 查看系统是否加载的有xfs,或者Mkfs. TABTAB查看是否有xfs文件格式包没有就执行下一步或者跳下一步
[root@linux ~]# lsmod | grep xfs
xfs 939662 3
libcrc32c 12644 1 xfs
[root@linux ~]# mkfs.
mkfs.btrfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.fat mkfs.minix mkfs.msdos mkfs.vfat mkfs.xfs
[root@linux ~]# mkfs.
b) Yum install xfs-progs安装xfs包(省略)
c) Mkfs.xfs –f /dev/sda# 强制把原来的格式转化为xfs格式的文件系统
[root@linux ~]# mkfs.xfs -f /dev/sda7
meta-data=/dev/sda7 isize=256 agcount=4, agsize=6400 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=25600, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=853, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@linux ~]#
d) Blkid /dev/sda#
123 [root@linux ~]# blkid /dev/sda7
/dev/sda7: UUID="6655205a-6c44-49a3-a9cc-e2587458c1c1" TYPE="xfs"
[root@linux ~]#
4.了解一些专业的ext文件系统创建工具
a) Mke2fs 选项 device
l -t {ext2|ext3|ext4}指明要创建的文件系统的类型
[root@bogon ~]# blkid /dev/sda3
/dev/sda3: UUID="228c109c-b9f8-4339-90eb-b072c60b3433" TYPE="ext2"
[root@bogon ~]# mke2fs -t ext3 /dev/sda3
......
[root@bogon ~]# blkid /dev/sda3
/dev/sda3: UUID="347239a7-720e-429a-b381-9e92d7e47f49" SEC_TYPE="ext2" TYPE="ext3"
Mkfs.ext4=mkfs –text4=mke2fs –t ext4
l -b {1024|2048|4096}指明块的大小
l -L 指明或修改卷标lable
l -m 指定预留空间百分比
[root@bogon ~]# mke2fs -t ext4 -b 2048 -L juanbiao1 -m 3 /dev/sda3
mke2fs 1.41.12 (17-May-2010)
Filesystem label=juanbiao1
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
657408 inodes, 5244722 blocks
157341 blocks (3.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=543162368
321 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816, 1327104,
2048000, 3981312
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@bogon ~]#
l -j 创建有日志功能的文件系统ext3
Mkfs.ext3=mkfs –text3=mke2fs –j=mke2fs –O has_journal /dev/sda3
[root@bogon ~]# mke2fs -j /dev/sda3
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655776 inodes, 2622361 blocks
131118 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2688548864
81 block groups
32768 blocks per group, 32768 fragments per group
8096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@bogon ~]# blkid /dev/sda3
/dev/sda3: UUID="33eb2e59-f7fc-4bc8-bb8a-824460614f2d" SEC_TYPE="ext2" TYPE="ext3"
例子:mke2fs –t ext4 –b 2048 –L juanbiao/dev/sda#
5.专业ext文件系统更改卷标
a) E2lable查看或者设定文件系统的卷标
e2lable /dev/sda# 或者blkid /dev/sda#查看卷标
e2lable /dev/sda# juanbiao 设定文件系统卷标
1234 [root@bogon ~]# e2label /dev/sda3 juanbiao2
[root@bogon ~]# e2label /dev/sda3
juanbiao2
[root@bogon ~]#
6.查看或修改ext系列文件系统的某些[超级块]属性[块大小创建后不能修改]
a) Tune2fs –l /dev/sda# 查看文件系统中超级块的信息
1234567891011121314151617181920 [root@bogon ~]# tune2fs -l /dev/sda3
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name: juanbiao2
Last mounted on: <not available>
Filesystem UUID: 33eb2e59-f7fc-4bc8-bb8a-824460614f2d
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags: signed_directory_hash
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 655776
Block count: 2622361
Reserved block count: 131118
Free blocks: 2542628
Free inodes: 655765
First block: 0
......
b) –j 无损将ext2升级为ext3
1. tune2fs –j /dev/sda# 文件系统改为ext3
[root@bogon ~]# mke2fs -t ext2 /dev/sda3
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655776 inodes, 2622361 blocks
131118 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2688548864
81 block groups
32768 blocks per group, 32768 fragments per group
8096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@bogon ~]# tune2fs -j /dev/sda3
tune2fs 1.41.12 (17-May-2010)
Creating journal inode: done
This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@bogon ~]# blkid /dev/sda3
/dev/sda3: UUID="c58a8365-b94b-4da4-b6c3-7e95e543b18b" SEC_TYPE="ext2" TYPE="ext3"
2. -L 指明或修改卷标lable
3. -m 指定预留空间百分比
[root@bogon ~]# tune2fs -L nihao -m 3 /dev/sda3
tune2fs 1.41.12 (17-May-2010)
Setting reserved blocks percentage to 3% (78670 blocks)
[root@bogon ~]# e2label /dev/sda3
nihao
[root@bogon ~]#
4. -O 关闭或启动某种特性
a) Tune2fs –O ^has_journal/dev/sda3关闭该文件系统的日志功能
b) Tune2fs –o ^mount_options/dev/sda3关闭该文件系统的默认挂载选项
c) Tune2fs –o acl /dev/sda3访问控制列表
[root@bogon ~]# tune2fs -o acl /dev/sda3
tune2fs 1.41.12 (17-May-2010)
[root@bogon ~]# blkid /dev/sda3
/dev/sda3: UUID="c58a8365-b94b-4da4-b6c3-7e95e543b18b" SEC_TYPE="ext2" TYPE="ext3" LABEL="nihao"
[root@bogon ~]# tune2fs -l /dev/sda3
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name: nihao
Last mounted on: <not available>
Filesystem UUID: c58a8365-b94b-4da4-b6c3-7e95e543b18b
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags: signed_directory_hash
Default mount options: acl-------------<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-------------
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
7.显示文件系统属性信息
a) Dumpe2fs /dev/sda# 显示文件系统的详细信息以及每一个块组的详细信息
由于版面太长不予显示了
b) Dumpe2fs –h /dev/sda#与Tune2fs –l /dev/sda#的结果相似
[root@bogon ~]# dumpe2fs -h /dev/sda3
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name: nihao
Last mounted on: <not available>
Filesystem UUID: c58a8365-b94b-4da4-b6c3-7e95e543b18b
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype sparse_super large_file
Filesystem flags: signed_directory_hash
Default mount options: acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 655776
Block count: 2622361
Reserved block count: 78670
8.文件系统检测
a) 因进程意外终止或系统崩溃等原因导致写入操作非正常终止时,可能会在造成文件损坏,此时应该检测并修复文件系统,但是建议文件系统离线[不要挂载或者别人正在使用写入的时候]操作
Ext系列文件系统检测专用e2fsck
-y 对所有的交互式询问自动回答yes
-f 即使文件系统处于clean状态,也要强制进行检测
123456789 [root@bogon ~]# e2fsck -yf /dev/sda3
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
nihao: 11/655776 files (0.0% non-contiguous), 79733/2622361 blocks
[root@bogon ~]#
通用fsck工具(检测和修复文件系统)
-f fstype 指明文件系统的类型fsck –t ext4=fsck.ext4
-a 不用交互自动修复所有错误(不建议使用)
-r 交互式修复
[root@bogon ~]# fsck -fr /dev/sda3
fsck from util-linux-ng 2.17.2
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
nihao: 11/655776 files (0.0% non-contiguous), 79733/2622361 blocks
[root@bogon ~]#
10定位设备
Blkid device
Blkid –L lable 根据卷标定位设备
Blkid –U UUID 根据UUID定位设备
[root@bogon ~]# blkid -L nihao
/dev/sda3
[root@bogon ~]# blkid /dev/sda3
/dev/sda3: UUID="c58a8365-b94b-4da4-b6c3-7e95e543b18b" SEC_TYPE="ext2" TYPE="ext3" LABEL="nihao"
[root@bogon ~]# blkid -U c58a8365-b94b-4da4-b6c3-7e95e543b18b
/dev/sda3
[root@bogon ~]#
11、创建一个GPT分区
简单了解一下什么是GPT分区?
GPT全局唯一标识分区表(GUID Partition Table),与传统的MBR分区表相比,存在着很大的差异性,比如:
分区数量:
MBR熟知的最多只能分为4个主分区,对于GPT来说,对分区是没有限制的,只是再window上支持128个分区罢了,但是在管理硬盘大小上来说,还是处于可管理18EB的优先地位,而NTFS只是256TB的大小空间。
下面我们体验一下Linux下GPT分区:
一个GPT分区的范例:
[root@bogon ~]# parted /dev/sda3
GNU Parted 2.1
Using /dev/sda3
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sda3 will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda3 (Invalid argument). As a result, it may not reflect all of your changes until after
reboot.
(parted) p
Model: Unknown (unknown)
Disk /dev/sda3: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
(parted) mkpart
Partition name? []? mydisk1
File system type? [ext2]?
Start? 100M
End? 200M
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda3 (Invalid argument). As a result, it may not reflect all of your changes until after
reboot.
(parted) P
Model: Unknown (unknown)
Disk /dev/sda3: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 99.6MB 200MB 101MB mydisk1
(parted) quit
以上仅供参考,谢谢指点
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-03/129297.htm
