Linux系統磁碟的分區、格式化、檢驗與掛載

來源:互聯網
上載者:User

磁碟分割 - fdisk

fdisk的命令不需要記,因為輸入m後,就會看到詳細的協助資訊,如下所示:

[root@lx15 /data ]# fdisk /dev/sda        The number of cylinders for this disk is set to 36404.  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)

分區格式化 - mkfs

通過fdisk進行分區後,需要進行格式化後才能使用,分區格式化的命令很簡單 :

mkfs [-t 檔案系統格式] 裝置檔案名稱

下面是一個例子:

mkfs -t ext3 /dev/sda2

上訴例子表示以ext3格式化分區/dev/sda2

磁碟檢驗 - fsck

fsck [-t 檔案系統格式] 裝置檔案名稱

ext2/ext3檔案系統的最頂層會存在一個lost+found目錄,該目錄就是當你使用fsck檢查後,若出現問 題,有問題的資料會被放置到該目錄下,所以理想狀態下該目錄應該是空的。

磁碟的掛載 - mount

mount的命令很複雜,參數極多,但一般指需要使用預設就可以了,掛載命令 如下:

用預設將/dev/sda2掛載到目錄/home上面

mkdir /home

mount /dev/sda2 /home

重新掛載命令如下:

將/home重新掛載,並加入參數rw與auto

mount -o remount,rw,auto /home

卸載命令是unmount,後面可以跟掛載點,也可以跟分區:

unmount /home

unmount /dev/sda2

設定開機掛載 - /etc/fstab

# cat /etc/fstab  LABEL=/                 /                       ext3    defaults        1 1  LABEL=/data             /data                   ext3    defaults        1 2  LABEL=/var              /var                    ext3    defaults        1 2  LABEL=/boot             /boot                   ext3    defaults        1 2  tmpfs                   /dev/shm                tmpfs   defaults        0 0  devpts                  /dev/pts                devpts  gid=5,mode=620  0 0  sysfs                   /sys                    sysfs   defaults        0 0  proc                    /proc                   proc    defaults        0 0  LABEL=SWAP-sda5         swap                    swap    defaults        0 0

當我們執行mount命令時,會將配置寫入/etc/fstab中,下面是該檔案每一列的意義:

第一列:磁 盤裝置檔案名稱或其LABEL

第二列:掛載點

第三列:檔案系統類型

第四列:檔案系統參數

第五 列:能否被dump(0表示不要,1表示每天要dump)

第六列:設定是否開機fsck(0表示不要,1表示最 早檢驗,2表示比1遲檢驗)

查看本欄目更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

聯繫我們

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