我使用了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
答案1
文件中未标识交换分区/etc/fstab
。因此,当您执行 时swapon -a
,没有要添加的交换文件。
根据您的 blkid 输出,/dev/sdc2 上有一个交换分区,但它不在您的 fstab 列表中。
因此,您可以在 fstab 中添加如下行:
/dev/sdc2 none swap sw 0 0
或者如果你坚持使用 UID:
UUID=05e01b5a-915c-4fe7-9ed1-5a1c5224fce9 none swap sw 0 0
答案2
还有更简单的方法。我猜你想要一个 4gb 的交换文件?只需按照我的说明操作即可 :)
dd if=/dev/zero of=/mnt/myswap.swap bs=1M count=4000
进行交换:
mkswap /mnt/myswap.swap
做 swapon
swapon /mnt/myswap.swap
现在是最后一步:)
nano /etc/fstab
现在只需将其添加到文件末尾:
/mnt/myswap.swap none swap sw 0 0
保存文件,就大功告成了!希望对你有帮助。如果有帮助,请点赞!