【小貼士】RedHat虛擬機器mount新硬碟

viadeazhu發表於2009-10-09

命令易忘,好記性不如爛筆頭,於是記下以備後用。

1.虛擬機器格式化新硬碟出來,在筆記本上在行動硬碟上劃出18G的空間出來,結果花了我大概三個小時。

此虛擬硬碟作為IDE Slave。

2.透過fdisk -l可以看到/dev/hdb就是新增的硬碟,還未格式化。


: / > 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對其進行分割槽

: /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.

這時可以看到新硬碟分割槽成功。

: /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命令格式化該分割槽

: /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到你想要的地方:)

: /mnt > mkdir -p /disk2
: /mnt >  mount /dev/hdb1 /disk2
: /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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章