Ubuntu 添加新分區 並設置掛載點


一、創建新分區
首先查看已經有的分區:
root@ubuntu:/fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e11ac

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        1871    15021056   83  Linux
/dev/sda2            1871        1958      704513    5  Extended
/dev/sda5            1871        1958      704512   82  Linux swap / Solaris
root@ubuntu:/#
從上面的信息看出/dev/sda1、/dev/sda2兩個主分區,那么我們可以創建一個/dev/sda3
root@ubuntu:/fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help):
m for help就看的出,輸入 m 為幫助;
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help):
從上面信息知道,為添加分區,即新建分區;w 為保存。
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
創建邏輯分區還是主分區,這里輸入 p 創建主分區。
如果出現:
Selected partition 4
No free sectors available
表示沒有空閑硬盤,這時你得手動在虛擬機上添加。
接着按默認數據輸入,最后記得輸入 保存。q為退出。

二、格式化新建分區並設置掛載點
格式化:
root@ubuntu:/mkfs.ext4 /dev/sda3
創建掛載點:
root@ubuntu:/mount -t ext4 /dev/sda3 /home/work
把新建的分區掛載到/home/work目錄,/home/work目錄大小就為自己先添加的硬盤大小。
這時你就可以查看到home/work里面有個lost+found目錄。

三、讓系統開機自動掛載

只要在/etc/fstab中添加一行,做過根文件系統的應該知道:

/dev/sda3       /home/work  ext4    defaults    1   0

重啟下就可以見效了。

查看使用情況:
root@ubuntu:/df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             14784996   5147264   8886680  37% /
none                    248640       208    248432   1% /dev
none                    254244       248    253996   1% /dev/shm
none                    254244       384    253860   1% /var/run
none                    254244         0    254244   0% /var/lock
/dev/sda3             15480852   8684096   6010376  60% /home/work
root@ubuntu:/#
當然在/home/work目錄,我已經添加了很多東西。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM