国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Using fdisk to Partition a Disk
Using parted for GPT and Large Disks
Key Differences and Best Practices
Final Notes
Home System Tutorial LINUX A Guide to Linux Disk Partitioning with `fdisk` and `parted`

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

Aug 02, 2025 am 07:14 AM

fdisk is suitable for use when the MBR partition table and the disk is less than 2TB, suitable for simple interactive operations; 1. When using fdisk, first use p to view the current partition table, n to create a new partition, t set the type, w to save changes; 2. parted is suitable for disks larger than 2TB or when GPT support is required, scripting operations can be performed; 3. When using parted, first mklabel gpt creates GPT tags, unit sets units, mkpart creates partitions, prints to view results, and quit exit; 4. Both must be carefully checked for device names to avoid data loss due to error operations; 5. Format the partition using the mkfs command, and can be used after mount; always back up important data before operation and confirm that the device name is correct.

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 give you full control over your storage layout. While both tools serve the same basic purpose—creating and managing disk partitions—they different 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 settings.


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 (eg, 20G for 20GB).
  4. Set the partition type (optional):

    • Type t to change the partition type.
    • Enter the partition number.
    • Choose a type code (eg, 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 apply 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 give 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.

The above is the detailed content of A Guide to Linux Disk Partitioning with `fdisk` and `parted`. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
Install Guacamole for Remote Linux/Windows Access in Ubuntu Install Guacamole for Remote Linux/Windows Access in Ubuntu Jul 08, 2025 am 09:58 AM

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

How to find my private and public IP address in Linux? How to find my private and public IP address in Linux? Jul 09, 2025 am 12:37 AM

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

How to Install NodeJS 14 / 16 & NPM on Rocky Linux 8 How to Install NodeJS 14 / 16 & NPM on Rocky Linux 8 Jul 13, 2025 am 09:09 AM

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and

System requirements to install linux System requirements to install linux Jul 20, 2025 am 03:49 AM

Linuxcanrunonmodesthardwarewithspecificminimumrequirements.A1GHzprocessor(x86orx86_64)isneeded,withadual-coreCPUrecommended.RAMshouldbeatleast512MBforcommand-lineuseor2GBfordesktopenvironments.Diskspacerequiresaminimumof5–10GB,though25GBisbetterforad

How to Install MySQL 8.0 on Rocky Linux and AlmaLinux How to Install MySQL 8.0 on Rocky Linux and AlmaLinux Jul 12, 2025 am 09:21 AM

Written in C, MySQL is an open-source, cross-platform, and one of the most widely used Relational Database Management Systems (RDMS). It’s an integral part of the LAMP stack and is a popular database management system in web hosting, data analytics,

Ubuntu 25.04 'Plucky Puffin”: A Bold Leap Forward with GNOME 48 and HDR Brilliance Ubuntu 25.04 'Plucky Puffin”: A Bold Leap Forward with GNOME 48 and HDR Brilliance Jul 12, 2025 am 09:28 AM

Ubuntu has long stood as a bastion of accessibility, polish, and power in the Linux ecosystem. With the arrival of Ubuntu 25.04, codenamed “Plucky Puffin”, Canonical has once again demonstrated its commitment to delivering a

How to Install MongoDB on Rocky Linux and AlmaLinux How to Install MongoDB on Rocky Linux and AlmaLinux Jul 12, 2025 am 09:29 AM

MongoDB is a high-performance, highly scalable document-oriented NoSQL database built to manage heavy traffic and vast amounts of data. Unlike traditional SQL databases that store data in rows and columns within tables, MongoDB structures data in a J

How to Install Magento on Rocky Linux and AlmaLinux How to Install Magento on Rocky Linux and AlmaLinux Jul 08, 2025 am 09:50 AM

Written in PHP, Magento is a popular open-source, and versatile eCommerce platform that provides businesses with an online shopping cart. It leverages various PHP frameworks such as Symfony and Laminas to enhance its functionality and usability. Mage

See all articles