-
-
Save kenwoodjw/427eeea240ed063853cc5bcb4ea834b9 to your computer and use it in GitHub Desktop.
kvm.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
virt-install \ | |
--virt-type=kvm \ | |
--name=master \ | |
--vcpus=16 \ | |
--memory=16384 \ | |
--location=/home/CentOS-7-x86_64-Everything-1708.iso \ | |
--disk path=/home/vms/master.qcow2,size=2048,format=qcow2 \ | |
--network bridge=br0 \ | |
--graphics none \ | |
--extra-args='console=ttyS0' \ | |
--force | |
``` | |
``` | |
xfs_growfs /dev/centos/root | |
#lvextend -r -L +300G /dev/centos/root | |
lvreduce -L 400G /dev/centos/root | |
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l | |
cat /proc/cpuinfo| grep "cpu cores"| uniq | |
1、提前备份重要数据,xfs减小会导致数据丢失 | |
备份可以用xfsdump,数据不大也可以备份到机器之外(此处略) | |
2、卸载卷/dev/mapper/cl-home | |
[root@localhost ~]# umount /home | |
3、减少卷/dev/mapper/cl-home大小(该步骤会导致数据丢失,请看第1点) | |
[root@localhost ~]# lvreduce -L 5G /dev/mapper/cl-home | |
WARNING: Reducing active logical volume to 10.00 GiB. | |
THIS MAY DESTROY YOUR DATA (filesystem etc.) | |
Do you really want to reduce cl/home? [y/n]:y | |
Size of logical volume cl/home changed from 178.25 GiB (45633 extents) to 10.00 GiB (2560 extents). | |
Logical volume cl/home successfully resized. | |
4、增加卷/dev/mapper/cl-root大小 | |
[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/cl-root | |
Size of logical volume cl/root changed from 50.00 GiB (12800 extents) to 218.26 GiB (55874 extents). | |
Logical volume cl/root successfully resized. | |
5、调整xfs文件系统大小 | |
[root@localhost ~]# xfs_growfs /dev/mapper/cl-root | |
6、重新挂载、恢复数据 | |
如果直接挂载会报错: | |
[root@localhost ~]# mount /dev/mapper/cl-home /home/ | |
mount: /dev/mapper/cl-home: can't read superblock | |
需要先格式化 | |
[root@localhost ~]# mkfs.xfs -f /dev/mapper/cl-home | |
格式化后挂载: | |
[root@localhost ~]# mount /dev/mapper/cl-home /home/ | |
``` | |
``` | |
使用groups命令查看用户所在组的名称: | |
$ groups [用户名] | |
若省略用户名,默认显示当前用户所在组。 | |
id命令提供额外的信息,包括用户UID以及相关用户组GID: | |
$ id [用户名] | |
查看所有组: | |
$ cat /etc/group | |
使用groupadd创建新的组: | |
# groupadd [组名] | |
使用gpasswd将用户添加到组: | |
# gpasswd -a [用户名] [组名] | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment