给虚机添加新的磁盘分区
上一篇 / 下一篇 2007-11-13 00:00:00 / 个人分类:操作系统
简单记录一下给虚拟机添加新的磁盘分区的步骤。
cu9[)V _X0
首先关闭虚拟机,然后选择设置,添加硬盘,创建一个虚拟磁盘,选择SCSI类型,设置磁盘的容量,并指定保存的操作系统文件名称。
下面就可以启动虚拟机。
登陆到虚拟机,切换到root用户:
[root@yangtk ~]# df -kITPUB个人空间L7x|Ls8uM`xW4S
Filesystem 1K-blocks Used Available Use% Mounted on
(Dyc)\xI^m0/dev/mapper/VolGroup00-LogVol00
mj5[ A:wM]E0 3142384 2963560 16624 100% /ITPUB个人空间W,C0z8YdM+k3bn&X
/dev/sda1 101086 10876 84991 12% /boot
;o"?$B
o?9xL\A5N0/dev/mapper/VolGroup00-LogVol03ITPUB个人空间_(Nu4Za QV
8919192 6665924 1792880 79% /data
d?2n]'I)Q1^8O#W0tmpfs 257800 0 257800 0% /dev/shm
X K3eFW|0/dev/mapper/VolGroup00-LogVol02ITPUB个人空间^R"KU;j+^w(Y
1015704 34452 928824 4% /tmp
i$jh,eqq4b0[root@yangtk disk]# cd /dev/disk/by-pathITPUB个人空间
@/H#Bx!N+D
[root@yangtk by-path]# ls -lITPUB个人空间m)@Oj1ETm&j%q H
total 0ITPUB个人空间9dw'Af%^?~[/o
lrwxrwxrwx 1 root root 9 Oct 21 06:00 pci-0000:00:07.1-ide-0:0 -> ../../hdc
;u1O4y7~B6|0lrwxrwxrwx 1 root root 9 Oct 21 06:00 pci-0000:00:10.0-scsi-0:0:0:0 -> ../../sdaITPUB个人空间rvX;^6_F9|
lrwxrwxrwx 1 root root 10 Oct 21 06:00 pci-0000:00:10.0-scsi-0:0:0:0-part1 -> ../../sda1
_ Q+Gs4pAd-H A.g0lrwxrwxrwx 1 root root 10 Oct 21 06:00 pci-0000:00:10.0-scsi-0:0:0:0-part2 -> ../../sda2
Wy"a Ij b0lrwxrwxrwx 1 root root 9 Oct 21 06:00 pci-0000:00:10.0-scsi-0:0:1:0 -> ../../sdbITPUB个人空间LR2aj$`J jW7v1cB
[root@yangtk by-path]# fdisk /dev/sdb -l
Disk /dev/sdb: 2147 MB, 2147483648 bytes
h V3@ c.jV
Po@0255 heads, 63 sectors/track, 261 cylindersITPUB个人空间'L9TJ+A ^
Z/\+P
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
9K-c;ysAd}$I0[root@yangtk by-path]# fdisk /dev/sdbITPUB个人空间"T#\cMH
^
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,ITPUB个人空间+ReD~p7yV9N
until you decide to write them. After that, of course, the previousITPUB个人空间;x}]4WW!h
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
9qy;k2{8jfi|f0Command action
)O&_"iW ^?r*KV0 e extendedITPUB个人空间(oYY7T
K+j6A
p primary partition (1-4)ITPUB个人空间eff(Q4EvN
pITPUB个人空间"a
{%Ms#IGu6{
Partition number (1-4): 1ITPUB个人空间;Al5b5f^ jE0Oj
First cylinder (1-261, default 1): ITPUB个人空间,sBSY3nV5dv'T
Using default value 1ITPUB个人空间1]'Ni7_IAx
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261): ITPUB个人空间2hfW.pkqT!qr+d
Z
Using default value 261
Command (m for help): t
xOa6bZ&p1R0Selected partition 1
|Mu3pRN!SNh!y"gN0Hex code (type L to list codes): 8e
o:U
p)G2Dx0Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
~A3?
w;~y)G0The partition table has been altered!
Calling ioctl() to re-read partition table.
c7o-kWANO0Syncing disks.ITPUB个人空间%pb0n9lvw;h{
[root@yangtk by-path]# fdisk /dev/sdb -l
Disk /dev/sdb: 2147 MB, 2147483648 bytesITPUB个人空间)Ycc} T9w
255 heads, 63 sectors/track, 261 cylinders
D q0@ Uoh(od/R0Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id SystemITPUB个人空间 q:twFp:|}
/dev/sdb1 1 261 2096451 8e Linux LVM
@ |:U0N0h.u0[root@yangtk by-path]# mkdir /data1
)y.fgA(_uA!T9q&h0[root@yangtk by-path]# mount -t ext3 /dev/sdb1 /data1ITPUB个人空间2Ol$Xjby
mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
B$d9bO
aa-C,A0 missing codepage or other errorITPUB个人空间2KlX_rsi;w{
In some cases useful info is found in syslog - try
F5q4FkTB1}:f;v0 dmesg | tail or so
[root@yangtk by-path]# mkfs.ext3 /dev/sdb1
P}Vn&G/@U!\.R0mke2fs 1.39 (29-May-2006)ITPUB个人空间{p+B||3pk
xCb5Z
Filesystem label=ITPUB个人空间j H4lHH"_
OS type: Linux
irD z+r9g2NF*n0Block size=4096 (log=2)ITPUB个人空间%qq'W6}/}
Fragment size=4096 (log=2)ITPUB个人空间,h1iw
P2T
262144 inodes, 524112 blocksITPUB个人空间6~eL6et1w]k
26205 blocks (5.00%) reserved for the super user
SC6~qw
bU0First data block=0ITPUB个人空间%tm L:A~"L|
Maximum filesystem blocks=536870912
rn
m1D4f {,[\ V016 block groups
JN8e_/ZU'x032768 blocks per group, 32768 fragments per groupITPUB个人空间"y8`~v#SP
L d8I7\
16384 inodes per groupITPUB个人空间#X&fE;Kj[S[
Superblock backups stored on blocks: ITPUB个人空间g$FJ%v(B9T+A
32768, 98304, 163840, 229376, 294912
Writing inode tables: done ITPUB个人空间2WYPI9VX
Creating journal (8192 blocks): doneITPUB个人空间
hbv/M@ {Qf
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
,Cq,qvk)PK!sx0180 days, whichever comes first. Use tune2fs -c or -i to override.ITPUB个人空间eDPT$Go)K
[root@yangtk by-path]# mount -t ext3 /dev/sdb1 /data1
t:o$j&zrCtP0[root@yangtk by-path]# df -kITPUB个人空间afada0b
Filesystem 1K-blocks Used Available Use% Mounted on
9@)|$Z2lJ0/dev/mapper/VolGroup00-LogVol00ITPUB个人空间(T8fII\
~'P
3142384 2963564 16620 100% /
w"L
H/v9du;FZ0/dev/sda1 101086 10876 84991 12% /bootITPUB个人空间pt8g\.J'U
/dev/mapper/VolGroup00-LogVol03ITPUB个人空间r LdNwI*ae
8919192 6665924 1792880 79% /dataITPUB个人空间QY;[~0|
tmpfs 257800 0 257800 0% /dev/shm
hEZ[(@s&E-W6qn0/dev/mapper/VolGroup00-LogVol02
i HV,Z ~WVT0 1015704 34452 928824 4% /tmpITPUB个人空间9_K,?GJ$QC,w8k
/dev/sdb1 2063504 35880 1922804 2% /data1
登陆到系统,新添加的分区不会自动加载,需要在linux环境下去手工mount,首先检查新增的磁盘在linux中对应的设备名称。
使用fdisk为磁盘分区建立分区表,并设置为Linux LVM类型。
下面仍然不能直接mount,否则会报错:wrong fs type, bad option, bad superblock on /dev/sdb1
需要使用mkfs建立文件系统,下面就可以通过mount命令来加载这个磁盘了。
如果需要系统重启后可以自动加载,需要将其添加到/etc/fstab文件中,在文件中加入下面的内容既可。
/dev/sdb1 /data1 ext3 defaults 1 2
导入论坛 引用链接 收藏 分享给好友 推荐到圈子 管理 举报
TAG: