成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

深入淺出話Linux分區管理

譯文
系統 Linux
創建Linux分區是新Linux用戶最棘手的任務之一。我在本文中將探討有關Linux分區的各個主題,將使用不同的Linux分區管理器來列出、創建、調整、擴展和刪除Linux分區。

[[262425]]

【51CTO.com快譯】創建Linux分區是新Linux用戶最棘手的任務之一。我在本文中將探討有關Linux分區的各個主題,將使用不同的Linux分區管理器來列出、創建、調整、擴展和刪除Linux分區。

Linux分區管理器

我們在本文中將使用各種Linux分區管理器對系統存儲驅動器執行CRUD(創建或克隆、讀取、刪除和更新)等操作。如果你是新的Linux用戶,可能想嘗試一種易于使用的基于GUI的工具。如果你喜歡使用命令行(CLI),我們還會介紹4款基于CLI的分區管理器。

1. 基于GUI的工具

(1)Gparted

1)列出分區

2) 創建分區

3) 調整分區大小

4) 刪除分區

2.基于CLI的工具

(1)cfdisk

1)列出分區

2)創建分區

3)調整分區大小

4)刪除分區

(2)fdisk

1)列出分區

2)創建分區

3) 刪除分區

列出Linux中的驅動器和分區

1. Gparted列出分區

Gparted是最流行最強大的Linux分區管理器。你可以對存儲驅動器輕松執行CRUD。

在Gparted中列出分區只需打開應用程序本身。加載所有系統驅動器和分區需要幾秒鐘。

gparted list linux partitions

圖1

2. cfdisk列出分區

cfdisk是一款極易使用的分區管理工具。它基于cli,但提供了易于使用的選項,可以對系統驅動器執行操作。

  1. sudo cfdisk 

只要打開該應用程序,它會列出當前存儲驅動器的所有分區。

  1. Disk: /dev/sda  
  2. Size: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  3. Label: dos, identifier: 0xa51a596a  
  4. Device Boot Start End Sectors Size Id Type  
  5. >> /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  6. /dev/sda2   19533822 50782207 31248386 14.9G 5 Extended  
  7. ├─/dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris  
  8. └─/dev/sda6 27346944 50782207 23435264 11.2G 83 Linux  
  9. /dev/sda3 50782208 63211519 12429312 5.9G 83 Linux 
  10.  
  11. ┌───────────────────────────────────────────────────────────┐ 
  12.  
  13. │Partition type: Linux (83) 
  14.  
  15. │Attributes: 80 
  16.  
  17. │Filesystem UUID: 77518fa2-4624-430d-8965-abf7b328165d 
  18.  
  19. │Filesystem: ext4 
  20.  
  21. │Mountpoint: / (mounted) 
  22.  
  23. └───────────────────────────────────────────────────────────┘ 
  24.  
  25. [Bootable] [ Delete ] [ Resize ] [ Quit ] [ Type ] [ Help ] [ Write ] [ Dump ]  
  26. Quit program without writing changes 

3. fdisk列出分區

想用fdisk列出分區,使用fdisk時使用‘l’參數。

  1. sudo fdisk -l  
  2. sandy@LinuxAndPeppermint ~ $ sudo fdisk -l  
  3. Disk /dev/sda: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  4. Units: sectors of 1 * 512 = 512 bytes  
  5. Sector size (logical/physical): 512 bytes / 512 bytes  
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes 
  7.  
  8. Disklabel type: dos  
  9. Disk identifier: 0xa51a596a  
  10. Device Boot Start End Sectors Size Id Type  
  11. /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  12. /dev/sda2 19533822 50782207 31248386 14.9G 5 Extended  
  13. /dev/sda3 50782208 63213343 12431136 5.9G 83 Linux  
  14. /dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris  
  15. /dev/sda6 27346944 50782207 23435264 11.2G 83 Linux  
  16. Partition table entries are not in disk order

創建Linux分區

1. Gparted創建新分區

在Linux中用Gparted創建分區極容易極快捷。只要選擇想要創建分區的驅動器,鼠標右擊,點擊“新建”。確保未掛載驅動器,否則“新建”選項呈灰色禁用。

​ 輸入新分區大小,點擊“添加”按鈕。

create linux partition gparted

圖2

點擊“應用”,開始創建分區。

2. cfdisk創建分區

想使用cfdisk創建新分區,以sudo權限運行cfdisk。

  1. sudo cfdisk  
  2. Disk: /dev/sda  
  3. Size: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  4. Label: dos, identifier: 0xa51a596a  
  5. Device Boot Start End Sectors Size Id Type  
  6. /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  7. /dev/sda2 19533822 50782207 31248386 14.9G 5 Extended 
  8.  
  9. ├─/dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris 
  10.  
  11. └─/dev/sda6 27346944 50782207 23435264 11.2G 83 Linux 
  12.  
  13. >> Free space 50782208 63213343 12431136 5.9G 
  14.  
  15. [ New ] [ Quit ] [ Help ] [ Write ] [ Dump ]  
  16. Create new partition from free space 

選擇你想創建分區的閑置空間。選擇“新建”,按回車鍵。

  1. Disk: /dev/sda  
  2. Size: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  3. Label: dos, identifier: 0xa51a596a  
  4. Device Boot Start End Sectors Size Id Type  
  5. /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  6. /dev/sda2 19533822 50782207 31248386 14.9G 5 Extended  
  7. ├─/dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris  
  8. └─/dev/sda6 27346944 50782207 23435264 11.2G 83 Linux  
  9. >> Free space 50782208 63213343 12431136 5.9G 
  10.  
  11. Partition size: 5.9G  
  12. May be followed by M for MiB, G for GiB, T for TiB, or S for sectors. 

輸入分區大小,按回車鍵。默認情況下,它會創建全部閑置空間大小的分區。在按回車鍵之前暫停,看看你是否真想創建全部閑置空間大小的分區。

  1. Disk: /dev/sda  
  2. Size: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  3. Label: dos, identifier: 0xa51a596a  
  4. Device Boot Start End Sectors Size Id Type  
  5. /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  6. /dev/sda2 19533822 50782207 31248386 14.9G 5 Extended  
  7. ├─/dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris  
  8. └─/dev/sda6 27346944 50782207 23435264 11.2G 83 Linux  
  9. >> /dev/sda3 50782208 63213343 12431136 5.9G 83 Linux 
  10.  
  11. ┌──────────────────────────────────────────────────────────────────┐ 
  12.  
  13. │Partition type: Linux (83) 
  14.  
  15. └──────────────────────────────────────────────────────────────────┘ 
  16.  
  17. [Bootable] [ Delete ] [ Resize ] [ Quit ] [ Type ] [ Help ] [ Write ] [ Dump ] 

一切就緒。現在選擇“寫入”,按回車鍵。它會讓你輸入“Yes”,按回車鍵。這是最后一次確認;出現該提示之后,cfdisk會創建分區。

  1. ┌────────────────────────────────────────────────────┐ 
  2.  
  3. │Partition type: Linux (83) 
  4.  
  5. └────────────────────────────────────────────────────┘ 
  6.  
  7. Are you sure you want to write the partition table to disk? yes_  
  8. Type "yes" or "no"or press ESC to leave this dialog. 

就這樣。分區已創建完畢!

  1. ┌─────────────────────────────────────────────────────┐ 
  2.  
  3. │Partition type: Linux (83) 
  4.  
  5. └─────────────────────────────────────────────────────┘ 
  6.  
  7. [Bootable] [ Delete ] [ Resize ] [ Quit ] [ Type ] [ Help ] [ Write ] [ Dump ]  
  8. The partition table has been altered. 

3. fdisk創建分區

想使用fdisk創建Linux分區,先列出分區,記下你想創建分區的設備路徑。

  1. sudo fdisk -l  
  2. sandy@LinuxAndPeppermint ~ $ sudo fdisk -l  
  3. Disk /dev/sda: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  4. Units: sectors of 1 * 512 = 512 bytes  
  5. Sector size (logical/physical): 512 bytes / 512 bytes  
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes 
  7.  
  8. Disklabel type: dos  
  9. Disk identifier: 0xa51a596a  
  10. Device Boot Start End Sectors Size Id Type  
  11. /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  12. /dev/sda2 19533822 50782207 31248386 14.9G 5 Extended  
  13. /dev/sda3 50782208 63213343 12431136 5.9G 83 Linux  
  14. /dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris  
  15. /dev/sda6 27346944 50782207 23435264 11.2G 83 Linux  
  16. Partition table entries are not in disk order

我想從/dev/sda3創建一個新分區。然后使用fdisk命令選擇分區。

  1. sandy@LinuxAndPeppermint ~ $ sudo fdisk /dev/sda3  
  2. Welcome to fdisk (util-linux 2.31.1).  
  3. Changes will remain in memory only, until you decide to write them.  
  4. Be careful before using the write command.  
  5. Device does not contain a recognized partition table 
  6. Created a new DOS disklabel with disk identifier 0x64d7e7ab.  
  7. Command (m for help): 

想創建新分區,使用‘n’命令。

  1. Command (m for help): n  
  2. Partition type  
  3. primary (0 primary, 0 extended, 4 free 
  4. e extended (container for logical partitions)  
  5. Select (default p): 

選擇分區類型。想創建主分區,使用‘p’命令,使用‘e’代表擴展類型。

  1. Select (default p): p  
  2. Partition number (1-4, default 1): 

下一步,它會要求提供分區號。使用默認值1。按回車鍵。

  1. First sector (2048-12431135, default 2048): 2048  
  2. Last sector, +sectors or +size{K,M,G,T,P} (2048-12431135, default 12431135): +2000M  
  3. Created a new partition 1 of type 'Linux' and of size 2 GiB.  
  4. Command (m for help): 

然后選擇新分區的大小。第一個扇區選擇默認值,最后一個扇區輸入以M為單位的值。比如說,想創建一個2GB大小的分區,輸入+2000M。

最后,它會顯示消息如下:'​Created a new partition 1 of type 'Linux' and of size 2 GiB. '

但分區仍未創建。想把變更寫入到磁盤,使用‘w’命令。它會顯示下列消息:"The kernel still uses the old partitions. The new table will be used at the next reboot. Syncing disks."。

​ 若要讓新分區出現,需要重啟系統。

調整Linux分區大小

1. Gparted調整分區大小

Gparted中調整分區大小很簡單。打開該應用程序,選擇想要調整大小的分區,右擊鼠標,選擇“調整大小/移動”。

resize linux partition gparted

圖3

輸入新分區大小,點擊“調整大小/移動”按鈕。最后,點擊“應用”按鈕,使剛完成的變更生效。

2. cfdisk調整分區大小

以sudo權限開啟cfdisk。

  1. sudo cfdisk 

選擇想要調整大小的分區。選擇“調整大小”選項,按回車鍵。

  1. Disk: /dev/sda  
  2. Size: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  3. Label: dos, identifier: 0xa51a596a  
  4. Device Boot Start End Sectors Size Id Type  
  5. /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  6. /dev/sda2 19533822 50782207 31248386 14.9G 5 Extended  
  7. ├─/dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris  
  8. └─/dev/sda6 27346944 50782207 23435264 11.2G 83 Linux  
  9. >> /dev/sda3 50782208 63211519 12429312 5.9G 83 Linux 
  10.  
  11. ┌──────────────────────────────────────────────────────────┐ 
  12.  
  13. │Partition type: Linux (83) 
  14.  
  15. │Filesystem UUID: 266f1f9d-5e6e-4d80-a973-4c991cf28763 
  16.  
  17. │Filesystem: ext4 
  18.  
  19. └──────────────────────────────────────────────────────────┘ 
  20.  
  21. [Bootable] [ Delete ] [ Resize ] [ Quit ] [ Type ] [ Help ] [ Write ] [ Dump ]  
  22. Reduce or enlarge the current partition 

輸入新分區大小。

  1. ┌─────────────────────────────────────────────────────┐ 
  2.  
  3. │Partition type: Linux (83) 
  4.  
  5. │Filesystem UUID: 266f1f9d-5e6e-4d80-a973-4c991cf28763 
  6.  
  7. │ Filesystem: ext4 
  8.  
  9. └─────────────────────────────────────────────────────┘ 
  10.  
  11. New size: 5.9G_  
  12. May be followed by M for MiB, G for GiB, T for TiB, or S for sectors. 

最后,選擇寫入選項,將變更寫入到磁盤。

  1. Disk: /dev/sda  
  2. Size: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  3. Label: dos, identifier: 0xa51a596a  
  4. Device Boot Start End Sectors Size Id Type  
  5. /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  6. /dev/sda2 19533822 50782207 31248386 14.9G 5 Extended  
  7. ├─/dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris  
  8. └─/dev/sda6 27346944 50782207 23435264 11.2G 83 Linux  
  9. >> /dev/sda3 50782208 57073663 6291456 3G 83 Linux  
  10. Free space 57073664 63213343 6139680 2.9G 
  11.  
  12. ┌───────────────────────────────────────────────────────────┐ 
  13.  
  14. │Partition type: Linux (83) 
  15.  
  16. │Filesystem UUID: 266f1f9d-5e6e-4d80-a973-4c991cf28763 
  17.  
  18. │Filesystem: ext4 
  19.  
  20. └───────────────────────────────────────────────────────────┘ 
  21.  
  22. [Bootable] [ Delete ] [ Resize ] [ Quit ] [ Type ] [ Help ] [ Write ] [ Dump ]  
  23. Write partition table to disk (this might destroy data) 

刪除Linux分區

1. Gparted刪除分區

想在Linux中使用GParted刪除分區,只要選擇分區,右擊鼠標,選擇刪除選項,即可刪除分區。

delete linux partition gparted

圖4

別忘了刪除分區后使變更生效。

2. cfdisk刪除分區

想使用cfdisk刪除分區,以sudo權限開啟cfdisk。

  1. sudo cfdisk 

高亮選中想刪除的分區,選擇“刪除”選項。

  1. Disk: /dev/sda  
  2. Size: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  3. Label: dos, identifier: 0xa51a596a  
  4. Device Boot Start End Sectors Size Id Type  
  5. /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  6. /dev/sda2 19533822 50782207 31248386 14.9G 5 Extended  
  7. ├─/dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris  
  8. └─/dev/sda6 27346944 50782207 23435264 11.2G 83 Linux  
  9. >> /dev/sda3 50782208 63211519 12429312 5.9G 83 Linux 
  10.  
  11. ┌──────────────────────────────────────────────────────────┐ 
  12.  
  13. │Partition type: Linux (83) 
  14.  
  15. │Filesystem UUID: 266f1f9d-5e6e-4d80-a973-4c991cf28763 
  16.  
  17. │Filesystem: ext4 
  18.  
  19. └──────────────────────────────────────────────────────────┘ 
  20.  
  21. [Bootable] [ Delete ] [ Resize ] [ Quit ] [ Type ] [ Help ] [ Write ] [ Dump ]  
  22. Delete the current partition 

最后,選擇“寫入”選項,將變更寫入到磁盤。

  1. Disk: /dev/sda  
  2. Size: 30.1 GiB, 32365232128 bytes, 63213344 sectors  
  3. Label: dos, identifier: 0xa51a596a  
  4. Device Boot Start End Sectors Size Id Type  
  5. /dev/sda1 * 2048 19531775 19529728 9.3G 83 Linux  
  6. /dev/sda2   19533822 50782207 31248386 14.9G 5 Extended  
  7. ├─/dev/sda5 19533824 27344895 7811072 3.7G 82 Linux swap / Solaris  
  8. └─/dev/sda6 27346944 50782207 23435264 11.2G 83 Linux  
  9. >> Free space 50782208 63213343 12431136 5.9G 
  10.  
  11. ┌───────────────────────────────────────────────────────────┐ 
  12.  
  13. │Filesystem UUID: 266f1f9d-5e6e-4d80-a973-4c991cf28763 
  14.  
  15. │Filesystem: ext4 
  16.  
  17. └───────────────────────────────────────────────────────────┘ 
  18.  
  19. [ New ] [ Quit ] [ Help ] [ Write ] [ Dump ]  
  20. Write partition table to disk (this might destroy data) 

3. fdisk刪除分區

想使用fdisk刪除分區,先運行fdisk,選擇想要刪除的分區。

  1. sandy@LinuxAndPeppermint ~ $ sudo fdisk /dev/sda3  
  2. Welcome to fdisk (util-linux 2.31.1).  
  3. Changes will remain in memory only, until you decide to write them.  
  4. Be careful before using the write command.  
  5. Command (m for help): 

然后使用‘d’命令刪除所選擇的分區。

  1. Command (m for help): d 

刪除后,你可以使用‘n’命令創建一個新分區,最后輸入‘w’命令,將所有變更寫入到磁盤。

結束語

以上就是管理Linux分區的方法。本文介紹了在Linux中使用三大分區管理工具,列出Linux分區、創建Linux分區、調整分區大小以及刪除分區。

原文標題:Linux Partition Management

【51CTO譯稿,合作站點轉載請注明原文譯者和出處為51CTO.com】

 

責任編輯:張燕妮 來源: 51CTO
相關推薦

2009-11-30 16:46:29

學習Linux

2021-03-16 08:54:35

AQSAbstractQueJava

2011-07-04 10:39:57

Web

2009-12-25 15:49:43

Linux rescu

2022-09-17 08:09:25

MGR故障檢測網絡

2019-01-07 15:29:07

HadoopYarn架構調度器

2021-07-20 15:20:02

FlatBuffers阿里云Java

2012-05-21 10:06:26

FrameworkCocoa

2017-07-02 18:04:53

塊加密算法AES算法

2022-09-26 09:01:15

語言數據JavaScript

2022-01-11 07:52:22

CSS 技巧代碼重構

2025-03-27 09:38:35

2021-04-27 08:54:43

ConcurrentH數據結構JDK8

2019-11-11 14:51:19

Java數據結構Properties

2022-12-02 09:13:28

SeataAT模式

2012-02-21 13:55:45

JavaScript

2022-10-31 09:00:24

Promise數組參數

2018-11-09 16:24:25

物聯網云計算云系統

2022-11-09 08:06:15

GreatSQLMGR模式

2009-11-18 13:30:37

Oracle Sequ
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 伊人狠狠操 | 中文字幕二区 | 免费黄色av | 天天玩天天干天天操 | 国产毛片久久久久久久久春天 | 亚洲欧洲综合av | 成人精品视频在线观看 | 日韩亚洲视频 | 国产精品视频入口 | 日韩av一区二区在线 | 国产免费一区二区 | 国产精品一区二区久久精品爱微奶 | 亚洲三级在线 | 久久精品国产99国产精品 | 成人a免费| 欧美日韩久久 | 99久久中文字幕三级久久日本 | 欧美在线小视频 | av网站在线播放 | 国内久久精品 | aaaaaa大片免费看最大的 | 99久久久国产精品免费消防器 | 国产在线精品一区二区三区 | 国产在线精品一区二区三区 | 久久久久久91| 欧美精品1区2区 | av第一页| 精品美女在线观看视频在线观看 | 欧美一区二区免费在线 | 国产乱精品一区二区三区 | 国产精品美女 | 欧美色性 | 国产精品久久久久久久免费观看 | 亚洲日韩中文字幕一区 | 99在线资源 | 日韩在线| 欧美成人精品一区二区男人看 | 一区二区三区四区在线视频 | 欧美日韩不卡合集视频 | 一区二区三区视频在线免费观看 | 成人在线观看免费爱爱 |