使用gdisk分配超过2TB的磁盘
- fdisk测试4TB分区
#添加了一快4TB的硬盘sdb,fdisk只支持2TB以下的分区
-----------查看sdb-----------
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 4T 0 disk
-----------使用fdisk测试分区4TB-----------
[root@localhost ~]# 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 0x370b60d3.
WARNING: The size of this disk is 4.4 TB (4398046511104 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).
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-4294967295, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4294967294, default 4294967294):
Using default value 4294967294
Partition 1 of type Linux and of size 2 TiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
-----------查看分区后只创建2TB-----------
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 800M 0 part [SWAP]
└─sda3 8:3 0 18.2G 0 part /
sdb 8:16 0 4T 0 disk
└─sdb1 8:17 0 2T 0 part
sr0 11:0 1 4.3G 0 rom
- gdisk
[root@localhost ~]# gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): GPT
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 (1-128, default 1):
First sector (34-8589934558, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-8589934558, default = 8589934558) or {+-}size{KMGTP}:
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.
-----------gdisk分区4TB完成-----------
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 800M 0 part [SWAP]
└─sda3 8:3 0 18.2G 0 part /
sdb 8:16 0 4T 0 disk
└─sdb1 8:17 0 4T 0 part
sr0 11:0 1 4.3G 0 rom
----------格式化-----------
[root@localhost ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=268435391 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=1073741563, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=521728, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
mount挂载磁盘
[root@localhost ~]# mkdir /sdb1 #根目录下创建一个挂载点目录
[root@localhost ~]# mount /dev/sdb1 /sdb1
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 800M 0 part [SWAP]
└─sda3 8:3 0 18.2G 0 part /
sdb 8:16 0 4T 0 disk
└─sdb1 8:17 0 4T 0 part /sdb1
sr0 11:0 1 4.3G 0 rom
-----------查看挂载信息-----------
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 19G 1.7G 17G 10% /
devtmpfs 224M 0 224M 0% /dev
tmpfs 235M 0 235M 0% /dev/shm
tmpfs 235M 5.6M 229M 3% /run
tmpfs 235M 0 235M 0% /sys/fs/cgroup
/dev/sda1 1014M 155M 860M 16% /boot
tmpfs 47M 0 47M 0% /run/user/0
/dev/sdb1 4.0T 33M 4.0T 1% /sdb1
---------------永久挂载盘-------------
[root@localhost ~]# blkid
/dev/sda1: UUID="5e27e765-4857-4111-9a25-c246abbf160a" TYPE="xfs"
/dev/sda2: UUID="402a620c-dacf-482b-a5d7-b504d200c03f" TYPE="swap"
/dev/sda3: UUID="a25d0506-0f08-4ab4-b841-a25453089710" TYPE="xfs"
/dev/sdb1: UUID="be19088b-4cd5-4e72-a032-079b5276f48f" TYPE="xfs" PARTLABEL="Linux filesystem" PARTUUID="f95cecbb-59ba-4a99-aad0-79de3e25be97"
/dev/sr0: UUID="2018-11-25-23-54-16-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
1./etc/fstab配置文件编写格式
要挂载的设备 | 挂载点 | 设备类型 | 挂载参数 | 是否备份 | 是否检查 |
---|---|---|---|---|---|
UUID="29ae40fb-93f4-4d87-b1e7-83cdd5946fc6" | /sdc2 | xfs | defaults | 0 | 0 |
2.加载fstab配置文件, 同时检测语法是否有错误
#没提示表示成功
[root@localhost ~]# mount -a
PS:在不知分区是否自动挂载成功后不要重启,会导致不能开机
swap交换分区
1.创建分区,并格式化为swap分区
#分S出一个分区为1G
[root@localhosts ~]# fdisk /dev/sdb
#格式化为swap
[root@localhosts ~]# mkswap /dev/sdb1
2.扩展swap分区大小
[root@localhosts ~]# swapon /dev/sdb2
3.缩小swap分区大小
[root@xlocalhosts ~]# swapoff /dev/sdb1
4.代表关闭所有的swap
[root@xuliangwei ~]# swapoff -a
磁盘阵列RAID
1.什么是磁盘阵列
提高磁盘的整体读写能力,和冗余能力,通常我们将其称为磁盘阵列。
2.RAID
- 提高性能
- 保证安全
3.RAID模式
RAID0
- 多磁盘数据分组同步写读
- 无数据备份功能,安全性差
- 理论读写速度是单盘读写速度的X倍,X指加入到同一阵列的磁盘数。同时容量也为单盘容量的X倍
- 没有数据冗余,没有数据校验的磁盘陈列。实现RAID 0至少需要两块以上的硬盘,它将两块以上的硬盘合并成一块,数据连续地分割在每块盘上。 因为带宽加倍,所以读/写速度加倍
RAID1
- 多磁盘同数据同步写读
- 盘间是相互备份的,安全性高
- 读写速度与单盘相同,容量为单盘的容量
-
可以提高读取性能。RAID 1是磁盘阵列中单位成本最高的,但提供了很高的数据安全性和可用性。当一个磁盘失效时,系统可以自动切换到镜像磁盘上读写,而不需要重组失效的数据
RAID5
- 读写性能都高
- 通过存放校验信息来保证数据恢复
- 允许坏一块盘
-
容量 n-1 * 单盘容量