From ac9a01de0c0baa08708d64a9d36fc3cd1c46e928 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 19 Apr 2019 08:41:00 +0800 Subject: [PATCH] translated --- ...0190410 Managing Partitions with sgdisk.md | 94 ------------------- ...0190410 Managing Partitions with sgdisk.md | 94 +++++++++++++++++++ 2 files changed, 94 insertions(+), 94 deletions(-) delete mode 100644 sources/tech/20190410 Managing Partitions with sgdisk.md create mode 100644 translated/tech/20190410 Managing Partitions with sgdisk.md diff --git a/sources/tech/20190410 Managing Partitions with sgdisk.md b/sources/tech/20190410 Managing Partitions with sgdisk.md deleted file mode 100644 index b42fef82af..0000000000 --- a/sources/tech/20190410 Managing Partitions with sgdisk.md +++ /dev/null @@ -1,94 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Managing Partitions with sgdisk) -[#]: via: (https://fedoramagazine.org/managing-partitions-with-sgdisk/) -[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/) - -Managing Partitions with sgdisk -====== - -![][1] - -[Roderick W. Smith][2]‘s _sgdisk_ command can be used to manage the partitioning of your hard disk drive from the command line. The basics that you need to get started with it are demonstrated below. - -The following six parameters are all that you need to know to make use of sgdisk’s most basic features: - - 1. **-p** -_Print_ the partition table: -### sgdisk -p /dev/sda - 2. **-d x** -_Delete_ partition x: -### sgdisk -d 1 /dev/sda - 3. **-n x:y:z** -Create a _new_ partition numbered x, starting at y and ending at z: -### sgdisk -n 1:1MiB:2MiB /dev/sda - 4. **-c x:y** -_Change_ the name of partition x to y: -### sgdisk -c 1:grub /dev/sda - 5. **-t x:y** -Change the _type_ of partition x to y: -### sgdisk -t 1:ef02 /dev/sda - 6. **–list-types** -List the partition type codes: -### sgdisk --list-types - - - -![The SGDisk Command][3] - -As you can see in the above examples, most of the commands require that the [device file name][4] of the hard disk drive to operate on be specified as the last parameter. - -The parameters shown above can be combined so that you can completely define a partition with a single run of the sgdisk command: - -### sgdisk -n 1:1MiB:2MiB -t 1:ef02 -c 1:grub /dev/sda - -Relative values can be specified for some fields by prefixing the value with a **+** or **–** symbol. If you use a relative value, sgdisk will do the math for you. For example, the above example could be written as: - -### sgdisk -n 1:1MiB:+1MiB -t 1:ef02 -c 1:grub /dev/sda - -The value **0** has a special-case meaning for several of the fields: - - * In the _partition number_ field, 0 indicates that the next available number should be used (numbering starts at 1). - * In the _starting address_ field, 0 indicates that the start of the largest available block of free space should be used. Some space at the start of the hard drive is always reserved for the partition table itself. - * In the _ending address_ field, 0 indicates that the end of the largest available block of free space should be used. - - - -By using **0** and relative values in the appropriate fields, you can create a series of partitions without having to pre-calculate any absolute values. For example, the following sequence of sgdisk commands would create all the basic partitions that are needed for a typical Linux installation if in run sequence against a blank hard drive: - -### sgdisk -n 0:0:+1MiB -t 0:ef02 -c 0:grub /dev/sda -### sgdisk -n 0:0:+1GiB -t 0:ea00 -c 0:boot /dev/sda -### sgdisk -n 0:0:+4GiB -t 0:8200 -c 0:swap /dev/sda -### sgdisk -n 0:0:0 -t 0:8300 -c 0:root /dev/sda - -The above example shows how to partition a hard disk for a BIOS-based computer. The [grub partition][5] is not needed on a UEFI-based computer. Because sgdisk is calculating all the absolute values for you in the above example, you can just skip running the first command on a UEFI-based computer and the remaining commands can be run without modification. Likewise, you could skip creating the swap partition and the remaining commands would not need to be modified. - -There is also a short-cut for deleting all the partitions from a hard disk with a single command: - -### sgdisk --zap-all /dev/sda - -For the most up-to-date and detailed information, check the man page: - -$ man sgdisk - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/managing-partitions-with-sgdisk/ - -作者:[Gregory Bartholomew][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/glb/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/managing-partitions-816x345.png -[2]: https://www.rodsbooks.com/ -[3]: https://fedoramagazine.org/wp-content/uploads/2019/04/sgdisk.jpg -[4]: https://en.wikipedia.org/wiki/Device_file -[5]: https://en.wikipedia.org/wiki/BIOS_boot_partition diff --git a/translated/tech/20190410 Managing Partitions with sgdisk.md b/translated/tech/20190410 Managing Partitions with sgdisk.md new file mode 100644 index 0000000000..19f2752245 --- /dev/null +++ b/translated/tech/20190410 Managing Partitions with sgdisk.md @@ -0,0 +1,94 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Managing Partitions with sgdisk) +[#]: via: (https://fedoramagazine.org/managing-partitions-with-sgdisk/) +[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/) + +使用 sgdisk 管理分区 +====== + +![][1] + +[Roderick W. Smith][2] 的 _sgdisk_ 命令可在命令行中管理硬盘的分区。下面将介绍使用它所需的基础知识。 + +以下六个参数是你使用 sgdisk 大多数基本功能所需了解的: + + 1. **-p** +_打印_ 分区表: +### sgdisk -p /dev/sda + 2. **-d x** +_删除_分区 x: +### sgdisk -d 1 /dev/sda + 3. **-n x:y:z** +创建一个编号 x 的_新_分区,从 y 开始,从 z 结束: +### sgdisk -n 1:1MiB:2MiB /dev/sda + 4. **-c x:y** +_更改_分区 x 的名称为 y: +### sgdisk -c 1:grub /dev/sda + 5. **-t x:y** +将分区 x 的_类型_更改为 y: +### sgdisk -t 1:ef02 /dev/sda + 6. **–list-types** +列出分区类型代码: +### sgdisk --list-types + + + +![The SGDisk Command][3] + +如你在上面的例子中所见,大多数命令都要求将要操作的硬盘的[设备文件名][4]指定为最后一个参数。 + +可以组合上面的参数,这样你可以一次定义所有分区: + +### sgdisk -n 1:1MiB:2MiB -t 1:ef02 -c 1:grub /dev/sda + +在值的前面加上 **+** 或 **–** 符号,可以为某些字段指定相对值。如果你使用相对值,sgdisk 会为你做数学运算。例如,上面的例子可以写成: + +### sgdisk -n 1:1MiB:+1MiB -t 1:ef02 -c 1:grub /dev/sda + +**0** 值对于以下几个字段是特殊情况: + + * 对于_分区号_字段,0 表示应使用下一个可用编号(编号从 1 开始)。 +  * 对于_起始地址_字段,0 表示使用最大可用空闲块的头。硬盘开头的一些空间始终保留给分区表本身。 +  * 对于_结束地址_字段,0 表示使用最大可用空闲块的末尾。 + + + +通过在适当的字段中使用 **0** 和相对值,你可以创建一系列分区,而无需预先计算任何绝对值。例如,如果在一块空白硬盘中,以下 sgdisk 命令序列将创建典型 Linux 安装所需的所有基本分区: + +### sgdisk -n 0:0:+1MiB -t 0:ef02 -c 0:grub /dev/sda +### sgdisk -n 0:0:+1GiB -t 0:ea00 -c 0:boot /dev/sda +### sgdisk -n 0:0:+4GiB -t 0:8200 -c 0:swap /dev/sda +### sgdisk -n 0:0:0 -t 0:8300 -c 0:root /dev/sda + +上面的例子展示了如何为基于 BIOS 的计算机分区硬盘。基于 UEFI 的计算机上不需要 [grub分区][5]。由于 sgdisk 在上面的示例中为你计算了所有绝对值,因此你可以在基于 UEFI 的计算机上跳过第一个命令,并且可以无需修改即可运行其余命令。同样,你可以跳过创建交换分区,并且不需要修改其余命令。 + +还有使用一个命令删除硬盘上所有分区的快捷方式: + +### sgdisk --zap-all /dev/sda + +关于最新和详细信息,请查看手册页: + +$ man sgdisk + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/managing-partitions-with-sgdisk/ + +作者:[Gregory Bartholomew][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/glb/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/04/managing-partitions-816x345.png +[2]: https://www.rodsbooks.com/ +[3]: https://fedoramagazine.org/wp-content/uploads/2019/04/sgdisk.jpg +[4]: https://en.wikipedia.org/wiki/Device_file +[5]: https://en.wikipedia.org/wiki/BIOS_boot_partition