Chinaunix首页 | 论坛 | 博客
  • 博客访问: 94523
  • 博文数量: 21
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2009-05-21 17:02
文章分类

全部博文(21)

文章存档

2011年(1)

2009年(20)

我的朋友

分类: LINUX

2009-10-19 11:42:15

 

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


首先关闭虚拟机,然后选择设置,添加硬盘,创建一个虚拟磁盘,选择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 (制作文件系统)
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524112 blocks
26205 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@yangtk by-path]# mount -t ext3 /dev/sdb1 /data1 (挂载分区)
[root@yangtk by-path]# df -k

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
3142384 2963564 16620 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
/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

阅读(482) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~