总结:1,首先讲到了磁盘的分类,现在磁盘一般分为机械式硬盘和SSD硬盘。磁盘接口类型有多种:IDE(ATA):最高速度133MB/s

      SCSI:640MB/s

      SATA:6Gbps

      SAS:6Gbps

      USB:480MB/s

linux标识硬盘设备一般用/dev/sd[a-z]来表示,其中1-4是主或扩展分区标识,5+是逻辑分区标识

设备一般用“块"或者"字符"为单位来表示。


2,其中讲到了分区的概念,分区是为了方便管理和增加单个区块文件的访问速度,每个空间可独立的使用文件系统。使用到的分区工具有fdisk,parted,sfdisk

fdisk的命令包括p(显示),n(创建),d(删除),t(修改分区ID),l(列出所有支持的ID类型),d(保存并退出),q(放弃修改并退出),m(获取帮助)


3,后来讲到了Linux文件系统管理

Linux文件系统包括如下类型:ext2,ext3,ext4,reiserfs,xfs,btrfs,swap

windows:fat32(vfat),ntfs

光盘:iso9660

unix:ffs,ufs,jfs,jfs2

集群文件系统:nfs,cifs

分布式文件系统:ceph,moosefs,mogilefs,hdfs,gfs,glusterfs

swap:交换分区,日志型文件系统ext3和非日志型文件系统ext2


4,创建文件的工具mkfs

      mkfs -t type DEVICE

     ext系列文件系统的专用管理工具:

     mke2fs -t {ext2|ext3|ext4} DEVICE

                  -b (1024,2048,4096)

                  -L (设定卷标)


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

e2label, tune2fs, dumpe2fs

文件系统检测:fsck,e2fsck

6,文件系统的挂载和使用

挂载方法:
        mount:通过读取/etc/mtab文件来显示当前系统所有已经挂载的设备;
        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 -v MOUNT_POINT

            终止所有正在访问指定的挂载点的进程:
                # fuser -km MOUNT_POINT

    交换分区:

        free命令:
            查看memory和swap的使用状态
                -m: 以MB为单位
                -g: 以GB为单位

        mkswap:创建交换分区

            mkswap [option] DEVICE
                -L 'LABEL'    
                
        swapon:启用交换分区
            swapon [option] [DEVICE]
                -a: 激活所有交换分区
                -p PRIORITY: 设定其优先级;

        swapoff:禁用交换分区
            swapoff [option] [DEVICE]

    文件系统等空间占用信息的查看工个:
        df: disk free
            -h: human-readable
            -i: inode数量
            -P: 以Posix兼容的格式输出
        du: disk usage
            -h: human-readable
            -s: summary

    文件系统相关挂载配置文件:/etc/fstab

[root@localhost ~]# fdisk -l

Disk /dev/sda: 109.5 GB, 109521666048 bytes
255 heads, 63 sectors/track, 13315 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00054612

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        2637    20971520   83  Linux
/dev/sda3            2637        3032     3170304   82  Linux swap / Solaris

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@localhost ~]# fdisk /dev/sdb
Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x143ad7fd

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305):
Using default value 1305

Command (m for help):
Command (m for help):
Command (m for help):
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# fdisk -l

Disk /dev/sda: 109.5 GB, 109521666048 bytes
255 heads, 63 sectors/track, 13315 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00054612

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        2637    20971520   83  Linux
/dev/sda3            2637        3032     3170304   82  Linux swap / Solaris

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x143ad7fd

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1305    10482381   83  Linux
[root@localhost ~]# mkfs.ext4 /dev/sdb1 -L 'Andy'
[root@localhost ~]# mkdir /mydata
[root@localhost ~]# echo '/dev/sdb1              /mydata                    ext4    defaults        0 0' >> /etc/fstab
UUID=7eb01b70-0885-4120-aaad-8a91c9aa63a6 /                       ext4    defaults        1 1
UUID=cd2be255-6d9b-4aa5-af39-e1e9b9ca772b /boot                   ext4    defaults        1 2
UUID=43499873-a8ef-4725-9566-82d2b274e116 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sdb1              /mydata                    ext4    defaults        0 0
[root@localhost ~]# mount -a
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        20G  1.7G   17G  10% /
tmpfs           504M     0  504M   0% /dev/shm
/dev/sda1       190M   33M  147M  19% /boot
/dev/sdb1       9.8G   23M  9.2G   1% /mydata