Disk identifier: CBD519C0-D1F2-4E98-B8D3-C4F4B60C025A
Device Start End Sectors Size Type
/dev/vdb1 1024 1000000 998977 487.8M Linux filesystem
/dev/vdb2 1001472 2549759 1548288 756M Linux filesystem
Command (m forhelp): w
The partition table has been altered.
Syncing disks.
格式化
[root@venus ~]# mkswap /dev/vdb2
Setting up swapspace version 1, size = 756 MiB (792719360 bytes)
no label, UUID=4e337981-b8c7-48ee-86c6-1a11fd7dbb82
永久挂载
[root@system1 ~]# vim /etc/fstab
/dev/vdb2 swap swap defaults 0 0
[root@venus ~]# mount -a
激活交换分区
[root@venus ~]# swapon -a
[root@venus ~]# swapon --show
NAME TYPE SIZE USED PRIO
/dev/dm-0 partition 512M 0B -2
/dev/vdb2 partition 756M 0B -3
[root@venus ~]# free -m
total used free shared buff/cache
available
Mem: 821 175 328 15 316
500
Swap: 1267 0 1267
解题2
查看一下磁盘空间分配情况
[root@venus ~]# lsblk NAMEMAJ:MINRMSIZEROTYPEMOUNTPOINT vda 252:00 10G 0 disk ├─vda1 252:10 1M 0 part ├─vda2 252:20 100M 0 part /boot/efi └─vda3 252:309.9G 0 part / vdb 252:160 5G 0 disk ├─vdb1 252:170 510M 0 part │ └─myvol-vo 253:00 232M 0 lvm /reports └─vdb2 252:180 2G 0 part └─vgroup-swap 253:10 512M 0 lvm [SWAP] vdc 252:320 10G 0 disk
使用磁盘分区分出一个swap
[root@venus ~]# fdisk /dev/vdb Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m forhelp): p # 首先p打印一下现在的分区信息 Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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 Disklabel type: dos Disk identifier: 0xdf110c4a
Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 1046528 1044481 510M 83 Linux /dev/vdb2 1046529 5240833 4194305 2G 83 Linux
Command (m forhelp): n # 然后按n新建分区 Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): p # 再按p添加主分区 Partition number (3,4, default 3): # 然后是让你选择主分区代码3,4默认就可以(3) First sector (5240834-10485759, default 5242880): # 之后是选择分区起始位置的大小默认就可以 Last sector,+sectors or +size{K,M,G,T,P} (5242880-10485759, default 10485759): +756M #最后是选择增加的大小+756M
Created a new partition 3 of type'Linux' and of size 756 MiB.
Command (m forhelp): p # 现在按p再查看一下分区信息 Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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 Disklabel type: dos Disk identifier: 0xdf110c4a
Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 1046528 1044481 510M 83 Linux /dev/vdb2 1046529 5240833 4194305 2G 83 Linux /dev/vdb3 5242880 6791167 1548288 756M 83 Linux
# 为了以后方便正常工作中查看将标识号更改为82(交换分区) Command (m forhelp): t # 按t Partition number (1-3, default 3): 3 # 选择3 Hex code (type L to list all codes): 82 # 再输入82
Changed type of partition 'Linux' to 'Linux swap / Solaris'.
Command (m forhelp): p # 再按p再查看一下分区信息 Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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 Disklabel type: dos Disk identifier: 0xdf110c4a
Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 1046528 1044481 510M 83 Linux /dev/vdb2 1046529 5240833 4194305 2G 83 Linux /dev/vdb3 5242880 6791167 1548288 756M 82 Linux swap / Solaris # 更改成功
Command (m forhelp): w # 按w保存退出 The partition table has been altered. Syncing disks.
查看分区信息
[root@venus ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 10G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 100M 0 part /boot/efi └─vda3 252:3 0 9.9G 0 part / vdb 252:16 0 5G 0 disk ├─vdb1 252:17 0 510M 0 part │ └─myvol-vo 253:0 0 232M 0 lvm /reports ├─vdb2 252:18 0 2G 0 part │ └─vgroup-swap 253:1 0 512M 0 lvm [SWAP] └─vdb3 252:19 0 756M 0 part vdc 252:32 0 10G 0 disk
格式化分区
[root@venus ~]# mkswap /dev/vdb3 Setting up swapspace version 1, size = 756 MiB (792719360 bytes) no label, UUID=dd5e8738-83a0-45fb-9014-4533d7a94e8e
Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m forhelp): n Partition type p primary (3 primary, 0 extended, 1 free) e extended (container for logical partitions) Select (default e):
Using default response e. Selected partition 4 First sector (5240834-10485759, default 6791168): Last sector, +sectors or +size{K,M,G,T,P} (6791168-10485759, default 10485759):
Created a new partition 4 of type'Extended' and of size 1.8 GiB.
Command (m forhelp): w The partition table has been altered. Syncing disks.
Command (m forhelp): n All primary partitions are in use. Adding logical partition 5 First sector (6793216-10485759, default 6793216): Last sector, +sectors or +size{K,M,G,T,P} (6793216-10485759, default 10485759):
Created a new partition 5 of type'Linux' and of size 1.8 GiB.
Command (m forhelp): p Disk /dev/vdb: 5 GiB, 5368709120 bytes, 10485760 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 Disklabel type: dos Disk identifier: 0xdf110c4a
Device Boot Start End Sectors Size Id Type /dev/vdb1 2048 1046528 1044481 510M 83 Linux /dev/vdb2 1046529 5240833 4194305 2G 83 Linux /dev/vdb3 5242880 6791167 1548288 756M 82 Linux swap / Solaris /dev/vdb4 6791168 10485759 3694592 1.8G 5 Extended /dev/vdb5 6793216 10485759 3692544 1.8G 83 Linux
Command (m forhelp): w The partition table has been altered. Failed to add partition 5 to system: Device or resource busy
The kernel still uses the old partitions. The new table will be used at the next reboot. Syncing disks.
# 在模拟环境中显示需要重启 [root@venus ~]# reboot
# 重启后查看之前创建的vdb5已经创建完成 [root@venus ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 10G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 100M 0 part /boot/efi └─vda3 252:3 0 9.9G 0 part / vdb 252:16 0 5G 0 disk ├─vdb1 252:17 0 510M 0 part │ └─myvol-vo 253:0 0 232M 0 lvm /reports ├─vdb2 252:18 0 2G 0 part │ └─vgroup-swap 253:1 0 512M 0 lvm [SWAP] ├─vdb3 252:19 0 756M 0 part [SWAP] ├─vdb4 252:20 0 1K 0 part └─vdb5 252:21 0 1.8G 0 part vdc 252:32 0 10G 0 disk
# 查看创建VDO的命令 [root@venus ~]# man vdo | grep \# # vdo create --name=vdo0 --device=/dev/sdb1 --vdoLogicalSize=10T # [root@venus ~]# vdo create --name=vdough --device=/dev/vdc --vdoLogicalSize=50G CreatingVDO vdough TheVDO volume can address 6GBin3 data slabs, each 2GB. It can grow to address at most 16TBof physical storage in8192 slabs. If a larger maximum size might be needed, use bigger slabs. StartingVDO vdough Starting compression on VDO vdough VDO instance 0 volume is ready at /dev/mapper/vdough
## 挂载时defaults后的参数通过man vdo 查找fstab找到 For /etc/fstab mounting, in order to make sure the mount waits for the VDO to start, use the mount option x-systemd.requires=vdo.service For example, an /etc/fstab line involving VDO could be the fol‐ lowing: