学习linux6

直播学习

.扩展知识: 磁盘坏道的修复 fsck/e2fsck -a分区名
[https://www.2cto.com/os/201204/126370.html]

避免数据丢失的几个策略
1)做raid1 raid10 raid5 raid6
2) 做好数据备份策略 drdb rsync+inotify

.raid磁盘阵列学习
https://blog.csdn.net/caipeichao2/article/details/52661825
常用的是raid0 raid1 raid5

dd工具的使用场景
dd命令用来测试硬盘的读写性能

测试写入速度: dd if=/dev/zero of=/fdfs1/daiyu/test1.dbf bs=8k count=400000
(默认"写缓存"启作用)
dd if=/dev/zero of=/fdfs1/daiyu/test2.dbf bs=8k count=400000 conv=fsync
dd if=/dev/zero of=/fdfs1/daiyu/test3.dbf bs=8k count=400000 conv=fdatasync
测试读取速度:
dd> if=/fdfs1/daiyu/test1.dbf of=/dev/null

https://blog.csdn.net/daiyudong2020/article/details/53157558
备份硬盘数据 http://zuyunfei.com/2015/06/04/linux-dd/

lvm的使用场景介绍 OSS 七牛
阿里云磁盘扩容文档 https://help.aliyun.com/document_detail/25452.html

parted分区gpt格式
http://www.apelearn.com/bbs/thread-7243-1-1.html
parted /dev/sdb
print
mklabel gpt 或者 msdos (msdos就是mbr)
mkfs aming1 0 2G //当使用mbr类型时,这里就不能写aming1了,得写primary/extended/logical
rm id

关于存储的常识 DAS SAN NAS
http://forum.huawei.com/enterprise/zh/thread-274145-1-1.html
https://blog.csdn.net/JesseYoung/article/details/38367217

学习任务

4.1df命令

用df命令查看磁盘信息

[root@qklinux-01 ~]# df
文件系统          1K-块    已用     可用 已用% 挂载点
/dev/sda3      29140072 1127120 28012952    4% /
devtmpfs         491940       0   491940    0% /dev
tmpfs            502812       0   502812    0% /dev/shm
tmpfs            502812    7596   495216    2% /run
tmpfs            502812       0   502812    0% /sys/fs/cgroup
/dev/sda1        201380  106808    94572   54% /boot
tmpfs            100564       0   100564    0% /run/user/0

df –h 显示单位

[root@qklinux-01 ~]# df -h
文件系统        容量  已用  可用 已用% 挂载点
/dev/sda3        28G  1.1G   27G    4% /
devtmpfs        481M     0  481M    0% /dev
tmpfs           492M     0  492M    0% /dev/shm
tmpfs           492M  7.5M  484M    2% /run
tmpfs           492M     0  492M    0% /sys/fs/cgroup
/dev/sda1       197M  105M   93M   54% /boot
tmpfs            99M     0   99M    0% /run/user/0

free 查看swap分区

[root@qklinux-01 ~]# free
              total        used        free      shared  buff/cache   available
Mem:        1005628      131652      726020        7628      147956      708668
Swap:       2097148           0     2097148

df –i查看inode状态 如果inode状态100%即使磁盘还有空间也写不进去数据

[root@qklinux-01 ~]# df -i
文件系统          Inode 已用(I)  可用(I) 已用(I)% 挂载点
/dev/sda3      14577152   27605 14549547       1% /
devtmpfs         122985     381   122604       1% /dev
tmpfs            125703       1   125702       1% /dev/shm
tmpfs            125703     656   125047       1% /run
tmpfs            125703      16   125687       1% /sys/fs/cgroup

/dev/sda1        102400     326   102074       1% /boot
tmpfs            125703       1   125702       1% /run/user/0

df –m以MB为单位显示

[root@qklinux-01 ~]# df -m
文件系统       1M-块  已用  可用 已用% 挂载点
/dev/sda3      28458  1101 27357    4% /
devtmpfs         481     0   481    0% /dev
tmpfs            492     0   492    0% /dev/shm
tmpfs            492     8   484    2% /run
tmpfs            492     0   492    0% /sys/fs/cgroup
/dev/sda1        197   105    93   54% /boot
tmpfs             99     0    99    0% /run/user/0

4.2 du命令

du命令是用来查看文件或目录大小

[root@qklinux-01 ~]# du /etc/passwd
4	/etc/passwd
[root@qklinux-01 ~]# du /root/
8	/root/.ssh
0	/root/123
0	/root/234/am
0	/root/234/am1
0	/root/234
0	/root/111/222
8	/root/111
0	/root/qkai2
88	/root/

du –a 把文件和目录大小都列出
-b 列出以B为单位
-k 以kb为单位
-m以MB单位
-h 表示系统自动调节单位,小于4KB以4KB显示
-s 表示只列出总和

[root@qklinux-01 ~]# du -a /root/123
0	/root/123/qkai3
0	/root/123
[root@qklinux-01 ~]# du -a /root/.ssh
4	/root/.ssh/known_hosts
4	/root/.ssh/authorized_keys
8	/root/.ssh
[root@qklinux-01 ~]# du -b /root/.ssh
1003	/root/.ssh
[root@qklinux-01 ~]# du -k /root/.ssh
8	/root/.ssh
[root@qklinux-01 ~]# du -m /root/.ssh
1	/root/.ssh
[root@qklinux-01 ~]# du -h /root/.ssh
8.0K	/root/.ssh
[root@qklinux-01 ~]# du -s /root/.ssh
8	/root/.ssh

4.3-4.4 磁盘分区

在虚拟机—编辑虚拟机设置—硬盘—添加—再添加硬件向导中保持默认–指定磁盘容量设置硬盘大小—选择将虚拟磁盘虚伪单个文件

在这里插入图片描述

在这里插入图片描述
fdisk 命令查看硬盘 -l选项列出系统中的磁盘

[root@qklinux-01 ~]# fdisk -l
磁盘 /dev/sda:32.2 GB, 32212254720 字节,62914560 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000e5271

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648     4605951     2097152   82  Linux swap / Solaris
/dev/sda3         4605952    62914559    29154304   83  Linux

磁盘 /dev/sdb:10.7 GB, 10737418240 字节,20971520 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

磁盘分区

[root@qklinux-01 ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0x83b39450 创建新的 DOS 磁盘标签。

命令(输入 m 获取帮助):m
命令操作
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

常用的命令选项参数
n 新建分区 p列出分区信息 w保存 d删除分区

命令(输入 m 获取帮助):n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
分区号 (1-4,默认 1):1                //创建主分区1为2g
起始 扇区 (2048-20971519,默认为 2048)&#
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值