VM VirtualBox使用vdi磁盘

引言

        在使用VM VirtualBox过程中,会用到很多平台sdk,每个sdk占用空间都特别大,如果将所有sdk都放置系统盘中,磁盘空间会变得非常巨大,不利于虚拟机备份。VM VirtualBox使用的是虚拟磁盘vdi,可以将系统和sdk分别存储在不同的虚拟磁盘中,需要使用哪个sdk就加载哪个vdi虚拟磁盘就行,这样方便备份虚拟机和sdk。

创建一个vdi磁盘

        

加载到虚拟机中,启动虚拟机

        

查看分区:

kircar@ubuntu:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0  55.4M  1 loop /snap/core18/2128
loop1    7:1    0   704K  1 loop /snap/gnome-characters/726
loop2    7:2    0     4K  1 loop /snap/bare/5
loop3    7:3    0   2.5M  1 loop /snap/gnome-calculator/884
loop4    7:4    0   1.6M  1 loop /snap/gnome-system-monitor/186
loop5    7:5    0   860K  1 loop /snap/gnome-logs/123
loop6    7:6    0  91.7M  1 loop /snap/gtk-common-themes/1535
loop7    7:7    0   219M  1 loop /snap/gnome-3-34-1804/72
loop8    7:8    0  63.7M  1 loop /snap/core20/2434
loop9    7:9    0  44.4M  1 loop /snap/snapd/23545
loop10   7:10   0   2.2M  1 loop /snap/gnome-calculator/955
loop11   7:11   0   516K  1 loop /snap/gnome-characters/797
loop12   7:12   0   548K  1 loop /snap/gnome-logs/106
loop13   7:13   0   2.5M  1 loop /snap/gnome-system-monitor/163
loop14   7:14   0  73.9M  1 loop /snap/core22/1722
loop15   7:15   0 218.4M  1 loop /snap/gnome-3-34-1804/93
loop16   7:16   0  55.4M  1 loop /snap/core18/2846
loop17   7:17   0  65.1M  1 loop /snap/gtk-common-themes/1515
loop18   7:18   0  61.8M  1 loop /snap/core20/1081
loop19   7:19   0 241.4M  1 loop /snap/gnome-3-38-2004/70
loop20   7:20   0 349.7M  1 loop /snap/gnome-3-38-2004/143
sda      8:0    0   120G  0 disk 
└─sda1   8:1    0   120G  0 part /
sdb      8:16   0   120G  0 disk 
└─sdb1   8:17   0   120G  0 part 
sdc      8:32   0   240G  0 disk 
sr0     11:0    1  1024M  0 rom  
kircar@ubuntu:~$ 


格式化磁盘

kircar@ubuntu:~$ sudo fdisk /dev/sdc
[sudo] password for kircar: 

Welcome to fdisk (util-linux 2.31.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 0x07644437.

Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-503316479, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-503316479, default 503316479): 

Created a new partition 1 of type 'Linux' and of size 240 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

kircar@ubuntu:~$ 

格式化分区

kircar@ubuntu:~$ sudo mkfs -t ext4 /dev/sdc1
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 62914304 4k blocks and 15728640 inodes
Filesystem UUID: b8767b8e-ac4a-4673-9348-349d21e3aa92
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done     

kircar@ubuntu:~$ 

创建一个文件夹

mkdir sdk-Android-rk3566-vdi

挂载分区

sudo mount /dev/sdc1 sdk-android-rk3566-vdi

文件夹属性是root用户,将文件夹属归属修改为kircar用户

chown kircar sdk-android-rk3566-vdi

设置开机启动自动挂载


编辑/etc/fstab
vim /etc/fstab

在末尾加上
/dev/sdb1 /root/docker ext4 defaults 0 0

以上程序做完,就可以使用这个新建分区了.
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值