一、掛載,卸載
掛載:將新的文件系統關聯至當前根文件系統
卸載:將某文件系統與當前根文件系統的關聯關系移除
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