我使用了sudo swapoff -a && sudo swapon -a
,但swapon
没有重新打开交换,尽管在我的旧机器上这总是用于清理交换。有什么问题?Ubuntu 16.04。
编辑:
$ sudo blkid
/dev/sda1: UUID="6ead6194-b15f-4108-b71c-f91bac560daf" TYPE="ext4" PARTUUID="e8b65a13-5140-4b3b-9a09-565c3283fd0d"
/dev/sdb1: LABEL="big" UUID="cdfd673f-a33f-46cd-81e4-e3c6c1e9b902" TYPE="ext4" PARTUUID="1df024fd-cf87-40e8-9347-4c4073fcf9ca"
/dev/sdc1: UUID="644fe734-074a-4801-b2b8-fdff946d438d" TYPE="ext4" PARTUUID="ebd3d525-9edf-4a50-b6ea-bd745e03bb7c"
/dev/sdc2: UUID="05e01b5a-915c-4fe7-9ed1-5a1c5224fce9" TYPE="swap" PARTUUID="ca7cbc08-535a-4c18-9afd-c4b7553155c5"
/dev/sdc3: PARTUUID="d7edea62-ee24-49d0-8818-a4445d5cca7b"
$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=644fe734-074a-4801-b2b8-fdff946d438d / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
#UUID=9bb0f54c-3d82-4376-9e07-a0c3dd7aae69 none swap sw 0 0
#added
UUID=cdfd673f-a33f-46cd-81e4-e3c6c1e9b902 /disk2 ext4 errors=remount-ro 0 1
UUID=6ead6194-b15f-4108-b71c-f91bac560daf /disk3 ext4 errors=remount-ro 0 1
$ cat /etc/crypttab
cat: /etc/crypttab: No such file or directory
文件中未标识交换分区
/etc/fstab
。因此,当您执行 时swapon -a
,没有要添加的交换文件。根据您的 blkid 输出,/dev/sdc2 上存在一个交换分区,它不在您的 fstab 列表中。
因此,您可以在 fstab 中添加如下一行:
或者,如果您坚持使用 UID:
还有一种更简单的方法。我假设你想要一个 4gb 的文件交换?只需按照我的指示 :)
进行交换:
做交换
现在是最后一步:)
现在您只需将其添加到文件的末尾:
并保存文件并完成!希望它有所帮助。如果有帮助,请点赞!