亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄
Using fdisk to Partition a Disk
Using parted for GPT and Large Disks
Key Differences and Best Practices
Final Notes
首頁 系統(tǒng)教程 操作系統(tǒng) Linux磁盤分區(qū)的指南,并``fdisk''and'panded'

Linux磁盤分區(qū)的指南,并``fdisk''and'panded'

Aug 02, 2025 am 07:14 AM

fdisk適用于MBR分區(qū)表且磁盤小于2TB時(shí)使用,適合簡單交互式操作;1. 使用fdisk時(shí)先用p查看當(dāng)前分區(qū)表,n創(chuàng)建新分區(qū),t設(shè)置類型,w保存更改;2. parted適用于大于2TB的磁盤或需要GPT支持時(shí),可進(jìn)行腳本化操作;3. 使用parted時(shí)先mklabel gpt創(chuàng)建GPT標(biāo)簽,unit設(shè)置單位,mkpart創(chuàng)建分區(qū),print查看結(jié)果,quit退出;4. 兩者均需謹(jǐn)慎核對設(shè)備名稱,避免誤操作導(dǎo)致數(shù)據(jù)丟失;5. 格式化分區(qū)使用mkfs命令,掛載后方可使用;始終在操作前備份重要數(shù)據(jù)并確認(rèn)設(shè)備名稱無誤。

A Guide to Linux Disk Partitioning with `fdisk` and `parted`

Linux disk partitioning is a fundamental skill for system administrators and power users. Whether you're setting up a new drive, resizing partitions, or preparing for a fresh OS install, knowing how to use tools like fdisk and parted gives you full control over your storage layout. While both tools serve the same basic purpose—creating and managing disk partitions—they differ in capabilities and use cases.

A Guide to Linux Disk Partitioning with `fdisk` and `parted`

Here’s a practical guide to using fdisk and parted, when to use each, and what you need to know to avoid common pitfalls.


When to Use fdisk vs. parted

Use fdisk when:

A Guide to Linux Disk Partitioning with `fdisk` and `parted`
  • You're working with MBR (Master Boot Record) partition tables.
  • The disk is under 2TB in size.
  • You prefer a simple, text-based interactive interface.
  • You don’t need advanced features like resizing or non-destructive operations.

fdisk is reliable, widely available, and great for basic partitioning tasks on older-style disks.

Use parted when:

A Guide to Linux Disk Partitioning with `fdisk` and `parted`
  • The disk is larger than 2TB.
  • You need GPT (GUID Partition Table) support.
  • You want to resize, move, or copy partitions (with caution).
  • You’re scripting partitioning tasks (supports non-interactive mode).

parted is more modern and flexible, especially for large drives and advanced setups.


Using fdisk to Partition a Disk

Let’s walk through creating a new partition on /dev/sdb using fdisk.

  1. Start fdisk:

    sudo fdisk /dev/sdb
  2. Check current partition table: At the prompt, type p to print the current partition layout.

  3. Create a new partition:

    • Type n to create a new partition.
    • Choose p for primary (or e for extended).
    • Accept default values or specify sector ranges.
    • Confirm the partition size (e.g., 20G for 20GB).
  4. Set the partition type (optional):

    • Type t to change the partition type.
    • Enter the partition number.
    • Choose a type code (e.g., 8e for Linux LVM, 82 for swap).
  5. Write changes:

    • Type w to write the new partition table to disk and exit.
    • Or q to quit without saving.

?? Warning: w applies changes immediately. There’s no undo.

  1. Notify the kernel of changes:

    sudo partprobe /dev/sdb

    Or reboot if needed.

  2. Format and use:

    sudo mkfs.ext4 /dev/sdb1
    sudo mkdir /mnt/mydisk
    sudo mount /dev/sdb1 /mnt/mydisk

Using parted for GPT and Large Disks

For disks over 2TB or when using UEFI systems, GPT is required. fdisk can technically handle GPT (via gdisk), but parted is better suited.

  1. Check disk and use parted:

    sudo parted /dev/sdc
  2. Create a GPT partition table: Inside parted, run:

    (parted) mklabel gpt
  3. Set unit (optional, for clarity):

    (parted) unit GB
  4. Create a partition:

    (parted) mkpart primary 0GB 50GB

    This creates a 50GB partition. You can also specify ext4, xfs, etc., though parted doesn’t format—it only defines layout.

  5. List and verify:

    (parted) print
  6. Exit:

    (parted) quit
  7. Format and mount:

    sudo mkfs.ext4 /dev/sdc1
    sudo mount /dev/sdc1 /mnt/bigdisk

? Tip: You can run parted non-interactively:

sudo parted /dev/sdc mkpart primary 0% 100%

Key Differences and Best Practices

  • Partition table support:

    • fdisk: Best for MBR (limited to 2TB, max 4 primary partitions).
    • parted: Supports both MBR and GPT; essential for large drives.
  • Interactive vs. scriptable:

    • fdisk is mostly interactive.
    • parted supports batch mode—great for automation.
  • Resizing:

    • parted can resize partitions (with resizepart), but always back up data first.
    • fdisk does not support resizing.
  • Safety:

    • Always double-check the device name (/dev/sda, /dev/sdb, etc.). Wiping the wrong disk is irreversible.
    • Use lsblk or fdisk -l to list disks before starting.
  • UEFI systems:

    • Use GPT and create an EFI System Partition (ESP) (type ef00 in gdisk or set appropriately in parted).

Final Notes

Both fdisk and parted are powerful, but they serve different needs. For traditional setups with smaller disks, fdisk is perfectly adequate. For modern systems with large drives, UEFI, or GPT requirements, parted is the better choice.

You don’t need to pick one forever—knowing both gives you flexibility. Just remember: always back up critical data before repartitioning, and verify device names carefully.

Basically, start with fdisk for simple tasks, switch to parted when you hit its limits.

以上是Linux磁盤分區(qū)的指南,并``fdisk''and'panded'的詳細(xì)內(nèi)容。更多信息請關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

本站聲明
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅(qū)動的應(yīng)用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用于從照片中去除衣服的在線人工智能工具。

Clothoff.io

Clothoff.io

AI脫衣機(jī)

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智能換臉工具輕松在任何視頻中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的代碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

功能強(qiáng)大的PHP集成開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級代碼編輯軟件(SublimeText3)

在RHEL,Rocky和Almalinux中安裝LXC(Linux容器) 在RHEL,Rocky和Almalinux中安裝LXC(Linux容器) Jul 05, 2025 am 09:25 AM

LXD被描述為下一代容器和虛擬機(jī)管理器,它為在容器內(nèi)部或虛擬機(jī)中運(yùn)行的Linux系統(tǒng)提供了沉浸式的。 它為有支持的Linux分布數(shù)量提供圖像

在Linux桌面中加快Firefox瀏覽器的7種方法 在Linux桌面中加快Firefox瀏覽器的7種方法 Jul 04, 2025 am 09:18 AM

Firefox瀏覽器是大多數(shù)現(xiàn)代Linux分布(例如Ubuntu,Mint和Fedora)的默認(rèn)瀏覽器。最初,它的性能可能令人印象深刻,但是隨著時(shí)間的流逝,您可能會注意到瀏覽器的快速和響應(yīng)不佳

如何在Linux機(jī)器上解決DNS問題? 如何在Linux機(jī)器上解決DNS問題? Jul 07, 2025 am 12:35 AM

遇到DNS問題時(shí)首先要檢查/etc/resolv.conf文件,查看是否配置了正確的nameserver;其次可手動添加如8.8.8.8等公共DNS進(jìn)行測試;接著使用nslookup和dig命令驗(yàn)證DNS解析是否正常,若未安裝這些工具可先安裝dnsutils或bind-utils包;再檢查systemd-resolved服務(wù)狀態(tài)及其配置文件/etc/systemd/resolved.conf,并根據(jù)需要設(shè)置DNS和FallbackDNS后重啟服務(wù);最后排查網(wǎng)絡(luò)接口狀態(tài)與防火墻規(guī)則,確認(rèn)53端口未

您將如何調(diào)試速度慢或使用高內(nèi)存使用量的服務(wù)器? 您將如何調(diào)試速度慢或使用高內(nèi)存使用量的服務(wù)器? Jul 06, 2025 am 12:02 AM

發(fā)現(xiàn)服務(wù)器運(yùn)行緩慢或內(nèi)存占用過高時(shí),應(yīng)先排查原因再操作。首先要查看系統(tǒng)資源使用情況,用top、htop、free-h、iostat、ss-antp等命令檢查CPU、內(nèi)存、磁盤I/O和網(wǎng)絡(luò)連接;其次分析具體進(jìn)程問題,通過ps、jstack、strace等工具追蹤高占用進(jìn)程的行為;接著檢查日志和監(jiān)控?cái)?shù)據(jù),查看OOM記錄、異常請求、慢查詢等線索;最后根據(jù)常見原因如內(nèi)存泄漏、連接池耗盡、緩存失效風(fēng)暴、定時(shí)任務(wù)沖突進(jìn)行針對性處理,優(yōu)化代碼邏輯,設(shè)置超時(shí)重試機(jī)制,加限流熔斷,并定期壓測評估資源。

在Ubuntu中安裝用于遠(yuǎn)程Linux/Windows訪問的鱷梨調(diào)味醬 在Ubuntu中安裝用于遠(yuǎn)程Linux/Windows訪問的鱷梨調(diào)味醬 Jul 08, 2025 am 09:58 AM

作為系統(tǒng)管理員,您可能會發(fā)現(xiàn)自己(今天或?qū)恚┰赪indows和Linux并存的環(huán)境中工作。 有些大公司更喜歡(或必須)在Windows Box上運(yùn)行其一些生產(chǎn)服務(wù)已不是什么秘密

如何使用Brasero在Linux中燃燒CD/DVD 如何使用Brasero在Linux中燃燒CD/DVD Jul 05, 2025 am 09:26 AM

坦率地說,我不記得上一次使用CD/DVD驅(qū)動器的PC。這要?dú)w功于不斷發(fā)展的科技行業(yè),該行業(yè)已被USB驅(qū)動器和其他較小且緊湊的存儲媒體所取代,這些磁盤可提供更多存儲

如何在Linux中找到我的私人和公共IP地址? 如何在Linux中找到我的私人和公共IP地址? Jul 09, 2025 am 12:37 AM

在Linux系統(tǒng)中,1.使用ipa或hostname-I命令可查看私有IP;2.使用curlifconfig.me或curlipinfo.io/ip可獲取公網(wǎng)IP;3.桌面版可通過系統(tǒng)設(shè)置查看私有IP,瀏覽器訪問特定網(wǎng)站查看公網(wǎng)IP;4.可將常用命令設(shè)為別名以便快速調(diào)用。這些方法簡單實(shí)用,適合不同場景下的IP查看需求。

如何在Rocky Linux 8上安裝Nodejs 14/16&npm 如何在Rocky Linux 8上安裝Nodejs 14/16&npm Jul 13, 2025 am 09:09 AM

Node.js建立在Chrome的V8引擎上,是一種開源的,由事件驅(qū)動的JavaScript運(yùn)行時(shí)環(huán)境,用于構(gòu)建可擴(kuò)展應(yīng)用程序和后端API。 Nodejs因其非阻滯I/O模型而聞名輕巧有效,并且

See all articles