linux中的分區與格式化(五)

來源:互聯網
上載者:User

一、分區與格式化的原理
二、使用linux中的fdisk分區
三、使用mkfs建立檔案系統
四、硬碟分區的掛載;

一、分區原理
1、主要磁碟分割表(64byte):記錄分區的起始與結束柱面、主要磁碟分割個數。主要磁碟分割大小有限,不能超過四個主要磁碟分割
2、擴充分區:將一個主要磁碟分割更改成擴充分區,擴充分區支援無限個分區(邏輯分區),邏輯分區的資訊寫在擴充分區表中。

二、格式化原理
也就是建立不同的檔案系統,供資料的儲存與讀取。
常用的linux分區工具:fdisk,sfdisk,diskdruid

fdisk一般使用過程
1、運行命令:#fdisk /dev/hdX
2、添加/刪除/修改分區
3、重新啟動電腦(生效,由核心讀取分區表資訊的)

[root@server root]# fdisk /dev/hda

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

Command (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):

三、Linux的格式化工具

mkfs - 支援ext2、ext3(日誌)、vfat、msdos、jfs、reiserfs等
用法1:mkfs -t <fstype> <partition>
例:#mkfs -t ext3 /dev/hda1
用法2:mkfs.<fstype> <partition>
例:#mkfs.vfat /dev/hda2
mke2fs - 支援ext2/ext3檔案系統
用法:mke2fs [-j] <partition>
例:#mke2fs -j /dev/hdb2
 
四、硬碟分區的掛載
1、掛載命令:#mount  (臨時掛載,重啟系統無效)
例:#mount /dev/hda11 /mnt/d2
2、卸載命令:#umount
例:umount /dev/hda11
3、寫入/etc/fstab(自動掛載,系統啟動時)
/dev/hda11  /mnt/d2 /ext3 defaults 0 0

五、使用卷標掛載
1、添加卷標 —— e2label
例:#e2label /dev/hda10 test
2、根據卷標掛載
例:#mount LABEL=test /mnt/d1
3、寫入/etc/fstab
LABEL=test /mnt/d1 /ext3 defaults 0 0

六、ext2/ext3掛載選項
1、ro/rw ——唯讀/讀寫
2、exec/noexec——允許/不允許可執行
3、dev/nodev——允許/不允許裝置檔案
4、suid,sgid/nosuid/nosgid——允許/不允許suid,sgid檔案
5、atime/noatime——更新/不更新節點的訪問時間
6、async/sync——非同步/同步磁碟I/O
7、user/nouser——允許/不允許普通使用者掛載磁碟,用於/etc/fstable檔案中的選項

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.