VirtualBox虚拟机添加虚拟磁盘为Linux系统扩充磁盘空间
来源:互联网 发布:豆瓣fm推荐算法 编辑:程序博客网 时间:2024/05/16 07:22
1、在虚拟机上设置-》存储-》添加磁盘
2、Linux系统进行新磁盘分区
检查现有磁盘空间
[root@maclean1 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 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: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table
Disk /dev/sde: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn't contain a valid partition table
Disk /dev/sdf: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdf doesn't contain a valid partition table
Disk /dev/sdg: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdg doesn't contain a valid partition table
Disk /dev/sdh: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdh doesn't contain a valid partition table
Disk /dev/sdi: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdi doesn't contain a valid partition table
Disk /dev/sdj: 21.4 GB, 21474836480 bytes 新添加的磁盘
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdj doesn't contain a valid partition table
Disk /dev/dm-0: 19.2 GB, 19226689536 bytes
255 heads, 63 sectors/track, 2337 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-1 doesn't contain a valid partition table
[root@maclean1 ~]# fdisk /dev/sdj sdj磁盘分区,有很多选项,我们选择m帮助信息
Command (m forhelp): n 创建一个新分区
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个柱面结束
Command (m forhelp): w 键入w,保存设置并退出,完成新磁盘分区表创建
[root@maclean1 ~]# fdisk /dev/sdj
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
我们把所有20GB空间都格式化为一个分区了,如果有朋友想划分多个分区,如下方法
Last cylinder or+size or +sizeM or +sizeK (1-2610, default 2610): 以MB为单位输入自己想要的大小即可
[root@maclean1~]# fdisk –l 我们在看一下系统磁盘空间分配情况
Disk /dev/sdj: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdj1 1 2610 20964793+ 83 Linux
下面我们给新磁盘的/dev/sdb1分区进行格式化操作
[root@maclean1 ~]# mkfs -t ext4 /dev/sdj1 用ext4格式对/dev/sdb1分区进行格式化
[root@maclean1 ~]# mount /dev/sdj1 / 将新磁盘分区挂载到/目录下,也可以创建其他目录进行挂载(mkdir /u02 在根目录上创建一个新的挂载目录/u02)
[root@maclean1 ~]# df -h 这是我们挂载新分区之后的挂载点分布
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
18G 13G 3.6G 79% /
/dev/sda1 99M 23M 71M 25% /boot
tmpfs 497M 200M 298M 41% /dev/shm
/dev/sdj1 20G 172M 19G 1% /s01
开机自动挂载新磁盘分区/dev/sdb1
[root@maclean1 ~]# cat /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/sdj1 /s01 ext4 defaults 0 0
这样在重启系统后就会自动挂载到/s01目录上
2、Linux系统进行新磁盘分区
检查现有磁盘空间
[root@maclean1 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 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: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
Disk /dev/sdd: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table
Disk /dev/sde: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sde doesn't contain a valid partition table
Disk /dev/sdf: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdf doesn't contain a valid partition table
Disk /dev/sdg: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdg doesn't contain a valid partition table
Disk /dev/sdh: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdh doesn't contain a valid partition table
Disk /dev/sdi: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdi doesn't contain a valid partition table
Disk /dev/sdj: 21.4 GB, 21474836480 bytes 新添加的磁盘
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdj doesn't contain a valid partition table
Disk /dev/dm-0: 19.2 GB, 19226689536 bytes
255 heads, 63 sectors/track, 2337 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/dm-1 doesn't contain a valid partition table
[root@maclean1 ~]# fdisk /dev/sdj sdj磁盘分区,有很多选项,我们选择m帮助信息
Command (m forhelp): n 创建一个新分区
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个柱面结束
Command (m forhelp): w 键入w,保存设置并退出,完成新磁盘分区表创建
[root@maclean1 ~]# fdisk /dev/sdj
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
我们把所有20GB空间都格式化为一个分区了,如果有朋友想划分多个分区,如下方法
Last cylinder or+size or +sizeM or +sizeK (1-2610, default 2610): 以MB为单位输入自己想要的大小即可
[root@maclean1~]# fdisk –l 我们在看一下系统磁盘空间分配情况
Disk /dev/sdj: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdj1 1 2610 20964793+ 83 Linux
下面我们给新磁盘的/dev/sdb1分区进行格式化操作
[root@maclean1 ~]# mkfs -t ext4 /dev/sdj1 用ext4格式对/dev/sdb1分区进行格式化
[root@maclean1 ~]# mount /dev/sdj1 / 将新磁盘分区挂载到/目录下,也可以创建其他目录进行挂载(mkdir /u02 在根目录上创建一个新的挂载目录/u02)
[root@maclean1 ~]# df -h 这是我们挂载新分区之后的挂载点分布
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
18G 13G 3.6G 79% /
/dev/sda1 99M 23M 71M 25% /boot
tmpfs 497M 200M 298M 41% /dev/shm
/dev/sdj1 20G 172M 19G 1% /s01
开机自动挂载新磁盘分区/dev/sdb1
[root@maclean1 ~]# cat /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/sdj1 /s01 ext4 defaults 0 0
这样在重启系统后就会自动挂载到/s01目录上
0 0
- VirtualBox虚拟机添加虚拟磁盘为Linux系统扩充磁盘空间
- 为virtualbox中的Linux虚拟机磁盘扩容
- 扩充VirtualBox上磁盘空间
- 如何扩充VirtualBox磁盘空间
- VirtualBox中为Linux添加磁盘
- VirtualBox安装的Linux虚拟机虚拟磁盘膨大问题处理
- linux系统给磁盘添加未分配的磁盘空间
- virtualbox增加ubuntu系统虚拟磁盘空间
- 为虚拟机linux扩充硬盘容量
- 给VM VirtualBox的Linux虚拟机添加虚拟硬盘
- VirtualBox虚拟机(Linux)磁盘扩容
- (VirtualBox)Linux系统上添加一块新磁盘
- (VirtualBox)Linux系统上添加一块新磁盘
- virtualbox中怎么给linux添加磁盘空间
- ubuntu虚拟机扩充磁盘
- Linux扩大虚拟机系统磁盘空间
- Linux 虚拟机根分区磁盘扩充空间记录
- 虚拟机为linux系统添加新硬盘
- Cmap和Carray以及Cstring的使用以及MFC中的文件读写
- mysql修改表的编码与修改表字段编码
- 异常处理:SSH整合中OpenSessionInViewFilter不生效问题的解决
- 基于Sqlcipher和GreenDao的数据库加密
- Assembly x64 Intro - Loop Example
- VirtualBox虚拟机添加虚拟磁盘为Linux系统扩充磁盘空间
- Storm原理
- TCP三次握手、四次拜拜
- 剑指offer系列之二十三:二叉树中和为某一值得所有路径
- java方法调用绑定
- int和Integer的区别&&String s=new String("abc")和String s = "abc"的区别
- linux基础(六)----linux命令系统学习----网络操作命令
- Android Studio 使用中遇到的问题和解决方案
- Windows下Oracle 10g instant client安装配置