产品:VMware® Workstation
版本:10.0.0 build-1295980
系统:Ubuntu16.04LTS
虚拟机(M)->设置(S)...->添加(A)...->硬盘->下一步(N)
SCSI(S)(推荐)->下一步(N)->创建新虚拟磁盘(V)
本例子设置磁盘大小为80GB
-------------------------------------------------------------------------------------------
查看挂载情况
ivansun@ubuntu:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 458M 0 458M 0% /dev
tmpfs 98M 6.6M 91M 7% /run
/dev/sda1 58G 7.0G 49G 13% /
tmpfs 488M 212K 487M 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 488M 0 488M 0% /sys/fs/cgroup
tmpfs 98M 56K 98M 1% /run/user/1000
-------------------------------------------------------------------------------------------
fdisk 查看硬盘分区情况
ivansun@ubuntu:~$ 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: 0x60970346
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 123828223 123826176 59G 83 Linux
/dev/sda2 123830270 125827071 1996802 975M 5 Extended
/dev/sda5 123830272 125827071 1996800 975M 82 Linux swap / Solaris
Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 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
-------------------------------------------------------------------------------------------
选择要进行操作的磁盘
ivansun@ubuntu:~$ sudo fdisk /dev/sdb
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 0xdd34ff0f.
-------------------------------------------------------------------------------------------
输入m列出可以执行的命令:
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
-------------------------------------------------------------------------------------------
输入p列出磁盘目前的分区情况
Command (m for help): p
Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 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: 0xdd34ff0f
-------------------------------------------------------------------------------------------
建立新的磁盘分区
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-167772159, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-167772159, default 167772159):
Created a new partition 1 of type 'Linux' and of size 80 GiB.
-------------------------------------------------------------------------------------------
输入p列出磁盘目前的分区情况
Command (m for help): p
Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 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: 0xdd34ff0f
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 167772159 167770112 80G 83 Linux
-------------------------------------------------------------------------------------------
保存分区操作
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
-------------------------------------------------------------------------------------------
ivansun@ubuntu:~$ 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: 0x60970346
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 123828223 123826176 59G 83 Linux
/dev/sda2 123830270 125827071 1996802 975M 5 Extended
/dev/sda5 123830272 125827071 1996800 975M 82 Linux swap / Solaris
Disk /dev/sdb: 80 GiB, 85899345920 bytes, 167772160 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: 0xdd34ff0f
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 167772159 167770112 80G 83 Linux
-------------------------------------------------------------------------------------------
格式化分区
ivansun@ubuntu:~$ sudo mkfs -t ext3 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 20971264 4k blocks and 5242880 inodes
Filesystem UUID: 4828b71e-cdf4-4418-ab3a-989ba941e663
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
-------------------------------------------------------------------------------------------
创建work文件夹用于挂载
ivansun@ubuntu:~$ mkdir -p /home/ivansun/work/
挂载分区
ivansun@ubuntu:~$ sudo mount /dev/sdb1 /home/ivansun/work/
-------------------------------------------------------------------------------------------
查看挂载情况
ivansun@ubuntu:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 458M 0 458M 0% /dev
tmpfs 98M 6.6M 91M 7% /run
/dev/sda1 58G 7.0G 49G 13% /
tmpfs 488M 216K 487M 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 488M 0 488M 0% /sys/fs/cgroup
tmpfs 98M 56K 98M 1% /run/user/1000
/dev/sdb1 79G 56M 75G 1% /home/ivansun/work
-------------------------------------------------------------------------------------------
更改目录所有者命令
ivansun@ubuntu:~$ sudo chown -R ivansun:ivansun /home/ivansun/work
更改目录权限命令
ivansun@ubuntu:~$ chmod -R 775 /home/ivansun/work
-------------------------------------------------------------------------------------------
取消挂载
ivansun@ubuntu:~$ sudo umount work
-------------------------------------------------------------------------------------------