快速业务通道

给虚拟机添加新的磁盘分区

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-04-27

简单记录一下给虚拟机添加新的磁盘分区的步骤.

关闭虚拟机,然后选择设置,添加硬盘,创建一个虚拟磁盘,选择SCSI类型,设置磁盘的容量,并指定保存的操作系统文件名称.

下面就可以启动虚拟机.

登陆到虚拟机,切换到root用户:

[root@yangtk ~]# df -k

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

3142384 2963560 16624 100% /

/dev/sda1 101086 10876 84991 12% /boot

/dev/mapper/VolGroup00-LogVol03

8919192 6665924 1792880 79% /data

tmpfs 257800 0 257800 0% /dev/shm

/dev/mapper/VolGroup00-LogVol02

1015704 34452 928824 4% /tmp

[root@yangtk disk]# cd /dev/disk/by-path

[root@yangtk by-path]# ls -l

total 0

lrwxrwxrwx 1 root root 9 Oct 21 06:00 pci-0000:00:07.1-ide-0:0 -> ../../hdc lrwxrwxrwx 1 root root 9 Oct 21 06:00 pci-0000:00:10.0-scsi-0:0:0:0 -> ../../sda lrwxrwxrwx 1 root root 10 Oct 21 06:00 pci-0000:00:10.0-scsi-0:0:0:0-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 Oct 21 06:00 pci-0000:00:10.0-scsi-0:0:0:0-part2 -> ../../sda2 lrwxrwxrwx 1 root root 9 Oct 21 06:00 pci-0000:00:10.0-scsi-0:0:1:0 -> ../../sdb

[root@yangtk by-path]# fdisk /dev/sdb -l

Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn''t contain a valid partition table

[root@yangtk by-path]# fdisk /dev/sdb (进行分区)

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.

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-261, default 1):

Using default value 1

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

Using default value 261

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table. Syncing disks.

[root@yangtk by-path]# fdisk /dev/sdb -l

Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 261 2096451 8e Linux LVM

[root@yangtk by-path]# mkdir /data1

[root@yangtk by-path]# mount -t ext3 /dev/sdb1 /data1

mount: wrong fs type, bad option, bad superblock on /dev/sdb1,

missing codepage or other error

In some cases useful info is found in syslog - try

dmesg | tail or so

[root@yangtk by-path]# mkfs.ext3 /dev/sdb1 (制作文件系统)

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号