给虚机添加新的磁盘分区

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

 


首先关闭虚拟机,然后选择设置,添加硬盘,创建一个虚拟磁盘,选择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

 

本文来自: (www.91linux.com) 详细出处参考:http://www.91linux.com/html/article/partition/20091020/17981.html

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值