主要知识点: 基本分区、逻辑卷LVM、EXT3/4/XFS文件系统、RAID
从工作原理区分
机械HDD
固态SSD
SSD的优势
SSD是摒弃传统磁介质,采用电子存储介质进行数据存储和读取的一种技术,突破了传统机械硬盘的性能瓶颈, 拥有极高的存储性能,被认为是存储技术发展的未来新星。 固态硬盘的全集成电路化、无任何机械运动部件的革命性设计,从根本上解决了在移动办公环境下,对于数据读
写稳定性的需求。全集成电路化设计可以让固态硬盘 做成任何形状。与传统硬盘相比,SSD固态电子盘具有以下优点:
无结构限制,可根据实际情况设计成各种不同接口、形状的特殊电子硬盘。
硬盘尺寸
3.5寸 2.5寸 1.8寸
从插拔方式
热插拔
非热插拔
从硬盘接口
IDE —— SATA (Serial ATA)
SCSI —— SAS (Serial Attached SCSI) 即串行连接SCSI other —— PCIE FC
SAS(Serial Attached SCSI)即串行连接SCSI,是新一代的SCSI技术,和现在流行的Serial ATA(SATA)硬盘相同,
都是采用串行技术以获得更高的传输速度,并通过缩短连结线改善内部空间等。
硬盘设备命名
物理硬盘: /dev/sd[a-z]
KVM虚拟化:/dev/vd[a-z]
/dev/sd[a-z]
KVM增加硬盘
半虚拟化驱动磁盘: online
全虚拟化驱动磁盘: offline
HP服务器硬盘 /dev/cciss/c0d0 /dev/cciss/c0d0p1 //c0第一个控制器, d0第一块磁盘, p1分区1 /dev/cciss/c0d0p2 //c0第一个控制器, d0第一块磁盘, p2分区2
从存储连接方式
本地存储 例如DellR730本地磁盘
外部存储 scsi线 sata线 sas线 FC线
网络存储 以太网络(iscsi, glusterFS,ceph) FC网络
MBR <2TB 14个分区(4个主分区,扩展分区,逻辑分区) 例如: 3主 + 1扩展(n逻辑)
GPT >2TB 128个主分区 注意:从MBR转到GPT,或从GPT转换到MBR会导致数据全部丢失!
MBR:
==================================================
基本分区(MBR|GPT) ----> Filesystem ----> mount
[root@newrain ~]# ll /dev/vd*
brw-rw----. 1 root disk 253, 0 11月 30 15:02 /dev/vda
brw-rw----. 1 root disk 253, 1 11月 30 15:02 /dev/vda1
brw-rw----. 1 root disk 253, 16 11月 30 15:02 /dev/vdb
brw-rw----. 1 root disk 252, 32 11月 30 15:02 /dev/vdcT
[root@newrain ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 10G 0 disk
└─vda1 253:1 0 10G 0 part /
vdb 253:16 0 10G 0 disk
vdc 252:32 0 8G 0 disk
[root@newrain ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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
[root@newrain ~]# 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 0xf5f6a455.
Command (m for help): m
Command action
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)
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): #分区编号
First sector (2048-20971519, default 2048): #起始位置
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +100M
Partition 1 of type Linux and of size 100 MiB is set
Command (m for help): p #打印分区表
Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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: 0xf5f6a455
Device Boot Start End Blocks Id System
/dev/sdb1 2048 206847 102400 83 Linux
Command (m for help): w #将修改保存到磁盘
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@newrain ~]# yum install -y gdisk
[root@newrain ~]# gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
***************************************************************
Command (? for help): ?
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): n
Partition number (2-128, default 2):
First sector (34-20971486, default = 206848) or {+-}size{KMGTP}:
Last sector (206848-20971486, default = 20971486) or {+-}size{KMGTP}: +200M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.
[root@newrain ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 9G 0 part
├─centos-root 253:0 0 8G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
├─sdb1 8:17 0 100M 0 part
└─sdb2 8:18 0 200M 0 part
sr0 11:0 1 4.3G 0 rom
2.创建文件系统(格式化)centos7默认使用xfs
[root@newrain ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=6400 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=25600, 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
[root@newrain ~]# mkfs.ext4 /dev/sdb2
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33816576
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@newrain ~]# mkdir /mnt/data1 /mnt/data2
#手动挂载,不推荐
#[root@newrain ~]# mount /dev/sdb1 /mnt/data1
#[root@newrain ~]# mount /dev/sdb2 /mnt/data2
#自动挂载,永久挂载
[root@newrain ~]# blkid /dev/sdb1 /dev/sdb2
/dev/sdb1: UUID="c57f4a9f-07fa-4d54-b826-3d110d752cb2" TYPE="xfs" PARTLABEL="Linux filesystem" PARTUUID="16052086-21b5-4630-9ae0-6f9e32aa72e8"
/dev/sdb2: UUID="38ae8974-333b-40e0-9e0b-828f92326d7f" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="7c52bb47-cc9b-4969-9ab0-eda92182bc12"
[root@newrain ~]# vim /etc/fstab
UUID="c57f4a9f-07fa-4d54-b826-3d110d752cb2" /mnt/data1 xfs defaults 0 0
UUID="38ae8974-333b-40e0-9e0b-828f92326d7f" /mnt/data2 ext4 defaults 0 0
[root@newrain ~]# mount -a
[root@newrain ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 9G 0 part
├─centos-root 253:0 0 8G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
├─sdb1 8:17 0 100M 0 part /mnt/data1
└─sdb2 8:18 0 200M 0 part /mnt/data2
sr0 11:0 1 4.3G 0 rom
umount 设备名称|挂载点
[root@newrain ~]# umount /dev/sdb1 /dev/sdb2
5.查看磁盘挂载
[root@newrain ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 8.0G 1.4G 6.7G 18% /
devtmpfs devtmpfs 475M 0 475M 0% /dev
tmpfs tmpfs 487M 0 487M 0% /dev/shm
tmpfs tmpfs 487M 7.7M 479M 2% /run
tmpfs tmpfs 487M 0 487M 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 133M 882M 14% /boot
tmpfs tmpfs 98M 0 98M 0% /run/user/0
/dev/sdb1 xfs 97M 5.3M 92M 6% /mnt/data1
/dev/sdb2 ext4 190M 1.6M 175M 1% /mnt/data2
[root@newrain ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 10G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 9G 0 part
├─centos-root 253:0 0 8G 0 lvm /
└─centos-swap 253:1 0 1G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk
├─sdb1 8:17 0 100M 0 part /mnt/data1
└─sdb2 8:18 0 200M 0 part /mnt/data2
sr0 11:0 1 4.3G 0 rom