-
在虛擬機未啟動狀態(tài)下點擊編輯虛擬機設(shè)置,在彈出框中選擇添加。在彈出框中選中硬盤,根據(jù)需求選擇即可。
image - 啟動虛擬機,在虛擬機中查看硬盤信息
# sudo fdisk -l
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 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: 0xcb6d7a7d
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 391167 389120 190M 83 Linux
/dev/sda2 393214 125827071 125433858 59.8G 5 Extended
/dev/sda5 393216 30390271 29997056 14.3G 83 Linux
/dev/sda6 30392320 46397439 16005120 7.6G 82 Linux swap / Solaris
/dev/sda7 46399488 125827071 79427584 37.9G 83 Linux
Disk /dev/sdb: 350 GiB, 375809638400 bytes, 734003200 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: 0xd868f2b3
- 分區(qū)命令:
fdisk可以用m命令來看fdisk命令的內(nèi)部命令;
a:命令指定啟動分區(qū);
d:命令刪除一個存在的分區(qū);
l:命令顯示分區(qū)ID號的列表;
m:查看fdisk命令幫助;
n:命令創(chuàng)建一個新分區(qū);
p:命令顯示分區(qū)列表;
t:命令修改分區(qū)的類型ID號;
w:命令是將對分區(qū)表的修改存盤讓它發(fā)生作用。
- 進入磁盤進行分區(qū)
Command (m for help):n
Command action
e extended //輸入e為創(chuàng)建擴展分區(qū)
p primary partition (1-4) //輸入p為創(chuàng)建邏輯分區(qū)
p
Partion number(1-4):1 //在這里輸入l,就進入劃分邏輯分區(qū)階段了;
First cylinder (51-125, default 51): //注:這個就是分區(qū)的Start 值;這里最好直接按回車,如果您輸入了一個非默認的數(shù)字,會造成空間浪費;
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:這個是定義分區(qū)大小的,+200M 就是大小為200M ;當然您也可以根據(jù)p提示的單位cylinder的大小來算,然后來指定 End的數(shù)值?;仡^看看是怎么算的;還是用+200M這個辦法來添加,這樣能直觀一點。如果您想添加一個10G左右大小的分區(qū),請輸入 +10000M ;
Command (m for help): w //最后輸入w回車保存。
- 查看分區(qū)情況并格式化分區(qū):
# fdisk -l
# mkfs.ext4 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系統(tǒng)標簽=
操作系統(tǒng):Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
640848 inodes, 2562359 blocks
128117 blocks (5.00%) reserved for the super user
第一個數(shù)據(jù)塊=0
Maximum filesystem blocks=2625634304
79 block groups
32768 blocks per group, 32768 fragments per group
8112 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
正在寫入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
- 掛載分區(qū)
# mkdir ~/work
# mount /dev/sdb1 ~/work
# df -h //查看配置情況
- 配置開機自動掛載并重啟
#sudo vim /etc/fstab
添加:
/dev/sdb1 /home/mozre/work ext4 defaults 0 0
# sudo reboot