vmware中新增Linux虛擬機器檔案系統空間

綠蘿綠蘿123發表於2016-02-03
1、在vmware中調整硬碟的大小
2、

啟動Linux,鍵入df -h檢視磁碟資訊:

[plain] 
  1. [root@localhost ~]# df -h  
  2. Filesystem            Size  Used Avail Use% Mounted on  
  3. /dev/mapper/VolGroup00-LogVol00  
  4.                        29G   26G  2.3G  92% /  
  5. /dev/sda1             190M   13M  168M   7% /boot  
  6. tmpfs                 506M   48K  506M   1% /dev/shm  
  7. gvfs-fuse-daemon       29G   26G  2.3G  92% /root/.gvfs  

可以看到新增加的硬碟容量並沒有體現在Linux中。使用fdisk -l檢視分割槽表資訊。我的資訊是:

[plain] 
  1. [root@localhost ~]# fdisk -l  
  2.   
  3. Disk /dev/sda: 42.9 GB, 42949672960 bytes  
  4. 255 heads, 63 sectors/track, 5221 cylinders  
  5. Units = cylinders of 16065 * 512 = 8225280 bytes  
  6. Disk identifier: 0x000f1526  
  7.   
  8.    Device Boot      Start         End      Blocks   Id  System  
  9. /dev/sda1   *           1          25      200781   83  Linux  
  10. /dev/sda2              26        3916    31254457+  8e  Linux LVM  

注意Disk /Dev/sda有40多G空間(剛剛透過VMWare擴充套件的),但兩個Device /dev/sda1和/dev/sda2加起來只有30多G,有10G空間沒有被使用。

從調整分割槽表入手,調整分割槽表用fdisk。這個過程需要人機互動,我在需要輸入的地方加註釋來說明

[plain] 
  1. [root@localhost ~]# fdisk /dev/sda  
  2.   
  3. The number of cylinders for this disk is set to 5221.  
  4. There is nothing wrong with that, but this is larger than 1024,  
  5. and could in certain setups cause problems with:  
  6. 1) software that runs at boot time (e.g., old versions of LILO)  
  7. 2) booting and partitioning software from other OSs  
  8.    (e.g., DOS FDISK, OS/2 FDISK)  
  9.   
  10. Command (m for help): n       //選擇n表示新建分割槽  
  11. Command action  
  12.    e   extended  
  13.    p   primary partition (1-4)  
  14. e                             //選擇e表示建立擴充套件分割槽  
  15. Partition number (1-4): 3     //選擇3是因為1和2都被佔了(/dev/dsa1和/dev/dsa2)  
  16. First cylinder (3917-5221, default 3917):                               //此分割槽起始柱面,直接按回車,使用預設值  
  17. Using default value 3917  
  18. Last cylinder or +size or +sizeM or +sizeK (3917-5221, default 5221):   //此分割槽大小,直接按回車,使用預設值(表明包含所有剩餘空間)  
  19. Using default value 5221  
  20.   
  21. Command (m for help): n       //在擴充套件分割槽基礎上新建邏輯分割槽  
  22. Command action  
  23.    l   logical (5 or over)  
  24.    p   primary partition (1-4)  
  25. l                             //選擇l表示新建邏輯分割槽  
  26. First cylinder (3917-5221, default 3917):                               //直接按回車  
  27. Using default value 3917  
  28. Last cylinder or +size or +sizeM or +sizeK (3917-5221, default 5221):   //直接按回車  
  29. Using default value 5221  
  30.   
  31. Command (m for help): p       //選擇p檢視新的分割槽表,發現已經新建成功  
  32.   
  33. Disk /dev/sda: 42.9 GB, 42949672960 bytes  
  34. 255 heads, 63 sectors/track, 5221 cylinders  
  35. Units = cylinders of 16065 * 512 = 8225280 bytes  
  36. Disk identifier: 0x000f1526  
  37.   
  38.    Device Boot      Start         End      Blocks   Id  System  
  39. /dev/sda1   *           1          25      200781   83  Linux  
  40. /dev/sda2              26        3916    31254457+  8e  Linux LVM  
  41. /dev/sda3            3917        5221    10482412+   5  Extended  
  42. /dev/sda5            3917        5221    10482381   83  Linux  
  43.   
  44. Command (m for help): w       //選擇w儲存  
  45. The partition table has been altered!  
  46.   
  47. Calling ioctl() to re-read partition table.  
  48.   
  49. WARNING: Re-reading the partition table failed with error 16: Device or resource busy.  
  50. The kernel still uses the old table.  
  51. The new table will be used at the next reboot.  
  52. Syncing disks.  

可以看到新增了/dev/sda3擴充套件分割槽和/dev/sda5邏輯分割槽。如果是新增了一塊硬碟,也可以直接新建一個主分割槽,步驟更簡單些。

鍵入partprobe命令,這個命令用於在硬碟分割槽發生改變時,更新Linux核心中讀取的硬碟分割槽表資料。

[plain] 
  1. [root@localhost ~]# partprobe  

我們使用ext3格式化/dev/sda5這個新的分割槽

[plain]
  1. [root@localhost ~]# mkfs -t ext3 /dev/sda5  
  2. mke2fs 1.40.8 (13-Mar-2008)  
  3. Warning: 256-byte inodes not usable on older systems  
  4. Filesystem label=  
  5. OS type: Linux  
  6. Block size=4096 (log=2)  
  7. Fragment size=4096 (log=2)  
  8. 655360 inodes, 2620595 blocks  
  9. 131029 blocks (5.00%) reserved for the super user  
  10. First data block=0  
  11. Maximum filesystem blocks=2684354560  
  12. 80 block groups  
  13. 32768 blocks per group, 32768 fragments per group  
  14. 8192 inodes per group  
  15. Superblock backups stored on blocks:   
  16.     32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632  
  17.   
  18. Writing inode tables: done                              
  19. Creating journal (32768 blocks): done  
  20. Writing superblocks and filesystem accounting information: done  
  21.   
  22. This filesystem will be automatically checked every 32 mounts or  
  23. 180 days, whichever comes first.  Use tune2fs -c or -i to override.

3、掛載到檔案系統
mkdir /software
mount -t ext3 /dev/sda5

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29820633/viewspace-1986036/,如需轉載,請註明出處,否則將追究法律責任。

相關文章