码迷,mamicode.com
首页 > 其他好文 > 详细

0901作业

时间:2015-09-15 09:30:45      阅读:316      评论:0      收藏:0      [点我收藏+]

标签:windows   linux   光盘   网络   

          Linux文件系统管理

Linux文件系统称为vfs(Virtual File System 虚拟文件系统)可支持的文件系统类型:

Linux:ext2, ext3, ext4, reiserfs, xfs,btrfs, swap

                   光盘:iso9660

                   Windows: fat32(vfat), ntfs

                   Unix: ffs, ufs, jfs, jfs2

                   网络文件系统:nfs, cifs

                   集群文件系统:ocfs2, gfs2

                   分布式文件系统:ceph,

                            moosefs, mogilefs,hdfs, gfs, glusterfs

 

                   (1) 日志型文件系统

                            非日志型文件系统:ext2

                            日志型文件系统:ext3

 

                   (2) swap:交换分区

分区工具:fdisk;lparted:sfdisk

Fdisk:

[root@localhost~]# fdisk

 

Usage:

 fdisk [options] <disk>    change partition table 更改分区表

 fdisk [options] -l <disk> list partitiontable(s) 列出分区表

 fdisk -s <partition>      give partition size(s) in blocks 以块为单位将指定的分区大小输出

 

分区管理子命令:

p: 显示

                            n: 创建

                            d: 删除

                            t: 修改分区ID

                            l: 列出所有支持ID类型

                            w: 保存退出

                            q: 放弃修改并退出

                            m: 获取帮助

新建分区后需要查看系统是否识别新的分区

[root@localhostdev]# cat /proc/partitions

majorminor  #blocks  name

 

   8       0   20971520 sda

   8       1     204800 sda1

   8       2    4194304 sda2

   8       3   16571392 sda3

   8      16   20971520 sdb

   8      17          1 sdb


创建工具(mkfs

mkfs -ttype DEVICE =mkfs.type DEVICE

使用blkid 查看分区信息

[root@localhost/]# mkfs -t ext4 /dev/sdb5

mke2fs1.41.12 (17-May-2010)

Filesystemlabel=

OS type:Linux

Blocksize=1024 (log=0)

Fragmentsize=1024 (log=0)

Stride=0blocks, Stripe width=0 blocks

56inodes, 448 blocks

22 blocks(4.91%) reserved for the super user

Firstdata block=1

Maximumfilesystem blocks=524288

1 blockgroup

8192blocks per group, 8192 fragments per group

56 inodesper group

 

Writinginode tables: done                           

 

Filesystemtoo small for a journal

Writingsuperblocks and filesystem accounting information: done

 

Thisfilesystem will be automatically checked every 22 mounts or

180 days,whichever comes first.  Use tune2fs -c or-i to override.

[root@localhost/]# blkid /dev/sdb5

/dev/sdb5:UUID="9b25009f-5f8f-4d17-876e-03e9e8435805" TYPE="ext4"

 

EXT系列文件系统在新系统中仍然有较好的支持

EXT系列文件系统专用管理工具

mke2fs   

 

         创建文件系统:

                   mke2fs [OPTION]... DEVICE

                            -t     {ext2|ext3|ext4}

                            -b {1024|2048|4096}

                            -L ‘LABEL‘

                            -j: mke2fs -t ext3

                            -i #:

                            -N #:

                            -m #: 预留磁盘空间占据多大百分比的空间为后期管理使用;

                            -O FEATURE[,...]

                                     -O ^FEATURE:关闭此特性

                                     has_journal

[root@localhost/]# mke2fs -t ext2 -L mytest /dev/sdb6

mke2fs1.41.12 (17-May-2010)

Filesystemlabel=mytest

OS type:Linux

Blocksize=4096 (log=2)

Fragmentsize=4096 (log=2)

Stride=0blocks, Stripe width=0 blocks

514080inodes, 2056184 blocks

102809blocks (5.00%) reserved for the super user

Firstdata block=0

Maximumfilesystem blocks=2105540608

63 blockgroups

32768blocks per group, 32768 fragments per group

8160inodes per group

Superblockbackups stored on blocks:

         32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632

 

Writinginode tables: done                           

Writingsuperblocks and filesystem accounting information: done

 

Thisfilesystem will be automatically checked every 39 mounts or

180 days,whichever comes first.  Use tune2fs -c or-i to override.

 

root@localhost/]# blkid /dev/sdb6

/dev/sdb6:LABEL="mytest" UUID="5d90f188-8dd3-4c64-aa44-7ad93ce7c138"TYPE="ext2"

 

文件系统属性查看及调整工具:

e2label

                            e2lable DEVICE[LABEL]

[root@localhost/]# e2label /dev/sdb6

mytest

[root@localhost/]# e2label /dev/sdb6 mytest1

[root@localhost/]# e2label /dev/sdb6

mytest1

 

tune2fs

                            显示ext系列文件系统的属性,或调整其属性;

 

                            -l:显示超级块中的信息;显示整个文件的属性及布局等相关信息;

                            -L ‘LABEL‘:修改卷标;

                            -m #: 调整预留给管理员的管理空间百分比;

                            -j: ext2 --> ext3

                            -O:文件系统属性的启动或关闭

                            -o:文件系统默认挂载选项的启用或关闭

[root@localhost/]# tune2fs -L mytest2  /dev/sdb6

tune2fs1.41.12 (17-May-2010)

[root@localhost/]# tune2fs -m 2   /dev/sdb6

tune2fs1.41.12 (17-May-2010)

Settingreserved blocks percentage to 2% (41123 blocks)

[root@localhost/]# tune2fs -j   /dev/sdb6

tune2fs1.41.12 (17-May-2010)

Creatingjournal inode: done

Thisfilesystem will be automatically checked every 39 mounts or

180 days,whichever comes first.  Use tune2fs -c or-i to override

 

[root@localhost/]# tune2fs -l   /dev/sdb6

tune2fs1.41.12 (17-May-2010)

Filesystem volume name:  mytest2

Lastmounted on:          <notavailable>

FilesystemUUID:         5d90f188-8dd3-4c64-aa44-7ad93ce7c138

Filesystemmagic number:  0xEF53

Filesystemrevision #:    1 (dynamic)

Filesystemfeatures:      has_journal ext_attrresize_inode dir_index filetype sparse_super large_file

Filesystemflags:         signed_directory_hash

Defaultmount options:    (none)

Filesystemstate:         clean

Errorsbehavior:          Continue

FilesystemOS type:       Linux

Inodecount:              514080

Block count:             2056184

Reserved block count:     41123

Freeblocks:              1986594

Freeinodes:              514069

Firstblock:              0

Blocksize:               4096

Fragmentsize:            4096

ReservedGDT blocks:      501

Blocksper group:         32768

Fragmentsper group:      32768

Inodesper group:         8160

Inodeblocks per group:   510

Filesystemcreated:       Sun Aug 30 15:25:58 2015

Lastmount time:          n/a

Lastwrite time:          Sun Aug 30 16:53:192015

Mountcount:              0

Maximummount count:      39

Lastchecked:             Sun Aug 30 15:25:582015

Checkinterval:           15552000 (6 months)

Nextcheck after:         Fri Feb 26 15:25:582016

Reservedblocks uid:      0 (user root)

Reservedblocks gid:      0 (group root)

Firstinode:              11

Inodesize:                  256

Requiredextra isize:     28

Desiredextra isize:      28

Journalinode:            8

Defaultdirectory hash:   half_md4

DirectoryHash Seed:     2e1f0a82-3f2e-490e-bc4f-3ee76c5a8061

Journalbackup:           inode blocks

 

dumpe2fs

-h: 仅显示超级块信息;

 

文件系统检测:

 fsck: Filesystem check

                            fsck -t type

                            fsck.type

                                     -a: 自动修复错误

                                     -r: 交互式修复错误

                                     -f: 强制检测

e2fsck:ext系列文件系统专用的检测修复工具;

                            -y: 自动回答为“yes”

                            -f:force

需要保持 type 与分区的文件系统一致否则可能损坏文件

 

文件系统的挂载和使用

mount:挂载

通过读取/etc/mtab文件来显示当前系统所有已经挂载的设备;

 

[root@localhost/]# mount

/dev/sda3on / type ext4 (rw)

proc on/proc type proc (rw)

sysfs on/sys type sysfs (rw)

devpts on/dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on/dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")

/dev/sda1on /boot type ext4 (rw)

none on/proc/sys/fs/binfmt_misc type binfmt_misc (rw)

gvfs-fuse-daemonon /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)

/dev/sr0on /media/CentOS_6.7_Final type iso9660(ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)            

mount -a:挂载/etc/fstab文件中的所有支持自动挂载的文件系统;

mount[options] [-o options] DEVICE MOUNT_POINT

                            [options]:命令选项

                            [-o options]:挂载选项

 

                            DEVICE: 要挂载的设备

                                     (1) 设备文件:/dev/sda5

                                     (2) 卷标:-L ‘LABEL‘

                                     (3) UUID:-U ‘UUID‘

                                     (4) 伪文件系统名称

                            MOUNT_POINT: 挂载点

 

                            常用选项:

                                     -t type:文件系统类型

                                     -r: 以“只读”方式挂载此文件系统

                                     -w: 以“读写”方式挂载此文件系统

                                     -n:每个文件系统在挂载时都会自动更新/etc/mtab文件,-n用于禁止此功能;

                                               此时,如果想查看挂载的所有文件系统:cat /proc/mounts

                                     -a: 自动挂载所有支持自动挂载的设备;

                                     -B:绑定目录至另一个目录上;

 

                            -o 挂载选项:

                                     async:异步模式

                                     sync: 同步模式

                                     atime/noatime:是否更新访问时间戳;

                                     diratime/nodiratime:是否更新目录的访问时间戳;

                                     auto/noauto:是否允许此设备被自动挂载;

                                     exec/noexec:是否允许执行此文件系统上应用程序;

                                     dev/nodev:是否支持在此设备上使用设备文件;

                                     suid/nosuid:

                                     remount:重新挂载

                                     ro

                                     rw

                                     user/nouser:是否允许普通挂载此设备;

                                     acl:是否支持此设备上使用facl;

                                     defaults:rw, suid, dev, exec, auto, nouser,and async

umount:卸载命令

                            # umount DEVICE

                            # umount MOUNT_POINT

 

                            查看正在访问指定挂载点的进程:

                                     # fuser -vMOUNT_POINT

 

                            终止所有正在访问指定的挂载点的进程:

                                     # fuser -kmMOUNT_POINT

交换分区

 

free

查看memory和swap的使用状态

-m: 以MB为单位

[root@localhost/]# free -m

             total       used       free    shared    buffers     cached

Mem:          1863        510       1352          2         41        164

-/+buffers/cache:        305       1557

Swap:         4095          0      4095

-g: 以GB为单位

[root@localhost/]# free -g

             total       used       free    shared    buffers     cached

Mem:             1          0          1          0          0          0

-/+buffers/cache:          0          1

Swap:            3          0          3

 

mkswap:创建交换分区

 

mkswap[option] DEVICE

         -L ‘LABEL‘

                                    

swapon:启用交换分区

                            swapon [option][DEVICE]

                                     -a: 激活所有交换分区

                                     -pPRIORITY: 设定其优先级;

 

swapoff:禁用交换分区

                            swapoff [option][DEVICE]

 

文件系统等空间占用信息的查看工具

df: diskfree

-:human-readable

[root@localhost/]# df -h /dev/sdb6

Filesystem      Size Used Avail Use% Mounted on

-               917M  244K 917M   1% /dev

-i: inode数量

-P: 以Posix兼容的格式输出

du: diskusage

-h:human-readable

[root@localhost/]# du -h /dev/sdb6

0       /dev/sdb6

-s:summary




0901作业

标签:windows   linux   光盘   网络   

原文地址:http://pioneerls.blog.51cto.com/5835787/1694777

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!