vmware虛擬機器新增虛擬磁碟的方法
1. 為VMware虛擬機器新增虛擬磁碟
開啟虛擬機器-> 虛擬機器設定 -> 磁碟 -> add -> hard disk -> next -> next -> create new disk -> 輸入大小和選擇儲存到單一檔案; -> 輸入檔名 -> finish;
2. 掛載到linux系統
首先重啟虛擬機器系統
# 2.1 確認新增的虛擬磁碟裝置檔案
# sudo fdisk -l
------------------------------------------------------------------------
Disk /dev/sdf: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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 identifier: 0x00000000
Disk /dev/sdf doesn't contain a valid partition table
------------------------------------------------------------------------
# 2.2 為新增磁碟配置分割槽
# sudo fdisk /dev/sdf
------------------------------------------------------------------------
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc388f37d.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): m #輸入m列印幫助資訊
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
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 #選擇n新建分割槽
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): #使用預設值p直接回車
Using default response p
Partition number (1-4, default 1): #使用預設值1直接回車
Using default value 1
First sector (2048-209715199, default 2048): #使用預設值2048直接回車
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Command (m for help): w #寫入分割槽資訊(儲存)
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
------------------------------------------------------------------------
# 2.3 格式化磁碟分割槽為ext4格式
# 首先檢視新增磁碟的分割槽資訊
# sudo fdisk -l
------------------------------------------------------------------------
Disk /dev/sdf: 107.4 GB, 107374182400 bytes
43 heads, 44 sectors/track, 110843 cylinders, total 209715200 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 identifier: 0xc388f37d
Device Boot Start End Blocks Id System
/dev/sdf1 2048 209715199 104856576 83 Linux
------------------------------------------------------------------------
# 然後對/dev/sdf1 進行格式化
# sudo mkfs.ext4 /dev/sdf1
------------------------------------------------------------------------
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
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 (32768 blocks): done
Writing superblocks and filesystem accounting information: done
------------------------------------------------------------------------
# 2.4 掛載分割槽到系統
# 首先確認分割槽的UUID
# sudo blkid /dev/sdf1
------------------------------------------------------------------------
/dev/sdf1: UUID="3c0633c0-fc64-4252-adae-c124ebeb2962" TYPE="ext4"
------------------------------------------------------------------------
# 然後將UUID寫入到 /etc/fstab 檔案
# sudo vi /etc/fstab
------------------------------------------------------------------------
UUID=3c0633c0-fc64-4252-adae-c124ebeb2962 /mnt/dev-toolkits auto rw,suid,dev,exec,auto,nouser,async 0 0
------------------------------------------------------------------------
# 最後執行重新掛載所有檔案系統命令
# sudo mount -a
------------------------------------------------------------------------
mount: mount point /mnt/dev-toolkits does not exist
------------------------------------------------------------------------
# 報錯了,提示掛載點目錄不存在,所以建立掛載點目錄後重試
# sudo mkdir -p /mnt/dev-toolkits
# sudo mount -a
# 最後執行df命令檢視檔案系統掛載情況
# df -h
------------------------------------------------------------------------
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 489G 14G 450G 3% /
/dev/sdf1 99G 60M 94G 1% /mnt/dev-toolkits
------------------------------------------------------------------------
# 至此已經配置完畢,以後每次重啟,該磁碟都會自動掛載到配置的目錄