一、挂载,卸载
挂载:将新的文件系统关联至当前根文件系统
卸载:将某文件系统与当前根文件系统的关联关系移除
cat /etc/mtab 存储着已经挂载的文件系统 (跟 mount 一样)
mount:显示当前系统已经挂载的设备及挂载点
mount [options] [-o options] DEVICE MOUNT_POINT 设备: 设备文件:/dev/sda5 卷标:LABEL="" UUID: UUID="" 挂载点:目录 要求: 1、此目录没有被其他进程使用; 2、目录得事先存在; 3、目录中的原有的文件将会暂时隐藏; 选项: -a:表示挂载/etc/fstab文件中定义的所有文件系统 -n:默认情况下,mount命令每挂载一个设备,都会把挂载的设备信息保存到/etc/mtab.加了-n就不写入/etc/mtab中 -r:以只读方式挂载 -w:以读写的方式挂载 -L:指明卷标 -U:用UUID挂载 -t:指明文件系统类型,默认通过blkid来识别指定 -o:指定挂载时候选项的内容 async All I/O to the filesystem should be done asynchronously. (See also the sync option.) atime Update inode access time for each access. See also the strictatime mount option. noatime Do not update inode access times on this filesystem (e.g, for faster access on the news spool to speed up news servers). auto Can be mounted with the -a option. noauto Can only be mounted explicitly (i.e., the -a option will not cause the filesystem to be mounted). context=context, fscontext=context, defcontext=context and rootcontext=context The context= option is useful when mounting filesystems that do not support extended attributes, such as a floppy or hard disk formatted with VFAT, or systems that are not nor- mally running under SELinux, such as an ext3 formatted disk from a non-SELinux workstation. You can also use context= on filesystems you do not trust, such as a floppy. It also helps in compatibility with xattr-supporting filesystems on earlier 2.4.<x> kernel versions. Even where xattrs are supported, you can save time not having to label every file by assigning the entire disk one security context. A commonly used option for removable media is context=system_u:object_r:removable_t. Two other options are fscontext= and defcontext=, both of which are mutually exclusive of the context option. This means you can use fscontext and defcontext with each other, but neither can be used with context. The fscontext= option works for all filesystems, regardless of their xattr support. The fscon- text option sets the overarching filesystem label to a specific security context. This filesystem label is separate from the individual labels on the files. It represents the entire filesystem for certain kinds of permission checks, such as during mount or file creation. Individual file labels are still obtained from the xattrs on the files themselves. The context option actually sets the aggregate context that fscontext provides, in addition to supplying the same label for individual files. You can set the default security context for unlabeled files using defcontext= option. This overrides the value set for unlabeled files in the policy and requires a filesystem that sup- ports xattr labeling. The rootcontext= option allows you to explicitly label the root inode of a FS being mounted before that FS or inode because visable to userspace. This was found to be useful for things like stateless linux. For more details, see selinux(8) defaults Use default options: rw, suid, dev, exec, auto, nouser, and async. dev Interpret character or block special devices on the filesystem. nodev Do not interpret character or block special devices on the file system. diratime Update directory inode access times on this filesystem. This is the default. nodiratime Do not update directory inode access times on this filesystem. dirsync All directory updates within the filesystem should be done synchronously. This affects the following system calls: creat, link, unlink, symlink, mkdir, rmdir, mknod and rename. exec Permit execution of binaries. noexec Do not allow direct execution of any binaries on the mounted filesystem. (Until recently it was possible to run binaries anyway using a command like /lib/ld*.so /mnt/binary. This trick fails since Linux 2.4.25 / 2.6.0.) group Allow an ordinary (i.e., non-root) user to mount the filesystem if one of his groups matches the group of the device. This option implies the options nosuid and nodev (unless overridden by subsequent options, as in the option line group,dev,suid). iversion Every time the inode is modified, the i_version field will be incremented. noiversion Do not increment the i_version inode field. mand Allow mandatory locks on this filesystem. See fcntl(2). All directory updates within the filesystem should be done synchronously. This affects the following system calls: creat, link, unlink, symlink, mkdir, rmdir, mknod and rename. nomand Do not allow mandatory locks on this filesystem. _netdev The filesystem resides on a device that requires network access (used to prevent the system from attempting to mount these filesystems until the network has been enabled on the system). nofail Do not report errors for this device if it does not exist. relatime Update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the current modify or change time. (Similar to noat- ime, but doesn’t break mutt or other applications that need to know if a file has been read since the last time it was modified.) norelatime Do not use relatime feature. See also the strictatime mount option. strictatime Allows to explicitly requesting full atime updates. This makes it possible for kernel to defaults to relatime or noatime but still allow userspace to override it. For more details about the default system mount options see /proc/mounts. nostrictatime Use the kernel’s default behaviour for inode access time updates. suid Allow set-user-identifier or set-group-identifier bits to take effect. nosuid Do not allow set-user-identifier or set-group-identifier bits to take effect. (This seems safe, but is in fact rather unsafe if you have suidperl(1) installed.) owner Allow an ordinary (i.e., non-root) user to mount the filesystem if he is the owner of the device. This option implies the options nosuid and nodev (unless overridden by subsequent options, as in the option line owner,dev,suid). remount 重新挂载 Attempt to remount an already-mounted filesystem. This is commonly used to change the mount flags for a filesystem, especially to make a readonly filesystem writeable. It does not change device or mount point.
df: report file system disk space usage
-h:以人类方便读取的方式显示
-T:显示文件系统类型
挂载完成之后,要通过挂载点来访问对应文件系统上的文件
umount:卸载文件系统(单参数命令)
umount 设备
umount 挂载点
-a:卸载/etc/mtab里所有的文件系统
卸载注意事项:
挂载的设备没有进程使用;
fuser -v 挂载点 :显示当前使用文件的进程信息
cat /etc/fstab
# # /etc/fstab # Created by anaconda on Mon May 11 05:49:57 2015 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=0f4c5b88-8b5e-4cdb-8c7a-3f1ef4757703 / ext4 defaults 1 1 UUID=436bfd28-bdc7-4103-97c8-6ad4cf70fa1a /boot ext4 defaults 1 2 UUID=d9ec093a-4023-4453-8576-46a02e58896c 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
第一列:设备(文件名,UUID,卷标)
第二列:挂载点
第三列:文件系统类型
第四列:设备选项
第五列:备份的频率(转储频率)0:不允许备份;1:允许备份
第六列:检测级别。0:不检测;1:优先检测;2:正常检测。一般情况下,只有根文件系统是1
swap:交换分区,没有挂载点
free 查看物理内存和交换空间的大小,使用率
-m 以兆为单位查看
buffers 缓冲区 :带宽高向带宽低传递数据;存放元数据
cached 缓存: 从带宽低里取数据;存放数据信息
正常情况下,交换分区的大小不小于512M,一般为物理内存的2倍
交换分区的ID为82
l 查看分区类型ID
t 82 转换为交换分区
mkswap 设备名:创建交换分区
swapon 设备名 启用交换空间
swapoff 设备名 关闭交换空间
dd:硬拷贝命令(直接在硬盘上进行数据拷贝,没有经过内存,二进制之间的协调复制) convert and copy a file bs=BYTES:一次读取和写入的字节数(单元大小) count=BLOCKS:单元数量 if=FILE:源文件 of=FILE:目标文件 dd if=/dev/sda of=/root/mbr.backup bs=512 count=1 (备份MBR)
MBR 主引导程序,硬盘的0柱面,0磁头,0扇区。总共512字节,其中446字节为主引导程序,64字节的分区表信息,剩下2字节为magic number
/dev/zero 泡泡设备
dd if=/dev/zero of=./swapfile bs=1M count=1024 mkswap swapfile
二、RAID
一些接口
IDE 电子集成化设备 133MBPS SATA:串行ATA 6Gbps USB (串行接口) 3.0:5Gbps 3.1:10Gbps SCSI(小型计算机系统接口):并行接口 640Mbps 支持热插拔 SAS(SCSI的串行技术)
RAID:Randundant Arry of Inexpensive Disks(廉价的冗余磁盘阵列)
Controller(控制器):集成
Adapter(适配器):独立
最大的区别:性能
显卡的处理器称为图形处理器(GPU),它是显卡的“心脏”
挑显卡挑GPU,位宽
核心显卡
英文原名Core graphics card,核心图形卡,意思是集成在核心中的显卡。
补充:集成显卡和独立显卡的区别:
所在位置不同:集成显卡是集成在CPU内或者主板上的,而独立显卡在单独的PCB电路板上。
搭载的显存大小不同:集成显卡没有单独的显存,需要共享系统的内存作为显存,而独立显卡有单独的显存。
RAID0带区卷
RAID1镜像卷
RAID5,容错的同时提高io效率。分布式校验信息存储系统
RAID6,比RAID5多一重校验,双重校验
RAID10,先做RAID1再做RAID0
RAID01
RAID51
BIOS是英文"Basic Input Output System"的缩略词,直译过来后中文名称就是"基本输入输出系统"。其实,它是一组固化到计算机内主板上一个ROM芯片上的程序,它保存着计算机最重要的基本输入输出的程序、开机后自检程序和系统自启动程序,它可从CMOS中读写系统设置的具体信息。 其主要功能是为计算机提供最底层的、最直接的硬件设置和控制。
硬件RAID
1.主板上要有RAID控制器
2.RAID适配器
软件RAID
md:Multi Disks
mdadm
模式化的管理工具
RAID设备名称必须是md#
JBOD:just a bunch of disks(类似windows里的跨区卷)
分区id修改为fd
mdadm: 将任何块设备做成RAID
模式化的命令:
mdadm [mode] <raiddevice> [options] <component-devices>
创建模式 -C 专用选项: -l #: 级别 -l 0 --level=raid0 -n #: 设备个数 -a {yes|no}: 是否自动为其创建设备文件 -c: CHUNK大小, 2^n,默认为512K(条带大小) -x #: 指定空闲盘个数 管理模式 -a|--add: 向RAID设备中添加分区,一般用于添加额外分区以便备用 -r|--remove: 从RAID设备中移除分区,一般用于移除失效的分区 -f|--fail: 设置使某RAID设备中的分区标记为失败 mdadm /dev/md# -a /dev/sde1 mdadm /dev/md# --fail /dev/sdd1 mdadm /dev/md# -r /dev/sdd1 装配模式: /etc/mdadm.conf -A 查询模式: -D 停止阵列(删除阵列): -S 配置文件管理: mdamd -D --scan > /etc/mdadm.conf
添加硬盘 echo " - - - " > /sys/class/scsi_host/host2/scan 创建分区 做RAID需要将分区id修改为fd : t 1 fd mdadm -C /dev/md0 -l 1 -n 2 /dev/sdb1 /dev/sdc1 y ls /dev/md* mke2fs -t ext4 /dev/md0 mkdir /mnt/md0 mount /dev/md0 /mnt/md0
df -hT blkid /dev/md0 tune2fs -l /dev/md0 看超级块信息 cat /proc/mdstat 查看RAID1信息 mdadm -D --scan 查看阵列信息 echo "this is a test information " > /mnt/md0/test fdisk /dev/sdd 再做一个分区 mdadm /dev/md0 -a /dev/sdd1 添加设备,成为空闲设备(s) cat /proc/mdstat 主设备0,从设备1 mdadm /dev/md0 -f /dev/sdc1 将设备标记为失败 cat /proc/mdstat 当设备损坏,空闲设备会补上,重新同步数据 mdadm /dev/md0 -r /dev/sdc1 移除失败的设备 后添加的设备成为空闲设备 mdadm -C /dev/md1 -l 1 -n 2 /dev/sdd1 /dev/sde1 y 做成RAID10 mdadm -C /dev/md0 -l 0 -n 2 -c 64 /dev/md1 /dev/md2 /dev/md0不能放到其他设备去 mke2fs -t ext4 -b 2048 -i 4096 -L "RAID10" /dev/md0 mount -t ext4 UUID="" /mnt/md0 RAID5至少需要三个设备 mdadm -D --scan /etc/mdadm.conf mdadm的专用配置文件 mdadm -D --scan > /etc/mdadm.conf 保存RAID配置文件 umount /dev/md0 mdadm -S /dev/md0 mdadm -S /dev/md1 mdadm -S /dev/md2 前提保存在配置文件中才能装配。注意装配顺序 mdadm -A /dev/md2 mdadm -A /dev/md1 mdadm -A /dev/md0
三、LVM
LVM:logical volume management 逻辑卷管理器
构成逻辑卷的物理存储设备叫做PV(物理卷)
包含物理卷的叫卷组VG(volume group)
逻辑卷由卷组构成
卷组上有个PE(物理盘区physical extent)的东西,决定逻辑卷的大小
PE默认4MB
逻辑卷叫LE(逻辑盘区)
LE和PE一一对应
逻辑卷管理
先创建物理设备
逻辑卷要做分区,必须改成8E
物理卷命令:
pvcreate 创建 pvcreate /dev/sd[bcde] pvdisplay 显示 pvmove 移动 pvremove 移除物理卷 pvscan 扫描物理卷 pvs 显示(比display简单)
卷组命令:
vgcreate -s 物理盘区大小 vgcreate VG_NAME PV_NAME PV_NAME... vgcreate vg1 /dev/sdb /dev/sdc vgdisplay vgextent 扩展卷组 vgreduce 将物理卷从卷组挪走
lvcreate
-L:指定逻辑卷的大小 -n:指定逻辑卷的名称 lvcreate -L LV_SIZE -n LV_NAME VG_NAME
物理边界 lvs
逻辑边界 df -hTP
若要扩展逻辑卷,先扩展物理边界,再扩展逻辑边界
逻辑边界不能超过物理边界
增大逻辑卷的物理边界的命令
lvextend -L [+]800M 逻辑卷路径
有+,表示增加800M
无+,表示增加到800M
resizee2fs -p 逻辑卷路径 刷新逻辑卷的逻辑边界
削减逻辑卷:
1.卸载逻辑卷 umount 2.减逻辑边界 e2fsck -f 逻辑卷路径 resize2fs 逻辑卷路径 逻辑边界大小 3.关闭逻辑卷 lvchange -an 逻辑卷路径 4.减物理边界 lvreduce -L [-]SIZE 逻辑卷路径 5.打开逻辑卷 lvchange -ay 逻辑卷路径 6.挂载逻辑卷 mount
快照逻辑卷
1.主要目的是为了备份数据,当数据被恢复之后,快照卷可以销毁 2.一般情况下,快照卷只读,不允许修改 3.快照卷默认于被快照的卷在同一卷组
lvcreate -L 快照逻辑卷大小 -s -p r -n 快照卷的名字 逻辑卷路径
例:lvcreate -L 32M -s -p r -n linksnap /dev/qhd/link