磁盘及文件系统管理应用实例

磁盘及文件系统管理应用实例

  • 1.创建一个10G的分区,并格式化为ext4文件系统

    • 要求其block大小为2048,预留空间百分比为2,卷标为MYDATA,默认挂载属性包含acl
    • 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳
[root@master ~]# fdisk /dev/sdb
    Command (m for help): n   
    Partition type:
      p   primary (0 primary, 0 extended, 4 free)
      e   extended
    Select (default p): p
    Partition number (1-4, default 1): 1
    First sector (2048-41943039, default 2048):
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +10G
    Partition 1 of type Linux and of size 10 GiB is set    
    Command (m for help): w
    The partition table has been altered!

    [root@master ~]# mke2fs -t ext4 -b 2048 -m 2 -L MYDATA  /dev/sdb1
    [root@master ~]# tune2fs -o acl /dev/sdb1

    [root@master ~]# mount -o noexec,noatime /dev/sdb1 /data/mydata
  • 2.创建一个大小为1G的swap分区,并创建好文件系统,并启用之,写一个脚本

    • 获取并列出当前系统上的所有磁盘设备
    • 显示每个磁盘设备上每个分区的相关的空间使用信息
[root@master ~]# fdisk /dev/sdb
    Command (m for help): n
    Partition type:
       p   primary (1 primary, 0 extended, 3 free)
       e   extended
    Select (default p): p
    Partition number (2-4, default 2): 2
    First sector (20973568-41943039, default 20973568):
    Using default value 20973568
    Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039): +1G
    Partition 2 of type Linux and of size 1 GiB is set
    Command (m for help): t
    Partition number (1,2, default 2): 2
    Hex code (type L to list all codes): L
    Hex code (type L to list all codes): 82
    Changed type of partition 'Linux' to 'Linux swap / Solaris'
    Command (m for help): w
    The partition table has been altered!

    [root@master ~]# mkswap -L SWAP /dev/sdb2
    [root@master ~]# swapon /dev/sdb2

    #!/bin/bash
    #
    disks=`fdisk -l|grep -o '^Disk /dev/[sh]d[a-z]'|cut -d' ' -f2`
    echo $disks
    for i in $disks;do
        fdisk -l $i
    done
  • 3.总结RAID的各个级别及其组合方式和性能的不同
    RAID(冗余磁盘阵列)是将多块磁盘当做一块物理磁盘来使用,以达到容错或者提高读写性能的优势。按照 组织起来的工作方式的不同,我们可以将RAID分为不同的级别,其中常见的有RAID0、RAID1、RAID5、RAID10

    • RAID0

      • 俗称条带卷,实现将文件分成多个chunk后同时并行存储到多个盘中。
      • 特性

        读写性能得到提升
        无冗余能力
        最少磁盘数为2
        可用空间为容量最小的磁盘*磁盘数
    • RAID1

      • 俗称镜像卷,在存储数据的同时需要再复制一份存入另一个磁盘中。
      • 特性

        读性能提升,写性能下降
        有冗余能力
        最少磁盘数为2,偶数
        可用空间小于1/2
    • RAID5

      • 将文件分成多个chunk,两两chunk之间作异或运算,各盘轮流存储校验码
      • 特点

        读写性能提升
        有冗余能力
        最少磁盘数为3
        可用空间为容量最小的磁盘*(磁盘数-1)
    • RAID10

      • 先两两做raid1,后将多组raid1组织成raid0
      • 特点

        读写性能提升
        有冗余能力
        最小磁盘数4
        可用空间为容量最小的磁盘*磁盘数/2
  • 4.创建一个大小为10G的RAID1,要求有一个空闲盘,而且chunk大小为128k

    [root@master ~]# fdisk /dev/sdb
      Command (m for help): n
      Partition type:
         p   primary (0 primary, 0 extended, 4 free)
         e   extended
      Select (default p): p
      Partition number (1-4, default 1): 1
      First sector (2048-104857599, default 2048):
      Using default value 2048
      Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +10G
      Partition 1 of type Linux and of size 10 GiB is set
      Command (m for help): n
      Partition type:
         p   primary (1 primary, 0 extended, 3 free)
         e   extended
      Select (default p): p
      Partition number (2-4, default 2): 2
      First sector (20973568-104857599, default 20973568): +10G
      Value out of range.
      First sector (20973568-104857599, default 20973568):
      Using default value 20973568
      Last sector, +sectors or +size{K,M,G} (20973568-104857599, default 104857599): +10G
      Partition 2 of type Linux and of size 10 GiB is set
      Command (m for help): n
      Partition type:
         p   primary (2 primary, 0 extended, 2 free)
         e   extended
      Select (default p): p
      Partition number (3,4, default 3): 3
      First sector (41945088-104857599, default 41945088):
      Using default value 41945088
      Last sector, +sectors or +size{K,M,G} (41945088-104857599, default 104857599): +10G
      Partition 3 of type Linux and of size 10 GiB is set
      Command (m for help): t
      Partition number (1-3, default 3): 1
      Hex code (type L to list all codes): fd
      Changed type of partition 'Linux' to 'Linux raid autodetect'
      Command (m for help): t
      Partition number (1-3, default 3): 2
      Hex code (type L to list all codes): fd
      Changed type of partition 'Linux' to 'Linux raid autodetect'
      Command (m for help): t
      Partition number (1-3, default 3): 3
      Hex code (type L to list all codes): fd
      Changed type of partition 'Linux' to 'Linux raid autodetect'
      Command (m for help): w
      The partition table has been altered!
    
      [root@master ~]# mdadm -C /dev/md0 -n 2 -c 128 -x 1 -l 1 -a yes /dev/sdb{1,2,3}
      mdadm: Defaulting to version 1.2 metadata
      mdadm: array /dev/md0 started.
  • 5.创建一个大小为4G的RAID5设备,chunk大小为256k,格式化ext4文件系统,要求可开机自动挂载至/backup目录,且不更新访问时间戳,且支持acl功能
    “`

    [root@master ~]# fdisk /dev/sdb
      Command (m for help): n
      All primary partitions are in use
      Adding logical partition 5
      First sector (62918656-104857599, default 62918656):
      Using default value 62918656
      Last sector, +sectors or +size{K,M,G} (62918656-104857599, default 104857599): +2G
      Partition 5 of type Linux and of size 2 GiB is set
      Command (m for help): n
      All primary partitions are in use
      Adding logical partition 6
      First sector (67115008-104857599, default 67115008):
      Using default value 67115008
      Last sector, +sectors or +size{K,M,G} (67115008-104857599, default 104857599): +2G
      Partition 6 of type Linux and of size 2 GiB is set
      Command (m for help): n
      All primary partitions are in use
      Adding logical partition 7
      First sector (71311360-104857599, default 71311360):
      Using default value 71311360
      Last sector, +sectors or +size{K,M,G} (71311360-104857599, default 104857599): +2G
      Partition 7 of type Linux and of size 2 GiB is set
      Command (m for help): w
      The partition table has been altered!
    
      [root@master ~]# mdadm -C /dev/md1 -n 3 -c 256  -l 5 -a yes /dev/sdb{5,6,7}
      mdadm: Defaulting to version 1.2 metadata
      mdadm: array /dev/md1 started.
    
      [root@master ~]# mke2fs -t ext4  /dev/md1
      [root@master ~]# mkdir /backup
      [root@master ~]# mount -o auto /dev/md1 /backup

原创文章,作者:N27_xiaoni,如若转载,请注明出处:http://www.178linux.com/84386

(0)
N27_xiaoniN27_xiaoni
上一篇 2017-08-14 09:52
下一篇 2017-08-14 09:54

相关推荐

  • vsftpd虚拟用户搭建

    首选的FTP服务器搭建方式 安装vsftpd      yum install -y vsftpd      systemctl enable vsftpd     #设置开机启动      systemctl is-enabled vsf…

    Linux干货 2017-04-27
  • 源码编译nginx和Nginx的特性,配置文件指令说明

    nginx的官方站点 www.nginx.org Nginx:engine X Tenginx:Taobao enginx libevent:高性能的网络库 epoll(); Nginx特性  模块化设计,较好扩展性:但不支持模块的动态装卸载;Tenginx支持;  高可靠性   master –> …

    Linux干货 2017-04-30
  • bash基础特性(一)之命令历史,命令补存,路劲补存,命令行展开,命令执行状态结果和引用

    bash是Unix shell的一种,在1987年由布莱恩·福克斯为了GNU计划而编写。1989年发布第一个正式版本,原先是计划用在GNU操作系统上,但能运行于大多数类Unix系统的操作系统之上,包括Linux与Mac OS X v10.4都将它作为默认shell。 Bourne shell是一个早期的重要shell,由史蒂夫·伯恩在1978年前后编写,并同…

    2017-09-20
  • 网络总结

    linux 网络配置 linux的网络服务是由内核提供。 网卡在内核看来就是个设备,各种网络配置不在网卡上。各种配置都是针相应网络管理程序使用的。 不同发行版的网络管理工具也是不一样(net-tools/iproute)。网络服务的管理程序(守护进程)也是不一样(脚本/程序)。 网络管理工具是将用户的设定直接传递给内核的网络服务,及时有效。 很多管理工具可以…

    Linux干货 2016-09-09
  • 洞悉find中的德摩根定律和条件权限perm

    1.德摩根定律 (1)初悉德摩根定律儿 在命题逻辑和逻辑代数中,德·摩根定律(或称德·摩根定理)是关于命题逻辑规律的一对法则。 奥古斯塔斯·德·摩根首先发现了在命题逻辑中存在着下面这些关系: 非(A 且 B) = (非 A) 或 (非 B)非(A 或 B)&n…

    Linux干货 2016-08-16
  • sed行编辑器与vim编辑器

    一、sed行编辑器   1、简介:sed的本身也是一个管道命令,可以分析标准输入,还可以将数据进行替换、删除、新增、选取特定行的功能   2、工作原理:sed是一种流编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”( pattern space),接着用sed命令处理缓冲区中的内容…

    Linux干货 2016-08-11

评论列表(1条)

  • 马哥教育
    马哥教育 2017-08-20 19:11

    磁盘的管理直接关乎到数据的安全性,所以务必掌握扎实。再接再励 。