【原文链接】:http://blog.csdn.net/tianlesoftware/article/details/5642883

装虚拟机时空间划小了,于是又加了5G的空间,折腾了半天,挂上去了。整理下弄个笔记,备用。

1. 添加磁盘,查看磁盘状况

[root@db1 /]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *         151        1305     9277537+  83  Linux

/dev/sda2               1         150     1204843+  82  Linux swap

Partition table entries are not in disk order

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

从查询结果看出,多了一个/dev/sdb的盘

2. 用fdisk 对/dev/sdb 进行分区

[root@db1 /]# fdisk /dev/sdb

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-652, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-652, default 652):

Using default value 652

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

再次查看分区情况,多出来一个/dev/sdb1 的区,这个1是我们在前面指定的,如果我们指定2,就变成 sdb2了。

[root@db1 /]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *         151        1305     9277537+  83  Linux

/dev/sda2               1         150     1204843+  82  Linux swap

Partition table entries are not in disk order

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         652     5237158+  83  Linux

[root@db1 /]#

如果创建完之后,/proc/partitions 查看不到对应的分区,使用parprobe 命令刷新一下就可以了:

[root@web1 ~]# cat /proc/partitions 

major minor  #blocks  name





   8     0  175825944 sda

   8     1    1020096 sda1

   8     2   30716280 sda2

   8     3    8193150 sda3

[root@web1 ~]# partprobe /dev/sda

[root@web1 ~]# cat /proc/partitions 

major minor  #blocks  name





   8     0  175825944 sda

   8     1    1020096 sda1

   8     2   30716280 sda2

   8     3    8193150 sda3

   8     4  135893835 sda4

[root@web1 ~]#

3. 格式化 /dev/sdb1 分区

[root@db1 /]# mkfs -t ext3 /dev/sdb1

mke2fs 1.35 (28-Feb-2004)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

655360 inodes, 1309289 blocks

65464 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=1342177280

40 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

4. 创建目录 并将 /dev/sdb1 挂在到该目录下

[root@db1 /]# ls

backup  dev   initrd      media  opt   sbin     sys       usr

bin     etc   lib         misc   proc  selinux  tftpboot  var

boot    home  lost+found  mnt    root  srv      tmp

[root@db1 /]# mkdir /u01

[root@db1 /]# ls

backup  dev   initrd      media  opt   sbin     sys       u01

bin     etc   lib         misc   proc  selinux  tftpboot  usr

boot    home  lost+found  mnt    root  srv      tmp       var

[root@db1 /]# mount /dev/sdb1 /u01

5. 验证挂载是否成功

[root@db1 /]# df -k

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1              9131772   7066884   1601012  82% /

none                    454256         0    454256   0% /dev/shm

/dev/sdb1              5154852     43040   4849956   1% /backup

6. 设置开机自动挂载

[root@db1 /]# vi /etc/fstab

# This file is edited by fstab-sync - see 'man fstab-sync' for details

LABEL=/                 /                       ext3    defaults        1 1

none                    /dev/pts                devpts  gid=5,mode=620  0 0

none                    /dev/shm                tmpfs   defaults        0 0

none                    /proc                   proc    defaults        0 0

none                    /sys                    sysfs   defaults        0 0

LABEL=SWAP-sda2         swap                    swap    defaults        0 0

/dev/sdb1               /u01                 ext3    defaults        0 0

/dev/hdc                /media/cdrom            auto    pamconsole,exec,noauto,m

anaged 0 0

/dev/fd0                /media/floppy           auto    pamconsole,exec,noauto,m

anaged 0 0

关于/etc/fstab 命令,详见:

Linux fstab 参数详解

http://blog.csdn.net/tianlesoftware/archive/2011/02/18/6194358.aspx

虚拟机Linux下扩展硬盘的方法的更多相关文章

  1. Linux 下挂载硬盘的 方法

    1. 添加磁盘,查看磁盘状况 [root@db1 /]# fdisk -l Disk /dev/sda: 10.7 GB, 10737418240 bytes 255 heads, 63 sector ...

  2. 详解VMware 虚拟机中添加新硬盘的方法

    一.VMware新增磁盘的设置步骤 (建议:在设置虚拟的时候,不要运行虚拟机的系统,不然添加了新的虚拟磁盘则要重启虚拟机) 1.选择“VM”----“设置”并打开,将光标定位在“硬盘(SCSI)”这一 ...

  3. 在Linux下禁用IPv6的方法小结

    在Linux下禁用IPv6的方法小结--http://www.jb51.net/LINUXjishu/335724.html 这篇文章主要介绍了在Linux下禁用IPv6的方法小结,禁用IPv6的操作 ...

  4. linux下定时执行任务方法【转】

     之前就转过一篇关于定时任务的文章,前俩天用,还的翻出来看!!!再转一次,备用,,需要的时候不用麻烦找! ----------------------------------------------- ...

  5. Windows 和  Linux 下 禁止ping的方法

    Windows 和Linux 下 禁止ping的方法 目的: 禁止网络上的其他主机或服务器ping自己的服务器 运行环境: Windows 03.08  linux 方法: Windows 03下: ...

  6. Linux下修改PATH的方法

    Linux下修改PATH的方法 1.直接在命令行里敲 PATH=$PATH:/path1:/path2:/pathN用户登出之后PATH恢复原样. 只是临时起作用. 2.修改~目录下bash_prof ...

  7. linux下的ImageMagick安装方法

     linux下的ImageMagick安装方法  由于没有图形化界面的支持,在Linux(CentOS 6.4 x64)上的配置相对Windows XP还是麻烦了一点.   1.下载ImageMagi ...

  8. Linux下彻底卸载LibreOffice方法

    Linux下彻底卸载LibreOffice方法 终端中输入命令: 对所有基于 Debian 的发行版(Debian.Ubuntu.Kubuntu.Xubuntu.*buntu.Sidux 等): su ...

  9. Linux下获取硬盘使用情况

    Linux下获取硬盘使用情况[总结] 1.前言 在嵌入式设备中,硬盘空间非常有限,在涉及到经常写日志的进程时候,需要考虑日志的大小和删除,不然很快就硬盘写满,导致日志程序崩溃.为了捕获硬盘写满的异常场 ...

随机推荐

  1. GitHub:IBM

    ylbtech-GitHub:IBM 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部 1. https://github.com/ibm 2.   6.返回顶部 ...

  2. 解决json_encode中文乱码问题

    关键字JSON_UNESCAPED_UNICODE即Json不要编码Unicode. $arr={"name":"你好"}; json_encode($arr, ...

  3. add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'

    发送一个报头,告诉浏览器当前页面不进行缓存,每次访问的时间必须从服务器上读取最新的数据 一般情况下,浏览器为了加快浏览速度会对网页进行缓存,在一定时间内再次访问同一页面的时候会有缓存里面读取而不是从服 ...

  4. Mysql(一)、索引研究

    一.索引简介 1. 为什么要使用索引 查询高效 2. 什么样的信息能成为索引 主键,唯一键,普通键等 二.优化你的索引 1. 二叉查找树 二叉查找树,也称二叉搜索树,或二叉排序树.其定义也比较简单,要 ...

  5. com.jniwrapper.util.ProcessorInfo

    MyEclipse 9.x Crack报错 com.jniwrapper.util.ProcessorInfo usercode or systemid is empty! 卸载JDK9,改成JDK8

  6. Delphi动态创建菜单

    在程序运行中动态创建菜单,主要使用TMeunItem类,所有菜单的条目都是TMenuItem的一个实例. 打开Delphi7集成开发环境,在默认新建工程里,放置一个Button1按钮和MainMenu ...

  7. 《Javascript 语言精粹》 中 用到的一些代码 (1)

    var isNumber = function isNumber(value){ return typeof value === 'number' && isFinite(value) ...

  8. cef加载flash的办法

    cef有2种加载flash插件的方式, 1,npapi,这种方式是调用系统自带的flash插件,由于有安全性方面的问题,已经被新版cef禁用. 2,ppapi,也就是 pepper flash,这是谷 ...

  9. python 连接SQL SERVER 并读取其数据

    1.没什么难的操作 安装  pip install pymssql import pymssql #引入pymssql模块 import pandas as pd def conn(): connec ...

  10. jmeter-ERROR o.a.j.p.j.c.DataSourceElement: JDBC data source already defined for: 报错原因

    转载自:https://www.cnblogs.com/zhangfeivip/p/9450403.html Jmeter 多个threadgroup 中的配置元件会一次性进行初始化   例如3个th ...