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 -l
Disk /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: 0x0001395d
Device 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
Disk /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: 0x00000000
Disk /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_root
3.6G 1.7G 1.7G 50% /
tmpfs 939M 0 939M 0% /dev/shm
/dev/sda1 485M 32M 429M 7% /boot
[root@jifeng04 ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): 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 for help): n
Command action
e extended
p 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 action
e extended
p 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 action
e extended
p 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 2549
Command (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 -l
Disk /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: 0x0001395d
Device 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 Linux
Disk /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: 0x00000000
Disk /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_root
3.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