VMware下LINUX的虛擬機增長磁盤空間

先關閉虛擬機電源,作以下設置:「 虛擬機」--「虛擬機設置」--「磁盤」--「擴展」node

 

 

能夠隨意添加你須要增到到的磁盤大小(如15Gb,表示磁盤總量,包含原來的磁盤容量); 再重啓電源進入系統作以下步驟設置。linux

1. 啓動虛擬機系統,用root登陸(後續全部步驟都應以root用戶身份登陸操做),在 命令行用fdisk -l查看。因爲這裏是直接修改了原始空間大小,所以能夠看到/dev/sda空間改變爲16.1GB(原磁盤空間從10G增長到15G)。若是是從VMware菜單裏增長虛擬硬盤,則會多出一個/dev/sd?,這裏的?表明硬盤編號,第一個硬盤編號爲a即sda,第二個就是sdb,第三個是sdc,以此類推,通常來講,若是之前沒有增長過硬盤,那麼原來的硬盤就是sda,經過VMware菜單增長的虛擬硬盤編號就是sdb。若是添加的第二塊硬盤是IDE硬盤,就應該看到hdb,若是是 SCSI硬盤,看到的就應該是sdb。app

2.使用fdisk /dev/sda進入菜單項,m是列出菜單,p是列出分區表,n是增長分區,w是保存並推出。因爲這裏增長的磁盤只有5G,所以5G劃爲一個區。ide

[root@localhost ~]# fdisk /dev/sdathis

The number of cylinders for this disk is set to 1958.
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)
spa

Command (m for help): p.net

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
命令行

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1305    10377990   8e  Linux LVM
3d

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1306-1958, default 1306): +1306
Last cylinder or +size or +sizeM or +sizeK (1306-1958, default 1958): +1958
Value out of range.
Last cylinder or +size or +sizeM or +sizeK (1306-1958, default 1958): 
Using default value 1958
orm

Command (m for help): p

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1305    10377990   8e  Linux LVM
/dev/sda3            1306        1958     5245222+  83  Linux

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 設備或資源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
/dev/sda3            1306        1958     5245222+  83  Linux

[root@localhost ~]# reboot                              #需reboot一下機器繼續以下步驟

[root@localhost ~]# df -h                                                                #掛載前的分區狀況
文件系統              容量  已用 可用 已用% 掛載點
/dev/mapper/VolGroup00-LogVol00
                      8.6G  2.8G  5.4G  35% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                 125M     0  125M   0% /dev/shm

3.  使用mkfs.ext3 /dev/sda3    格式化分區

[root@localhost ~]# mkfs.ext3 /dev/sda3
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
656000 inodes, 1311305 blocks
65565 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1346371584
41 block groups
32768 blocks per group, 32768 fragments per group
16000 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736

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

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@localhost ~]# cd /
[root@localhost /]# 
mkdir /cm                       #增長一個/cm

[root@localhost /]# mount /dev/sda3 /cm           #掛載分區到   /cm         
[root@localhost /]# df -h                                     #掛載後的分區狀況
文件系統              容量  已用 可用 已用% 掛載點
/dev/mapper/VolGroup00-LogVol00
                      8.6G  2.8G  5.4G  35% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                 125M     0  125M   0% /dev/shm
/dev/sda3             5.0G  139M  4.6G   3% /cm

4.設置開機自動加載     

建立加載點:mkdir /cm 掛載以後,      修改vi /etc/fstab  分區表文件,

在文件最後加上      /dev/sda3  /cm   ext3    defaults    0 0     而後保存,重啓便可。  

(注意:修改分區表若是有誤,將致使進不了linux桌面系統,但這時系統會進入commandline模式,咱們能夠在commandline模式下對有誤的fstab進行修復更改,不過默認狀況下這個commandline模式會是Read-Only file system,這意味着你的任何修改操做都是不容許的,但能夠經過命令 mount / -o remount,rw  來解除這個限制)。

 

轉自:http://blog.itpub.net/24435147/viewspace-694200/

相關文章
相關標籤/搜索