VisualBox中增大linux硬盘空间的方法

1:在VisualBox的安装目录命令行中执行

VBoxManage.exe modifyhd e:\os\RedHat5.6.vdi --resize 20000

把RedHat5.6.vdi 改为20G,必须停止虚拟机

2:进入linux,root操作

fdisk -l 

可以看到/dev/sda变 21G了。

[jifeng@jifeng04 ~]$ su -
密码:
[root@jifeng04 ~]# fdisk -lDisk /dev/sda: 21.0 GB, 20971520000 bytes
255 heads, 63 sectors/track, 2549 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001395dDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1045     7875584   8e  Linux LVMDisk /dev/mapper/VolGroup-lv_root: 3833 MB, 3833593856 bytes
255 heads, 63 sectors/track, 466 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 4227 MB, 4227858432 bytes
255 heads, 63 sectors/track, 514 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
从1046到2549没有划分磁盘,也就是说这一部分是未分区的。

3:创建分区

[root@jifeng04 ~]# df -lh
文件系统              容量  已用  可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root3.6G  1.7G  1.7G  50% /
tmpfs                 939M     0  939M   0% /dev/shm
/dev/sda1             485M   32M  429M   7% /boot[root@jifeng04 ~]# fdisk /dev/sdaWARNING: DOS-compatible mode is deprecated. It's strongly recommended toswitch off the mode (command 'c') and change display units tosectors (command 'u').Command (m for help): m
Command actiona   toggle a bootable flagb   edit bsd disklabelc   toggle the dos compatibility flagd   delete a partitionl   list known partition typesm   print this menun   add a new partitiono   create a new empty DOS partition tablep   print the partition tableq   quit without saving changess   create a new empty Sun disklabelt   change a partition's system idu   change display/entry unitsv   verify the partition tablew   write table to disk and exitx   extra functionality (experts only)Command (m for help): n
Command actione   extendedp   primary partition (1-4)
p
Partition number (1-4): 1
Partition 1 is already defined.  Delete it before re-adding it.Command (m for help): n
Command actione   extendedp   primary partition (1-4)
p
Partition number (1-4): 2
Partition 2 is already defined.  Delete it before re-adding it.Command (m for help): n
Command actione   extendedp   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1045-2549, default 1045): 
Using default value 1045
Last cylinder, +cylinders or +size{K,M,G} (1045-2549, default 2549): 
Using default value 2549Command (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
多出了一个sda3
[root@jifeng04 ~]# fdisk -lDisk /dev/sda: 21.0 GB, 20971520000 bytes
255 heads, 63 sectors/track, 2549 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001395dDevice Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        1045     7875584   8e  Linux LVM
/dev/sda3            1045        2549    12086234+  83  LinuxDisk /dev/mapper/VolGroup-lv_root: 3833 MB, 3833593856 bytes
255 heads, 63 sectors/track, 466 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000Disk /dev/mapper/VolGroup-lv_swap: 4227 MB, 4227858432 bytes
255 heads, 63 sectors/track, 514 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

必须重启

[root@jifeng04 ~]# reboot

4:格式化

[root@jifeng04 ~]# mkfs.ext3     /dev/sda3
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
755904 inodes, 3021558 blocks
151077 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=3095396352
93 block groups
32768 blocks per group, 32768 fragments per group
8128 inodes per group
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
5:挂载硬盘
[root@jifeng04 /]# mount -t ext3 /dev/sda3 /storage
[root@jifeng04 /]# df -h
文件系统              容量  已用  可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root3.6G  1.7G  1.7G  50% /
tmpfs                 939M     0  939M   0% /dev/shm
/dev/sda1             485M   32M  429M   7% /boot
/dev/sda3              12G  157M   11G   2% /storage

6:自动挂载硬盘

vi /etc/fstab,最后一行加上

[root@jifeng04 ~]# cat /etc/fstab#
# /etc/fstab
# Created by anaconda on Thu Jul 31 18:17:27 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/VolGroup-lv_root /                       ext4    defaults        1 1
UUID=c60714d0-963f-417e-b171-33f3cd10ea25 /boot                   ext4    defaults        1 2
/dev/mapper/VolGroup-lv_swap swap                    swap    defaults        0 0
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/sda3               /storage                ext3    defaults        1 2



本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部