服務器新硬盤分區、格式化、掛載、開機自動掛載


有時服務器需要添加新的硬盤,添加之后要經過分區、格式化、掛載才能使用,還要做開機自動掛載!

1.分區一般使用fdisk命令,參數-l:

#fdisk -l


Disk /dev/sda: 600.1 GB, 600127266816 bytes
255 heads, 63 sectors/track, 72961 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: 0x000862c9

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 3851 30720000 83 Linux
/dev/sda3 3851 4373 4194304 82 Linux swap / Solaris

Disk /dev/sdd: 600.1 GB, 600127266816 bytes
255 heads, 63 sectors/track, 72961 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: 0x00000000


Disk /dev/sdb: 600.1 GB, 600127266816 bytes
255 heads, 63 sectors/track, 72961 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: 0x000862c9

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2 26 3851 30720000 83 Linux
/dev/sdb3 3851 4373 4194304 82 Linux swap / Solaris

你可以看到有幾塊盤,大小,分區情況!

   找到你新加的硬盤,進行分區,命令還是fdisk:  

   以/dev/sdc為例;

#fdisk /dev/sdc


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,看下有哪些參數

按下p,打印已經分區好的信息

按下n,新建分區,然后選擇開始分區的地方、結束分區的地方;再次按下p,看下分區信息,按下w,保存;按下q,退出!!!

記住:分好區可以按下w保存,如果分區錯了,不要按下w,直接按下q,離開並且不會保存你剛剛進行的分區操作!

 

2.格式化分區

# mkfs.ext4  /dev/sdc1

等着就行,一般不會報錯

 

3.掛載

先創建掛載點/目錄

mkdir  /xmon/

 

直接掛載

mount  /dev/sdc1  /xmon

4.開機自動掛載  實現方式很多

     (1)#vim  /etc/fstab

     增加一行    /dev/sdc1      /xmon      ext4  defaults   0    0

     (2)寫入/etc/rc/loacl文件

      /dev/sdc1      /xmon      ext4  defaults   0    0

等等,也可以寫入其他開機會讀取的配置文件或者是系統的環境變量!

 


免責聲明!

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



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