2022-07-22 15:49:31#1、 创建50GB 的vdi硬盘 VBoxManage createvdi --Filename "/gpmaster/gpseg-1_down/VirtualBox VMs/meta_meta_1651042401911_2096/meta-50g.vdi" --size 51200 #2、将第一步创建的硬盘attach到虚拟机上 VBoxManage storageattach meta_meta_1651042401911_2096 --storagectl SATA --port 0 --device 0 --type hdd --medium "/gpmaster/gpseg-1_down/VirtualBox VMs/meta_meta_1651042401911_2096/meta-50g.vdi" # 3、如果第二步报错: sata控制器未开启先执行以下命令开启再执行第二步(必须关机状态) VBoxManage storagectl meta_meta_1651042401911_2096 --name SATA --add sata --controller IntelAhci --bootable on ,下面我们就来聊聊关于virtualbox虚拟机数量设置?接下来我们就一起去了解一下吧!

virtualbox虚拟机数量设置(VirtualBox虚拟机加硬盘实操)

virtualbox虚拟机数量设置

给vagrant拉起来的机器加一块硬盘通过VBoxManage 工具给虚拟机增加硬盘.

2022-07-22 15:49:31

#1、 创建50GB 的vdi硬盘 VBoxManage createvdi --Filename "/gpmaster/gpseg-1_down/VirtualBox VMs/meta_meta_1651042401911_2096/meta-50g.vdi" --size 51200 #2、将第一步创建的硬盘attach到虚拟机上 VBoxManage storageattach meta_meta_1651042401911_2096 --storagectl SATA --port 0 --device 0 --type hdd --medium "/gpmaster/gpseg-1_down/VirtualBox VMs/meta_meta_1651042401911_2096/meta-50g.vdi" # 3、如果第二步报错: sata控制器未开启先执行以下命令开启再执行第二步(必须关机状态) VBoxManage storagectl meta_meta_1651042401911_2096 --name SATA --add sata --controller IntelAhci --bootable on

lsblk查看新加的硬盘

[root@meta /etc/prometheus]#df -Th Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 7.8G 0 7.8G 0% /dev tmpfs tmpfs 7.8G 180K 7.8G 1% /dev/shm tmpfs tmpfs 7.8G 156M 7.7G 2% /run tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/sda1 xfs 40G 39G 1.5G 97% / tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0 [root@meta /etc/prometheus]#fdisk -l /dev/sdb Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 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@meta /etc/prometheus]#lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 40G 0 disk `-sda1 8:1 0 40G 0 part / sdb 8:16 0 50G 0 disk

fdisk格式化硬盘

[root@meta /etc/prometheus]#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 0x1daa8e3b. Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 #几个分区 First sector (2048-104857599, default 2048):# 扇区起始位置 Using default value 2048 Last sector, sectors or size{K,M,G} (2048-104857599, default 104857599):# 扇区结束位置 Using default value 104857599 Partition 1 of type Linux and of size 50 GiB is set Command (m for help): p Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 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 Disk label type: dos Disk identifier: 0x1daa8e3b Device Boot Start End Blocks Id System /dev/sdb1 2048 104857599 52427776 83 Linux Command (m for help): w # 保存 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@meta /etc/prometheus]# [root@meta /etc/prometheus]#lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 40G 0 disk `-sda1 8:1 0 40G 0 part / sdb 8:16 0 50G 0 disk `-sdb1 8:17 0 50G 0 part [root@meta /etc/prometheus]#partprobe /dev/sdb # 重新载入磁盘分区信息 [root@meta /etc/prometheus]#

xfs_growfs 和 mkfs.xfs区别

mkfs.xfs格式化没有做lvm的磁盘

xfs_growfs格式化做了lvm的磁盘

[root@meta /etc/prometheus]#mkfs.xfs -f /dev/sdb1 # 不同文件系统使用不同的格式化命令 meta-data=/dev/sdb1 isize=512 agcount=4, agsize=3276736 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=13106944, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=6399, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0

umount报 target is busy

[root@meta /tmp]#df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 7.8G 0 7.8G 0% /dev tmpfs 7.8G 180K 7.8G 1% /dev/shm tmpfs 7.8G 792M 7.0G 10% /run tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/sda1 40G 21G 20G 51% / /dev/sdb1 50G 13G 38G 26% /prometheus tmpfs 1.6G 0 1.6G 0% /run/user/0 [root@meta /tmp]#mount /dev/sdb1 /prometheus

[root@meta /data/prometheus/data]#umount -v /dev/sdb1 umount: /data: target is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))

解决

对付系统文件正忙的另一种方法是执行延迟卸载: [root@meta /data/prometheus/data]#umount -vl /data/ umount: /data (/dev/sdb1) unmounted 延迟卸载(lazy unmount)会立即卸载目录树里的文件系统,等到设备不再繁忙时才清理所有相关资源