美文网首页
vmware中Linux挂载新硬盘

vmware中Linux挂载新硬盘

作者: mozre | 来源:发表于2017-09-17 15:43 被阅读0次
  1. 在虚拟机未启动状态下点击编辑虚拟机设置,在弹出框中选择添加。在弹出框中选中硬盘,根据需求选择即可。


    image
  2. 启动虚拟机,在虚拟机中查看硬盘信息
    # 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


  1. 分区命令:
    fdisk可以用m命令来看fdisk命令的内部命令;
a:命令指定启动分区;
d:命令删除一个存在的分区;
l:命令显示分区ID号的列表;
m:查看fdisk命令帮助;
n:命令创建一个新分区;
p:命令显示分区列表;
t:命令修改分区的类型ID号;
w:命令是将对分区表的修改存盘让它发生作用。
  1. 进入磁盘进行分区
Command (m for help):n  
Command action  
     e    extended                  //输入e为创建扩展分区  
     p    primary partition (1-4)      //输入p为创建逻辑分区  
p  
Partion number(1-4):1      //在这里输入l,就进入划分逻辑分区阶段了;  
First cylinder (51-125, default 51):   //注:这个就是分区的Start 值;这里最好直接按回车,如果您输入了一个非默认的数字,会造成空间浪费;  
Using default value 51  
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:这个是定义分区大小的,+200M 就是大小为200M ;当然您也可以根据p提示的单位cylinder的大小来算,然后来指定 End的数值。回头看看是怎么算的;还是用+200M这个办法来添加,这样能直观一点。如果您想添加一个10G左右大小的分区,请输入 +10000M ;  
  
Command (m for help): w                     //最后输入w回车保存。 
  1. 查看分区情况并格式化分区:
# fdisk -l
# mkfs.ext4 /dev/sdb1  

mke2fs 1.41.12 (17-May-2010)  
文件系统标签=  
操作系统: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  
第一个数据块=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. 
  1. 挂载分区
# mkdir ~/work
# mount /dev/sdb1 ~/work
# df -h   //查看配置情况

  1. 配置开机自动挂载并重启
#sudo vim /etc/fstab

添加:
/dev/sdb1       /home/mozre/work        ext4    defaults        0       0


# sudo reboot

相关文章

网友评论

      本文标题:vmware中Linux挂载新硬盘

      本文链接:https://www.haomeiwen.com/subject/urxmsxtx.html