day19-磁盘管理2

使用gdisk分配超过2TB的磁盘

  • fdisk测试4TB分区
#添加了一快4TB的硬盘sdb,fdisk只支持2TB以下的分区 -----------查看sdb----------- [root@localhost ~]# lsblk NAMEMAJ:MIN RMSIZE RO TYPE MOUNTPOINT sdb8:1604T0 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: pprimary (0 primary, 0 extended, 4 free) eextended 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 setCommand (m for help): w The partition table has been altered!Calling ioctl() to re-read partition table. Syncing disks.-----------查看分区后只创建2TB----------- [root@localhost ~]# lsblk NAMEMAJ:MIN RMSIZE RO TYPE MOUNTPOINT sda8:0020G0 disk ├─sda18:101G0 part /boot ├─sda28:20800M0 part [SWAP] └─sda38:30 18.2G0 part / sdb8:1604T0 disk └─sdb18:1702T0 part sr011:014.3G0 rom

  • gdisk
[root@localhost ~]# gdisk /dev/sdb GPT fdisk (gdisk) version 0.8.10Partition table scan: MBR: protective BSD: not present APM: not present GPT: presentFound valid GPT with protective MBR; using GPT.Command (? for help): GPT bback up GPT data to a file cchange a partition's name ddelete a partition ishow detailed information on a partition llist known partition types nadd a new partition ocreate a new empty GUID partition table (GPT) pprint the partition table qquit without saving changes rrecovery and transformation options (experts only) ssort partitions tchange a partition's type code vverify disk wwrite table to disk and exit xextra functionality (experts only) ?print this menuCommand (? 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): wFinal 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 NAMEMAJ:MIN RMSIZE RO TYPE MOUNTPOINT sda8:0020G0 disk ├─sda18:101G0 part /boot ├─sda28:20800M0 part [SWAP] └─sda38:30 18.2G0 part / sdb8:1604T0 disk └─sdb18:1704T0 part sr011:014.3G0 rom----------格式化----------- [root@localhost ~]# mkfs.xfs /dev/sdb1 meta-data=https://www.it610.com/dev/sdb1isize=512agcount=4, agsize=268435391 blks =sectsz=512attr=2, projid32bit=1 =crc=1finobt=0, sparse=0 data=bsize=4096blocks=1073741563, imaxpct=5 =sunit=0swidth=0 blks naming=version 2bsize=4096ascii-ci=0 ftype=1 log=internal logbsize=4096blocks=521728, version=2 =sectsz=512sunit=0 blks, lazy-count=1 realtime =noneextsz=4096blocks=0, rtextents=0

mount挂载磁盘
[root@localhost ~]# mkdir /sdb1#根目录下创建一个挂载点目录 [root@localhost ~]# mount /dev/sdb1 /sdb1 [root@localhost ~]# lsblk NAMEMAJ:MIN RMSIZE RO TYPE MOUNTPOINT sda8:0020G0 disk ├─sda18:101G0 part /boot ├─sda28:20800M0 part [SWAP] └─sda38:30 18.2G0 part / sdb8:1604T0 disk └─sdb18:1704T0 part /sdb1 sr011:014.3G0 rom-----------查看挂载信息----------- [root@localhost ~]# df -h FilesystemSizeUsed Avail Use% Mounted on /dev/sda319G1.7G17G10% / devtmpfs224M0224M0% /dev tmpfs235M0235M0% /dev/shm tmpfs235M5.6M229M3% /run tmpfs235M0235M0% /sys/fs/cgroup /dev/sda11014M155M860M16% /boot tmpfs47M047M0% /run/user/0 /dev/sdb14.0T33M4.0T1% /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"

day19-磁盘管理2
文章图片
把UUID写入到/etc/fstab中 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

【day19-磁盘管理2】4.代表关闭所有的swap
[root@xuliangwei ~]# swapoff -a

磁盘阵列RAID 1.什么是磁盘阵列
提高磁盘的整体读写能力,和冗余能力,通常我们将其称为磁盘阵列。
2.RAID
  • 提高性能
  • 保证安全
3.RAID模式
RAID0
  • 多磁盘数据分组同步写读
  • 无数据备份功能,安全性差
  • 理论读写速度是单盘读写速度的X倍,X指加入到同一阵列的磁盘数。同时容量也为单盘容量的X倍
  • 没有数据冗余,没有数据校验的磁盘陈列。实现RAID 0至少需要两块以上的硬盘,它将两块以上的硬盘合并成一块,数据连续地分割在每块盘上。 因为带宽加倍,所以读/写速度加倍
day19-磁盘管理2
文章图片
RAID0 RAID1
  • 多磁盘同数据同步写读
  • 盘间是相互备份的,安全性高
  • 读写速度与单盘相同,容量为单盘的容量
  • 可以提高读取性能。RAID 1是磁盘阵列中单位成本最高的,但提供了很高的数据安全性和可用性。当一个磁盘失效时,系统可以自动切换到镜像磁盘上读写,而不需要重组失效的数据

    day19-磁盘管理2
    文章图片
    RAID1
RAID5
  • 读写性能都高
  • 通过存放校验信息来保证数据恢复
  • 允许坏一块盘
  • 容量 n-1 * 单盘容量

    day19-磁盘管理2
    文章图片
    RAID5
PS:制作RIAD时必须准备热备份,不然备份无效

    推荐阅读