【小贴士】RedHat虚拟机mount新硬盘

命令易忘,好记性不如烂笔头,于是记下以备后用。

1.虚拟机格式化新硬盘出来,在笔记本上在移动硬盘上划出18G的空间出来,结果花了我大概三个小时。

此虚拟硬盘作为IDE Slave。

2.通过fdisk -l可以看到/dev/hdb就是新增的硬盘,还未格式化。


root@HaoRedHat: / > fdisk -l

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        2610    20860402+  8e  Linux LVM

Disk /dev/hdb: 17.1 GB, 17179869184 bytes
16 heads, 63 sectors/track, 33288 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

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

3.再用fdisk对其进行分区

root@HaoRedHat: /mnt > fdisk /dev/hdb
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.


The number of cylinders for this disk is set to 33288.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
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-33288, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-33288, default 33288):
Using default value 33288

Command (m for help): w
The partition table has been altered!

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

这时可以看到新硬盘分区成功。

root@HaoRedHat: /mnt > fdisk -l

Disk /dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        2610    20860402+  8e  Linux LVM

Disk /dev/hdb: 17.1 GB, 17179869184 bytes
16 heads, 63 sectors/track, 33288 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdb1               1       33288    16777120+  83  Linux

4.使用mkfs.ext3命令格式化该分区

root@HaoRedHat: /mnt > mkfs.ext3 /dev/hdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2097152 inodes, 4194280 blocks
209714 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
128 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Writing inode tables: done                           
Creating journal (32768 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.

5.mount到你想要的地方:)

root@HaoRedHat: /mnt > mkdir -p /disk2
root@HaoRedHat: /mnt >  mount /dev/hdb1 /disk2
root@HaoRedHat: /mnt > df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       18G   13G  3.7G  78% /
/dev/hda1              99M   11M   84M  12% /boot
tmpfs                 1.0G     0  1.0G   0% /dev/shm
/dev/hdb1              16G  173M   15G   2% /disk2

 

 

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/15415488/viewspace-616184/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/15415488/viewspace-616184/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值