Linux 虚拟化 | 您所在的位置:网站首页 › linux增加磁盘容量 › Linux 虚拟化 |
0、背景 整理一下 Linux 虚拟化相关技术~ (1)本系列文章格瑞图:Linux 虚拟化-0001-安装 KVM 格瑞图:Linux 虚拟化-0002-创建虚拟机 格瑞图:Linux 虚拟化-0003-容器化部署 opennebula 格瑞图:Linux 虚拟化-0004-克隆虚拟机 格瑞图:Linux 虚拟化-0005-调整虚机内存 格瑞图:Linux 虚拟化-0006-调整虚机磁盘 格瑞图:Linux 虚拟化-0007-KVM 虚机跨宿主迁移 1、步骤(1)创建磁盘文件[root@home ~]# qemu-img create -f qcow2 /data/sde1/kvm/nau128.100g.qcow2 100G Formatting '/data/sde1/kvm/nau128.100g.qcow2', fmt=qcow2 size=107374182400 encryption=off cluster_size=65536 lazy_refcounts=off [root@home kvm]# du -sh nau128.100g.qcow2 196K nau128.100g.qcow2 [root@home kvm]#qemu-img 报告大小 size 为 107374182400 du 报告带下为 196K (2)检查虚机磁盘名称[root@nau128 ~]# fdisk -l Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0x3b290167 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux /dev/sda2 2099200 37748735 35649536 17G 83 Linux /dev/sda3 37748736 41943039 4194304 2G 82 Linux swap / Solaris [root@nau128 ~]#从图中磁盘名称 /dev/sda 命名得知磁盘名为 /dev/sdx 其中 x 为 a~z 字母排序 (3)添加磁盘到虚机[root@home kvm]# virsh attach-disk nau128 /data/sde1/kvm/nau128.100g.qcow2 sdb --cache none Disk attached successfully [root@home kvm]# ssh nau128 Last login: Sun May 22 12:02:20 2022 from 192.168.1.100 [root@nau128 ~]# fdisk -l Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0x3b290167 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux /dev/sda2 2099200 37748735 35649536 17G 83 Linux /dev/sda3 37748736 41943039 4194304 2G 82 Linux swap / Solaris Disk /dev/sdb: 194 KiB, 198656 bytes, 388 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 [root@nau128 ~]#磁盘显示 194KiB 是不是有问题呢? 先格式化挂载试试 (4)格式化磁盘[root@nau128 ~]# fdisk /dev/sdb 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. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0xae06f852. Command (m for help): o Created a new DOS disklabel with disk identifier 0x427e5c5d. Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (1-4, default 1): First sector (1-387, default 1): Last sector, +sectors or +size{K,M,G,T,P} (1-387, default 387): Created a new partition 1 of type 'Linux' and of size 193.5 KiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. [root@nau128 ~]#查看磁盘 [root@nau128 ~]# fdisk -l Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0x3b290167 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux /dev/sda2 2099200 37748735 35649536 17G 83 Linux /dev/sda3 37748736 41943039 4194304 2G 82 Linux swap / Solaris Disk /dev/sdb: 194 KiB, 198656 bytes, 388 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: 0x427e5c5d Device Boot Start End Sectors Size Id Type /dev/sdb1 1 387 387 193.5K 83 Linux [root@nau128 ~]#(5)重启查看一下 [root@nau128 ~]# fdisk -l Disk /dev/sda: 194 KiB, 198656 bytes, 388 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: 0x427e5c5d Device Boot Start End Sectors Size Id Type /dev/sda1 1 387 387 193.5K 83 Linux Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 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: 0x3b290167 Device Boot Start End Sectors Size Id Type /dev/sdb1 * 2048 2099199 2097152 1G 83 Linux /dev/sdb2 2099200 37748735 35649536 17G 83 Linux /dev/sdb3 37748736 41943039 4194304 2G 82 Linux swap / Solaris [root@nau128 ~]#竟然把两块磁盘的顺序换了一下 [root@nau128 ~]# mkdir /data [root@nau128 ~]# mkfs.ext4 /dev/sda1 mke2fs 1.45.6 (20-Mar-2020) Filesystem too small for a journal Creating filesystem with 192 1k blocks and 24 inodes Allocating group tables: done Writing inode tables: done Writing superblocks and filesystem accounting information: done [root@nau128 ~]#从一开始就错了 [root@home kvm]# ls -lh nau128.100g.qcow2 -rw-r--r--. 1 qemu qemu 194K May 22 12:26 nau128.100g.qcow2 [root@home kvm]# qemu-img info nau128.100g.qcow2 image: nau128.100g.qcow2 file format: raw virtual size: 194K (198656 bytes) disk size: 196K [root@home kvm]#先使用图形界面搞定添加磁盘 这个坑还没有过去,使用 virsh attach-disk 添加的磁盘,空间就是有问题~ 先忙正事儿~ |
CopyRight 2018-2019 实验室设备网 版权所有 |