虛擬機器VirtualBox怎麼新增新的虛擬硬碟
阿新 • • 發佈:2020-10-13
1、建立虛擬硬碟
virtualbox中,通過“設定”——”儲存“——新增虛擬硬碟
根據提示,新增完虛擬硬碟。 2、虛擬硬碟分割槽 啟動 系統,檢視磁碟空間 [plain] [root @localhost ~]# fdisk -l 如果正常,將看到類似資訊:Disk /dev/hdb doesn't contain a valid partition table,這裡/dev/hdb就是新增的虛擬硬碟。對虛擬硬碟進行分割槽 [plain] [root @localhost ~]# fdisk /dev/hdb 輸入m檢視幫助 [plain] Command (m for help): m 輸入n新增分割槽 [plain] Command (m for help): n 輸入p新建主分割槽 鍵入數字1,新增一個主分割槽 www.2cto.com [plain] Partition number (1-4): 1 摁回車鍵【Enter】 [plain] First cylinder (1-41610, default 1):Enter 摁回車鍵【Enter】 [plain] Last cylinder or +size or +sizeM or +sizeK (1-41610, default 41610): 輸入w寫入並退出 [plain] Command (m for help): w www.2cto.com 3、格式化虛擬硬碟分割槽 把虛擬硬碟分割槽格式化為ext4之前,需要先檢視系統是否載入ext4模組 [plain] [root @localhost ~]# lsmod | grep ext4
如果沒有載入,手動載入(centos5.x中有ext4模組,只是需要手動載入)
[plain]
[root
@localhost ~]# cd /lib/modules/2.6.18-194.el5/kernel/fs/ext4/
如果不出意外,將看到ext4.ko檔案,載入ext4模組
[plain]
[root
@localhost ext4]# modprobe ext4
檢視是否載入成功:
[plain]
[[email protected] ext4]# lsmod | grep ext4
ext4 254557 0
jbd2 60325 1 ext4
crc16 6209 1 ext4
上面說明已經載入成功了。格式化之前需要安裝e4fsprogs,如果沒有安裝可以通過下面的命令安裝:
[plain]
[ [email protected] ext4]# yum -y install e4fsprogs
格式化分割槽:
[plain]
[[email protected] ext4]#
mkfs.ext4 /dev/hdb1
4、掛載虛擬分割槽
建立掛載目錄:/mnt/hdb1
[plain]
[[email protected] dev]# cd /mnt/
[[email protected] mnt]# mkdir hdb1
掛載虛擬分割槽/dev/hdb1 到/mnt/hdb1/
[plain]
[[email protected] mnt]#
mount -t ext4 /dev/hdb1 /mnt/hdb1/
檢視檔案系統:
[plain]
[[email protected] hdb1]# df -lh
檔案系統 容量 已用 可用 已用% 掛載點
/dev/mapper/VolGroup00-LogVol00
6.7G 6.0G 378M 95% /
/dev/hda1 99M 25M 70M 26% /boot
tmpfs 315M 0 315M 0% /dev/shm
/dev/hdb1 20G 172M 19G 1% /mnt/hdb1
竟然真的看到/mnt/hdb1了。到目前為止,已經基本操作完畢。
5、開機自動掛載新虛擬硬碟
編輯fstab
[plain]
[[email protected] ~]#
vim /etc/fstab
在檔案最後新增一行:
[plain]
/dev/hdb1 /mnt/hdb1 ext4 defaults 0 0
根據提示,新增完虛擬硬碟。 2、虛擬硬碟分割槽 啟動 系統,檢視磁碟空間 [plain] [root @localhost ~]# fdisk -l 如果正常,將看到類似資訊:Disk /dev/hdb doesn't contain a valid partition table,這裡/dev/hdb就是新增的虛擬硬碟。對虛擬硬碟進行分割槽 [plain] [root @localhost ~]# fdisk /dev/hdb 輸入m檢視幫助 [plain] Command (m for help): m 輸入n新增分割槽 [plain] Command (m for help): n 輸入p新建主分割槽 鍵入數字1,新增一個主分割槽 www.2cto.com [plain] Partition number (1-4): 1 摁回車鍵【Enter】 [plain] First cylinder (1-41610, default 1):Enter 摁回車鍵【Enter】 [plain] Last cylinder or +size or +sizeM or +sizeK (1-41610, default 41610): 輸入w寫入並退出 [plain] Command (m for help): w www.2cto.com 3、格式化虛擬硬碟分割槽 把虛擬硬碟分割槽格式化為ext4之前,需要先檢視系統是否載入ext4模組 [plain] [root
轉載於:https://my.oschina.net/guyson/blog/324513