← 返回命令列表

Linux command

sfdisk 命令

安全

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

Back up

sudo sfdisk -d [/dev/sdX] > [path/to/file.dump]

Restore

sudo sfdisk [/dev/sdX] < [path/to/file.dump]

Set

sudo sfdisk --part-type [/dev/sdX] [partition_number] [swap]

Delete

sudo sfdisk --delete [/dev/sdX] [partition_number]

说明

sfdisk is a scriptable partition table manipulator. Unlike interactive tools like fdisk, sfdisk is designed for non-interactive use, making it ideal for backup/restore operations and automated partitioning scripts. The dump format is human-readable and can be edited before restoring. This makes it useful for cloning partition layouts between identical disks.

参数

-d, --dump
Dump partition table in sfdisk-compatible format
-l, --list
List partitions on a device
--delete
Delete a partition
--part-type
Set or change partition type
-n, --no-act
Dry run; don't write changes
-b, --backup
Backup partition table sectors before changes
-f, --force
Disable all consistency checks
--verify
Check partition table consistency
-J, --json
Output in JSON format

FAQ

What is the sfdisk command used for?

sfdisk is a scriptable partition table manipulator. Unlike interactive tools like fdisk, sfdisk is designed for non-interactive use, making it ideal for backup/restore operations and automated partitioning scripts. The dump format is human-readable and can be edited before restoring. This makes it useful for cloning partition layouts between identical disks.

How do I run a basic sfdisk example?

Run `sudo sfdisk -d [/dev/sdX] > [path/to/file.dump]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -d, --dump do in sfdisk?

Dump partition table in sfdisk-compatible format