gpt4 book ai didi

linux - fdisk - 创建一半磁盘大小的交换分区

转载 作者:行者123 更新时间:2023-12-04 19:31:28 24 4
gpt4 key购买 nike

我有一个 /dev/xvdf disk安装在我的 linux 服务器上。
我正在使用这个磁盘创建一个交换分区,我成功地这样做了。

但是,我还想做的是将磁盘的一半分区用于交换,并保留另一半。

我做了以下事情:

**fdisk -l**

Disk /dev/xvdf: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

开始创建交换分区:
fdisk /dev/xvdf
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x6ab35b7f.

然后我继续并选择创建一个新分区(主):
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p

然后我选择了 1 这是默认分区号
Partition number (1-4, default 1): 1
First sector (2048-2097151, default 2048):
Using default value 2048

这就是我开始困惑的地方,我打算只使用 总磁盘的一半/dev/xvdf 我做了以下事情:
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): 536MB
Value out of range.
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +536MB
Partition 1 of type Linux and of size 511 MiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

我已指定 536MB 大小如上所示,是 的一半/dev/xvdf 这是1073MB。

请问这是分区一半磁盘的正确方法吗?

最佳答案

我确定这个问题很久以前就已经回答过了,但为了将来引用,我相信 fdisk 使用 M 读取分区大小,而不是 MB .在这种情况下,您需要将最终分区大小更改为 +536M .

关于linux - fdisk - 创建一半磁盘大小的交换分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40023251/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com