Virtualbox中Linux添加新磁盘并创建分区
原文:https://www.linuxidc.com/Linux/2017-01/139616.htm
------------------------------------------------------------------
引言:我们常常在使用系统的时候突然发现,哎呦~~~我们的磁盘空间不够用啦!我遇到常见的就是数据库数据暴增,预留的空间没有啦,只好新添加磁盘,在VB虚拟机上就可以实现,往往苦于没有图文并茂的好资料,下面我来为大家简单快捷的实操示范一下,做一名“实操族”偶耶!
一 virtualbox 设置添加磁盘
![](https://www.linuxidc.com/upload/2017_01/170116220252671.jpg)
![](https://www.linuxidc.com/upload/2017_01/170116220252672.jpg)
它会问你,添加虚拟磁盘是要创建一个新文件来保存数据,还是选择一个现有文件保存,我们选择“创建新的虚拟磁盘”
![](https://www.linuxidc.com/upload/2017_01/170116220252673.jpg)
这时又让你选择“虚拟磁盘文件类型”,请注意90%都是选择VDI(虚拟磁盘映像)类型的,如果你的系统没有什么特殊需求,请选择第一个。点击“下一步”
![](https://www.linuxidc.com/upload/2017_01/170116220252674.jpg)
![](https://www.linuxidc.com/upload/2017_01/170116220252675.jpg)
虚拟磁盘映像文件的路径:E:\Vritaulbox\leonarding2.vdi
虚拟磁盘映像文件的大小:20GB
点击“创建”
![](https://www.linuxidc.com/upload/2017_01/170116220252676.jpg)
二 Linux系统进行新磁盘分区
[root@leonarding1~]# fdisk –l 检查现有系统磁盘空间
Disk/dev/sda: 21.4 GB, 21474836480 bytes 这是我们原来的那块旧磁盘
255 heads, 63sectors/track, 2610 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System 旧磁盘就分了2个分区
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2610 20860402+ 8e Linux LVM
Disk/dev/sdb: 21.4 GB, 21474836480 bytes 这是我们新添加的磁盘/dev/sdb,还没有分区
255 heads, 63sectors/track, 2610 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Disk /dev/sdbdoesn't contain a valid partition table 不包含有效分区表信息,我们需要给新磁盘创建分区表
Disk /dev/dm-0:18.2 GB, 18253611008 bytes 下面这些都不用管
255 heads, 63sectors/track, 2219 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Disk /dev/dm-0doesn't contain a valid partition table
Disk /dev/dm-1:3087 MB, 3087007744 bytes
255 heads, 63sectors/track, 375 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Disk /dev/dm-1doesn't contain a valid partition table
[root@leonarding1~]# fdisk /dev/sdb sdb磁盘分区,有很多选项,我们选择m帮助信息
Device containsneither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOSdisklabel. Changes will remain in memory only,
until you decideto write them. After that, of course, the previous
content won't be recoverable.
The number ofcylinders for this disk is set to 2610.
There is nothingwrong with that, but this is larger than 1024,
and could incertain setups cause problems with:
1) software thatruns at boot time (e.g., old versions of LILO)
2) booting andpartitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalidflag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m forhelp): 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 forhelp): n 创建一个新分区
Command action
e extended
p primary partition (1-4)
p 选择p添加主分区
Partition number(1-4): 1 选择主分区编号为1,这样创建后的主分区为sdb1
First cylinder(1-2610, default 1): 选择格式化分区从第几个柱面开始
Using defaultvalue 1 直接“回车”默认从第1个柱面开始
Last cylinder or+size or +sizeM or +sizeK (1-2610, default 2610): 选择格式化分区从第几个柱面结束
Using defaultvalue 2610 直接“回车”默认从最后1个柱面结束
我们把所有20GB空间都格式化为一个分区了,如果有朋友想划分多个分区,如下方法
Last cylinder or+size or +sizeM or +sizeK (1-2610, default 2610): 以MB为单位输入自己想要的大小即可
这样我们就创建完一个分区,如果要创建更多分区可以照上面的步骤继续创建。
Command (m forhelp): w 键入w,保存设置并退出,完成新磁盘分区表创建
The partitiontable has been altered!
Calling ioctl() tore-read partition table.
Syncing disks.
[root@leonarding1~]# fdisk –l 我们在看一下系统磁盘空间分配情况
Disk /dev/sda:21.4 GB, 21474836480 bytes
255 heads, 63sectors/track, 2610 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2610 20860402+ 8e Linux LVM
Disk/dev/sdb: 21.4 GB, 21474836480 bytes 这时我们可以看到新磁盘已经加入分区表了
255heads, 63 sectors/track, 2610 cylinders
Units =cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux
下面我们给新磁盘的/dev/sdb1分区进行格式化操作
[root@leonarding1~]# mkfs -t ext4 /dev/sdb1 用ext4格式对/dev/sdb1分区进行格式化
mke4fs 1.41.12(17-May-2010)
Filesystem label=
OS type: Linux 操作系统类型Linux
Block size=4096(log=2) 操作系统块大小4k
Fragment size=4096(log=2)
Stride=0 blocks,Stripe width=0 blocks
1310720 inodes,5241198 blocks
262059 blocks(5.00%) reserved for the super user
First data block=0
Maximum filesystemblocks=4294967296
160 block groups
32768 blocks pergroup, 32768 fragments per group
8192 inodes pergroup
Superblock backupsstored on blocks:
32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632, 2654208,
4096000
Writing inodetables: done
Creating journal(32768 blocks): done
Writingsuperblocks and filesystem accounting information: done
This filesystemwill be automatically checked every 35 mounts or
180 days,whichever comes first. Use tune4fs -c or-i to override.
到此我们的新分区格式化完毕,下面我们就要挂载上分区就可以使用啦!
[root@leonarding1~]# df –h 这是我们还没有挂载新分区之前的挂载点分布
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
17G 15G 1.6G 90% /
/dev/sda1 99M 23M 71M 25% /boot
tmpfs 731M 320M 411M 44% /dev/shm
/dev/sr0 55M 55M 0 100% /media/VBOXADDITIONS_4.2.6_82870
[root@leonarding1/]# mkdir /u02 在根目录上创建一个新的挂载目录/u02
[root@leonarding1/]# mount /dev/sdb1 /u02 将新磁盘分区挂载到/u02目录下
[root@leonarding1/]# df –h 这是我们挂载新分区之后的挂载点分布
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
17G 15G 1.6G 90% /
/dev/sda1 99M 23M 71M 25% /boot
tmpfs 731M 320M 411M 44% /dev/shm
/dev/sr0 55M 55M 0 100% /media/VBOXADDITIONS_4.2.6_82870
/dev/sdb1 20G 172M 19G 1% /u02
现在我们可以正常使用新添加的磁盘空间了
[root@leonarding1/]# cd /u02
[root@leonarding1u02]# mkdir app 创建一个app目录试试
[root@leonarding1u02]# ll
total 20
drwxr-xr-x 2 rootroot 4096 Apr 14 09:12 app ok成功创建木有问题
drwx------ 2 rootroot 16384 Apr 14 08:59 lost+found
到此Virtualbox中Linux添加一个新磁盘->创建分区->格式化->挂载分区系列操作完毕
Virtualbox 添加磁盘创建分区 格式化 挂载分区
开机自动挂载新磁盘分区/dev/sdb1
[root@leonarding1 /]# vim /etc/fstab 修改文件,在文件最后新增一行
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/dev/sdb1 /u02 ext4 defaults 0 0
这样在重启系统后就会自动挂载到/u02目录上
Virtualbox中Linux添加新磁盘并创建分区的更多相关文章
- linux添加新磁盘和创建分区
Linux磁盘概念及其管理工具fdisk:http://www.linuxidc.com/Linux/2016-08/134664.htm 一. 进入linux虚拟机 右键 open in termi ...
- Linux添加新硬盘,设置分区和开机自动挂载之图文教程!
虚拟机添加硬盘的步骤就不多废话了,主要列出添加硬盘后要进行设置的几个详细步骤: 1.查看磁盘信息:fdisk -ls 添加前如下图所示: 添加后如下图: 也可以用:ls /dev/sd*查看,如下图: ...
- Linux 添加新磁盘 && 创建分区 && 挂载
参考: 挂载目录 分区:https://blog.csdn.net/arenn/article/details/78866251 挂载:https://www.jb51.net/article/108 ...
- Linux 添加新磁盘,在线扩充空间
CentOS 7开发环境中的home 目录空间满了,需要增加空间 到虚拟机上执行"ls /sys/class/scsi_host",然后重新扫描SCSI总线来添加设备.如右图.然后 ...
- linux添加新磁盘
先fdisk -l 看一下有哪些没有挂载的盘符. 然后将创建的文件夹与待挂载的盘符绑定,即:mount /dev/vdc /data
- Linux系统格式化新磁盘并挂载分区
Linux系统格式化新磁盘并挂载分区 在虚拟机的设置界面中,我们可以选择添加硬盘 添加好硬盘后,我们输入命令fdisk -l 看到有一个未经分区的硬盘 Fdisk命令编辑这个硬盘 输入n创建分区,p选 ...
- linux添加新LUN,无需重启
linux添加新LUN,无需重启 在给存储增加新的Lun时,在linux下一般是: A.重启操作系统B.重启HBA卡驱动 1. kudzu添加完新硬盘后,运行命令kudzu重新扫描新的硬件设备,类似a ...
- VMWare EXSi 添加新磁盘时 报错 HostStorageSystem.ComputeDiskPartitionInfo 的处理
给 VMWare EXSi 添加新磁盘时报错 : Call "HostStorageSystem.ComputeDiskPartitionInfo" for object &quo ...
- 给Linux添加新用户,新建用户,新建帐号
给Linux添加新用户,新建用户,新建帐号 添加用户组 sudo groupadd groupname 添加用户 sudo useradd username -m -s /sbin/nologin - ...
随机推荐
- 转:C++模板学习
C++ 模板 转:http://www.runoob.com/cplusplus/cpp-templates.html 2018-01-05 模板是泛型编程的基础,泛型编程即以一种独立于任何特定类型的 ...
- 工厂bean和bean工厂
FactoryBean(工厂bean):是bean的加工工厂,是对已知Bean的加工,是一个接口,要实现三个方法: ① Object getObject()可以对bean进行加工添加功能. ② Cla ...
- Redis学习篇(十一)之发布订阅
PUBLISH/SUBSCRIBE 发布订阅的原理 包含两个角色,一个是发布者, 一个是订阅者 订阅者可以订阅一个或者多个频道(channel) 发布者可以向指定的频道发布信息 通过SUBSCRIBE ...
- Hibernate fetching strategies(抓取策略)
抓取策略(fetching strategies)是指:当应用程序需要在(Hibernate实体对象图的)关联关系间进行导航的时候,Hibernate如何获取关联对象的策略.抓取策略可以在O/R映射的 ...
- Parse要垮了
一清早收到邮件就睡不着了... 花了那么多时间熟悉api,第一个基于parse的app也要做完了... 看来国内的类似产品也不敢用了,还是老老实实用阿里云自己写backend吧...
- hdu 1711
读入优化有3s多. #include <cstdio> #include <cctype> #define maxn 1000010 #define maxm 10010 in ...
- css选择器:first-child和nth-child 采坑记
今天想用nth-child来给一个类似于树的目录(bootstrap-nav-tree 一个angularjs插件)设置不同的颜色,结构大致类似于 <ul> <li class=& ...
- js利用正则替换图片路径问题
/* * 需求:给图片的src地址前面增加为assets * * 1. 将需要匹配的内容原封不动的写入正则表达式 * 2. 将改变的内容替换为.*? * 3. 将.*?添加(),目的是为了能够将src ...
- 2038: [2009国家集训队]小Z的袜子(hose) (莫队算法)
题目链接: http://www.lydsy.com/JudgeOnline/problem.php?id=2038 专题练习: http://acm.hust.edu.cn/vjudge/conte ...
- Use a TL431 shunt regulator to limit high ac input voltage
Most isolated, offline SMPSs (switched-mode power supplies), including flyback, forward, and resonan ...