Linux day12

查询磁盘信息

  定义:Linux系统中磁盘管理就是将硬盘通过挂载的方式挂载到linux文件系统中

        1.使用df命令查看磁盘容量,不加参数则以k为单位
            1.df -i  查看inode的使用情况
            2.df -h  以G或T或M的人性化方式显示
            3.df -T  查看磁盘分区类型(文件系统类型)

            使用df -h 命令查看磁盘,下面分别介绍每列什么含义
            [root@JYC ~]# df -h
            Filesystem               Size  Used Avail Use% Mounted on
            devtmpfs                 475M     0  475M   0% /dev
            tmpfs                    487M     0  487M   0% /dev/shm
            tmpfs                    487M  7.5M  479M   2% /run
            tmpfs                    487M     0  487M   0% /sys/fs/cgroup
            /dev/mapper/centos-root  100G  2.6G   97G   3% /
            /dev/sda1                509M  131M  378M  26% /boot
            tmpfs                     98M     0   98M   0% /run/user/0

        2.使用lsblk查看磁盘分区情况
            1.[root@JYC ~]# lsblk
                NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
                sda               8:0    0  100G  0 disk 
                ├─sda1            8:1    0  512M  0 part /boot
                └─sda2            8:2    0 99.5G  0 part 
                  └─centos-root 253:0    0 99.5G  0 lvm  /
                sdb               8:16   0  100G  0 disk 
                sr0              11:0    1  4.4G  0 rom  

        3.使用du查看目录或者文件的容量,不加参数则以k为单位
            1.du -sh  人性化输出显示大小
            2.du -s   列出总和
            3.du -h   人性化显示容量信息
            [root@JYC ~]# du -sh /etc
            33M    /etc

        4.显示当前磁盘的读写速度
            1.iotop  显示磁盘的读写
            2.iotop -o 只显示在读写的进程
            3.dd if=/dev/zero of=/tmp/big bs=1k count=100000  该命令可用来测速

磁盘分区和挂载

        1.磁盘分区命令
            1.fdisk   支持mbr分区格式,2tb以内磁盘
            2.gdisk   支持mbr,gpt
            3.parted  fdisk升级版(仅支持gpt格式)

        2.fdisk
            1.参看磁盘分区信息
                fdisk -l

            2.用fdisk进行分区
                fdisk /dev/sdb
                [root@JYC ~]# fdisk /dev/sdb
                Welcome to fdisk (util-linux 2.23.2).

               # 你当前的修改都保存在内存中,知道你决定保存他们
                Changes will remain in memory only, until you decide to write them.
                Be careful before using the write command.

                # 磁盘当前没有磁盘分区列表
                Device does not contain a recognized partition table
                Building a new DOS disklabel with disk identifier 0xbcb9ea13.
                Command (m for help):

                # 一些常用命令
                   n   new 创建磁盘分区 partition(分区)
                   p   print 显示分区信息
                   d   delete 删除磁盘分区
                   q   退出不保存
                   w   保存并退出

                # 创建一个磁盘分区
                Command (m for help): p
                Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
                Units = sectors of 1 * 512 = 512 bytes
                Sector size (logical/physical): 512 bytes / 512 bytes
                I/O size (minimum/optimal): 512 bytes / 512 bytes
                Disk label type: dos
                Disk identifier: 0xbcb9ea13

                   Device Boot      Start         End      Blocks   Id  System

                Command (m for help): n
                Partition type:
                   p   primary(主分区) (0 primary, 0 extended, 4 free)
                   e   extended(扩展分区)

                Select (default p): 
                Using default response p
                Partition number (1-4, default 1): 
                First sector (2048-209715199, default 2048): 
                Using default value 2048
                Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): +200M 
                Partition 1 of type Linux and of size 200 MiB is set

                Command (m for help): P
                Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
                Units = sectors of 1 * 512 = 512 bytes
                Sector size (logical/physical): 512 bytes / 512 bytes
                I/O size (minimum/optimal): 512 bytes / 512 bytes
                Disk label type: dos
                Disk identifier: 0xbcb9ea13

                   Device Boot      Start         End      Blocks   Id  System
                /dev/sdb1            2048      411647      204800   83  Linux

                Command (m for help): w  
                The partition table has been altered!
                Calling ioctl() to re-read partition table.
                Syncing disks.

        注:期间若有输入错误需要取消则 ctrl+u 

        3.格式化文件系统
            mkfs.xfs /dev/sdb1
            [root@JYC ~]# mkfs.xfs /dev/sdb1
            meta-data=/dev/sdb1              isize=512    agcount=4, agsize=12800 blks
                     =                       sectsz=512   attr=2, projid32bit=1
                     =                       crc=1        finobt=0, sparse=0
            data     =                       bsize=4096   blocks=51200, imaxpct=25
                     =                       sunit=0      swidth=0 blks
            naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
            log      =internal log           bsize=4096   blocks=855, version=2
                     =                       sectsz=512   sunit=0 blks, lazy-count=1
            realtime =none                   extsz=4096   blocks=0, rtextents=0

        4.挂载
            mount /dev/sdb1 /mnt
            [root@JYC ~]# mount /dev/sdb1 /mnt
            [root@JYC ~]# lsblk
            NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
            sda               8:0    0  100G  0 disk 
            ├─sda1            8:1    0  512M  0 part /boot
            └─sda2            8:2    0 99.5G  0 part 
              └─centos-root 253:0    0 99.5G  0 lvm  /
            sdb               8:16   0  100G  0 disk 
            └─sdb1            8:17   0  200M  0 part /mnt
            sr0              11:0    1  4.4G  0 rom  

查询磁盘信息

        定义:Linux系统中磁盘管理就是将硬盘通过挂载的方式挂载到linux文件系统中

        1.使用df命令查看磁盘容量,不加参数则以k为单位
            1.df -i  查看inode的使用情况
            2.df -h  以G或T或M的人性化方式显示
            3.df -T  查看磁盘分区类型(文件系统类型)

            使用df -h 命令查看磁盘,下面分别介绍每列什么含义
            [root@JYC ~]# df -h
            Filesystem               Size  Used Avail Use% Mounted on
            devtmpfs                 475M     0  475M   0% /dev
            tmpfs                    487M     0  487M   0% /dev/shm
            tmpfs                    487M  7.5M  479M   2% /run
            tmpfs                    487M     0  487M   0% /sys/fs/cgroup
            /dev/mapper/centos-root  100G  2.6G   97G   3% /
            /dev/sda1                509M  131M  378M  26% /boot
            tmpfs                     98M     0   98M   0% /run/user/0

        2.使用lsblk查看磁盘分区情况
            1.[root@JYC ~]# lsblk
                NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
                sda               8:0    0  100G  0 disk 
                ├─sda1            8:1    0  512M  0 part /boot
                └─sda2            8:2    0 99.5G  0 part 
                  └─centos-root 253:0    0 99.5G  0 lvm  /
                sdb               8:16   0  100G  0 disk 
                sr0              11:0    1  4.4G  0 rom  

        3.使用du查看目录或者文件的容量,不加参数则以k为单位
            1.du -sh  人性化输出显示大小
            2.du -s   列出总和
            3.du -h   人性化显示容量信息
            [root@JYC ~]# du -sh /etc
            33M	/etc

        4.显示当前磁盘的读写速度
            1.iotop  显示磁盘的读写
            2.iotop -o 只显示在读写的进程
            3.dd if=/dev/zero of=/tmp/big bs=1k count=100000  该命令可用来测速

Linux day12

磁盘分区和挂载

        1.磁盘分区命令
            1.fdisk   支持mbr分区格式,2tb以内磁盘
            2.gdisk   支持mbr,gpt
            3.parted  fdisk升级版(仅支持gpt格式)

        2.fdisk
            1.参看磁盘分区信息
                fdisk -l

            2.用fdisk进行分区
                fdisk /dev/sdb
                [root@JYC ~]# fdisk /dev/sdb
                Welcome to fdisk (util-linux 2.23.2).

               # 你当前的修改都保存在内存中,知道你决定保存他们
                Changes will remain in memory only, until you decide to write them.
                Be careful before using the write command.

                # 磁盘当前没有磁盘分区列表
                Device does not contain a recognized partition table
                Building a new DOS disklabel with disk identifier 0xbcb9ea13.
                Command (m for help):

                # 一些常用命令
                   n   new 创建磁盘分区 partition(分区)
                   p   print 显示分区信息
                   d   delete 删除磁盘分区
                   q   退出不保存
                   w   保存并退出

                # 创建一个磁盘分区
                Command (m for help): p
                Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
                Units = sectors of 1 * 512 = 512 bytes
                Sector size (logical/physical): 512 bytes / 512 bytes
                I/O size (minimum/optimal): 512 bytes / 512 bytes
                Disk label type: dos
                Disk identifier: 0xbcb9ea13

                   Device Boot      Start         End      Blocks   Id  System

                Command (m for help): n
                Partition type:
                   p   primary(主分区) (0 primary, 0 extended, 4 free)
                   e   extended(扩展分区)

                Select (default p): 
                Using default response p
                Partition number (1-4, default 1): 
                First sector (2048-209715199, default 2048): 
                Using default value 2048
                Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): +200M 
                Partition 1 of type Linux and of size 200 MiB is set

                Command (m for help): P
                Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
                Units = sectors of 1 * 512 = 512 bytes
                Sector size (logical/physical): 512 bytes / 512 bytes
                I/O size (minimum/optimal): 512 bytes / 512 bytes
                Disk label type: dos
                Disk identifier: 0xbcb9ea13

                   Device Boot      Start         End      Blocks   Id  System
                /dev/sdb1            2048      411647      204800   83  Linux

                Command (m for help): w  
                The partition table has been altered!
                Calling ioctl() to re-read partition table.
                Syncing disks.

        注:期间若有输入错误需要取消则 ctrl+u 

        3.格式化文件系统
            mkfs.xfs /dev/sdb1
            [root@JYC ~]# mkfs.xfs /dev/sdb1
            meta-data=/dev/sdb1              isize=512    agcount=4, agsize=12800 blks
                     =                       sectsz=512   attr=2, projid32bit=1
                     =                       crc=1        finobt=0, sparse=0
            data     =                       bsize=4096   blocks=51200, imaxpct=25
                     =                       sunit=0      swidth=0 blks
            naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
            log      =internal log           bsize=4096   blocks=855, version=2
                     =                       sectsz=512   sunit=0 blks, lazy-count=1
            realtime =none                   extsz=4096   blocks=0, rtextents=0

        4.挂载
            mount /dev/sdb1 /mnt
            [root@JYC ~]# mount /dev/sdb1 /mnt
            [root@JYC ~]# lsblk
            NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
            sda               8:0    0  100G  0 disk 
            ├─sda1            8:1    0  512M  0 part /boot
            └─sda2            8:2    0 99.5G  0 part 
              └─centos-root 253:0    0 99.5G  0 lvm  /
            sdb               8:16   0  100G  0 disk 
            └─sdb1            8:17   0  200M  0 part /mnt
            sr0              11:0    1  4.4G  0 rom  
上一篇:voa start


下一篇:使用koa2写一个简易接口