linux檔案系統之檔案和分區基礎

來源:互聯網
上載者:User

linux檔案系統之檔案和分區基礎

InUnix/Linux, a file is a sequence of bytes withoutstructure. Any necessary structure (e.g. for a database) isadded by the programs that manipulate the data in the file. Linuxitself doesn’t know about the internal structure of a database file– all it does is return bytes.

對於Linux系統來說,檔案都是無結構的位元組序列。所謂任何一個有結構檔案(比如資料庫檔案)都是針對應用程式來講的,也就是說,linux不會知道檔案是什麼結構(也不需要知道的),linux只負責返回或者寫入檔案的位元組序列,具體如何解析這個檔案是由應用程式負責。

Unix/Linuxtries its best to treat every device attached to it as if it were alist of bytes. Therefore, everything, including network cards, harddrives, partitions, keyboards, printers, and plain files are treatedas file-like objects and each has a name in the file system.

Yourcomputer memory is /dev/mem.

Yourfirst hard disk is /dev/sda.

Aterminal (keyboard and screen) is /dev/tty1.

Etc.

Linux的另一個特點是,一切皆檔案的思想。linux盡最大努力把所有的裝置當成由位元組序列構成的檔案看待(其實這個思想咋一看不可思議,但是我們想一想,所有的物理裝置,最終做的是什嗎?儲存資料。不管是顯示屏/印表機/鍵盤/磁碟/usb等,都是要儲存資料的,這些資料不就是位元組序列麼,位元組序列不就是檔案麼,所以這是一種很好的物件導向的抽象思想,並且很好的實現了統一管理和透明性)。

Thereare two kinds of major partitions on a Linux system:

datapartition: normal Linux system data, including the rootpartition containing all the data to start up and run thesystem; and

swappartition: expansion of the computer's physical memory, extramemory on hard disk.

Oneof the goals of having different partitions is to achieve higher datasecurity in case of disaster. By dividing the hard disk inpartitions, data can be grouped and separated. When an accidentoccurs, only the data in the partition that got the hit will bedamaged, while the data on the other partitions will most likelysurvive.

Linux下對磁碟的組織是分區,那麼為什麼需要分區呢?一塊磁碟統一管理不就行了麼。電腦裡面所有的一切都是在tradeoff(權衡),我們會犧牲某個東西去換取另一個東西,如果另一個東西在實際生產環境中更有價值。電腦時間空間和安全永遠都在博弈。Linux分區的一個主要考慮是security安全問性。分區能夠實現更好的資料安全性從而避免災難。通過對磁碟分割,資料可以分別存放在不同的組中。一旦發生事故,只有發生事故的分區資料會損壞,而其他分區的資料不會受到太大的影響。

下面我們來看看linux下面如何查看磁碟分割和檔案系統類型:

The df command only displays information about active non-swappartitions.

df命令只會顯示已掛載的分區(檔案系統)和非交換分區的資訊。

 

下面我們掛載一個分區:

 

把/dev/sda6分區掛載到/media/kitian目錄下面。查看自己的分區,可以使用fdisk-l命令,再次df,就可以看到掛載上的/dev/sda6了

df命令看不到檔案系統的類型,那麼我們使用另一個工具parted;parted可以看到所有分區的具體資訊(包括檔案系統類型)

 

進入parted工具後輸入printlist命令,就可以看到了。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.