代码改变世界

RAID5存储上parted进行分期及UUID对应关系

2018-08-05 20:58  DataBases  阅读(777)  评论(0编辑  收藏  举报

#parted [设备] [命令 [参数]]
命令功能:
新增分区:mkpart [primary|logical|extended] [ext3|vfat] 开始 结束
分区表:print
删除分区:rm [partition]

例子:以parted列出目前本机的分区资料表
#parted /dev/sda print
解释一下这个输出:
Number:这个就是分区的号码,举例来说,1代表的就是 /dev/sda1
Start:表示起始的柱面位置
End:表示结束的柱面位置
Size:有上述两者分析,得到这个分区有多少容量
Type:就是分区类型,有primary,extended,logical
File system:就如同fdisk的System ID

例子:新建一个约 512M 的逻辑分区。
#parted /dev/sda mkpart logical ext3 18.0GB 18.5GB
#parted /dev/sda print
#parted /dev/sda rm 7 ==>删除

获取UUID
ls -l /dev/disk/by-uuid/

UUID=f51895f2-196a-4239-ba62-7fea960a2808 /mnt/disk01 xfs defaults 0 0

UUID=a0075d76-b630-4858-bc4b-10f77cad496e /mnt/disk02 xfs defaults 0 0

[root@tdh01 /]# parted /dev/sda print
Model: IBM ServeRAID M5210 (scsi)
Disk /dev/sda: 4193GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志
1 1049kB 2149MB 2147MB fat32 EFI System Partition 启动
2 2149MB 6443MB 4295MB xfs
3 6443MB 681GB 674GB lvm

[root@tdh01 /]# parted /dev/sda mkpart primary xfs 681GB 1181GB
信息: You may need to update /etc/fstab.

[root@tdh01 /]# parted /dev/sda mkpart primary xfs 1181GB 1681GB
信息: You may need to update /etc/fstab.

[root@tdh01 /]# ls -l /dev/disk/by-uuid/
总用量 0
lrwxrwxrwx. 1 root root 10 8月 1 02:36 0C47-29C3 -> ../../sda1
lrwxrwxrwx. 1 root root 10 8月 1 02:15 6accd891-cd78-469a-a864-675d2a4a4810 -> ../../dm-3
lrwxrwxrwx. 1 root root 10 8月 1 02:15 bad0d9cc-5d95-44a8-bd58-e180e2b83570 -> ../../dm-0
lrwxrwxrwx. 1 root root 10 8月 1 02:36 cfc9bd44-1db3-4d2a-b4b3-b27ce84f3292 -> ../../sda4
lrwxrwxrwx. 1 root root 10 8月 1 02:36 daa1cf53-eddf-4393-9274-dfbb0e0a2c5a -> ../../sda2
lrwxrwxrwx. 1 root root 10 8月 1 02:15 dda5c423-a4f0-4068-af6f-919f19adc0f7 -> ../../dm-2
lrwxrwxrwx. 1 root root 10 8月 1 02:15 f933919b-dce5-4f83-a959-4c21a2529cbb -> ../../dm-1
[root@tdh01 /]# parted /dev/sda print
Model: IBM ServeRAID M5210 (scsi)
Disk /dev/sda: 4193GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志
1 1049kB 2149MB 2147MB fat32 EFI System Partition 启动
2 2149MB 6443MB 4295MB xfs
3 6443MB 681GB 674GB lvm
4 681GB 1181GB 500GB xfs primary
5 1181GB 1681GB 500GB primary

[root@tdh01 /]# mkfs.xfs -f -n ftype=1 /dev/sda4
meta-data=/dev/sda4 isize=256 agcount=16, agsize=7632960 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=122127360, imaxpct=25
= sunit=64 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=59648, version=2
= sectsz=512 sunit=64 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@tdh01 /]# mkfs.xfs -f -n ftype=1 /dev/sda5
meta-data=/dev/sda5 isize=256 agcount=16, agsize=7629376 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=122070016, imaxpct=25
= sunit=64 swidth=64 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=59648, version=2
= sectsz=512 sunit=64 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@tdh01 /]# parted /dev/sda print
Model: IBM ServeRAID M5210 (scsi)
Disk /dev/sda: 4193GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name 标志
1 1049kB 2149MB 2147MB fat32 EFI System Partition 启动
2 2149MB 6443MB 4295MB xfs
3 6443MB 681GB 674GB lvm
4 681GB 1181GB 500GB xfs primary
5 1181GB 1681GB 500GB xfs primary

[root@tdh01 /]# ls -l /dev/disk/by-uuid
总用量 0
lrwxrwxrwx. 1 root root 10 8月 1 02:39 0C47-29C3 -> ../../sda1
lrwxrwxrwx. 1 root root 10 8月 1 02:15 6accd891-cd78-469a-a864-675d2a4a4810 -> ../../dm-3
lrwxrwxrwx. 1 root root 10 8月 1 02:39 a0075d76-b630-4858-bc4b-10f77cad496e -> ../../sda5
lrwxrwxrwx. 1 root root 10 8月 1 02:15 bad0d9cc-5d95-44a8-bd58-e180e2b83570 -> ../../dm-0
lrwxrwxrwx. 1 root root 10 8月 1 02:39 daa1cf53-eddf-4393-9274-dfbb0e0a2c5a -> ../../sda2
lrwxrwxrwx. 1 root root 10 8月 1 02:15 dda5c423-a4f0-4068-af6f-919f19adc0f7 -> ../../dm-2
lrwxrwxrwx. 1 root root 10 8月 1 02:39 f51895f2-196a-4239-ba62-7fea960a2808 -> ../../sda4
lrwxrwxrwx. 1 root root 10 8月 1 02:15 f933919b-dce5-4f83-a959-4c21a2529cbb -> ../../dm-1
[root@tdh01 /]# cd /mnt/

[root@tdh01 mnt]# mkdir disk01
[root@tdh01 mnt]# mkdir disk02
[root@tdh01 mnt]# mount /dev/sda4 /mnt/disk01
[root@tdh01 mnt]# mount /dev/sda5 /mnt/disk02
[root@tdh01 mnt]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/rhel-root 200G 5.1G 195G 3% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 0 63G 0% /dev/shm
tmpfs 63G 9.3M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/sda2 4.0G 124M 3.9G 4% /boot
/dev/sda1 2.0G 9.5M 2.0G 1% /boot/efi
/dev/mapper/rhel-var_lib_docker 200G 33M 200G 1% /var/lib/docker
/dev/mapper/rhel-var_log 100G 36M 100G 1% /var/log
tmpfs 13G 0 13G 0% /run/user/0
/dev/sda4 466G 33M 466G 1% /mnt/disk01
/dev/sda5 466G 33M 466G 1% /mnt/disk02
[root@tdh01 mnt]# vi /etc/fstab