我试图在openSUSE 42.2系统的根分区创建一个swap文件,却无法正常挂载。
经过查询应该是btrfs系统这种类型的文件系统不支持swap文件。
另外还有一个btrfs-swapon的项目可以在btrfs上挂载swap文件,但文档里说不太适合在copy-on-write文件系统中创建swap,除非不得已,不建议使用。Keep in mind, that a copy-on-write file system is not the best choice to use a swap file。
talen@opensuse:/> sudo dd if=/dev/zero of=/swapfile bs=1M count=8192
8192+0 records in
8192+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 15.2733 s, 562 MB/s
talen@opensuse:/> sudo mkswap /swapfile
mkswap: /swapfile: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 8 GiB (8589930496 bytes)
no label, UUID=58762fa9-d15f-4790-ad12-bbafa2f93de0
talen@opensuse:/> sudo swapon /swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
swapon: /swapfile: swapon failed: Invalid argument
talen@opensuse:/> sudo chmod 0600 /swapfile
talen@opensuse:/> sudo swapon /swapfile
swapon: /swapfile: swapon failed: Invalid argument
参考:
https://github.com/sebastian-philipp/btrfs-swapon
https://superuser.com/questions/539287/swapon-failed-invalid-argument-on-a-linux-system-with-btrfs-filesystem
经过查询应该是btrfs系统这种类型的文件系统不支持swap文件。
另外还有一个btrfs-swapon的项目可以在btrfs上挂载swap文件,但文档里说不太适合在copy-on-write文件系统中创建swap,除非不得已,不建议使用。Keep in mind, that a copy-on-write file system is not the best choice to use a swap file。
talen@opensuse:/> sudo dd if=/dev/zero of=/swapfile bs=1M count=8192
8192+0 records in
8192+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 15.2733 s, 562 MB/s
talen@opensuse:/> sudo mkswap /swapfile
mkswap: /swapfile: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 8 GiB (8589930496 bytes)
no label, UUID=58762fa9-d15f-4790-ad12-bbafa2f93de0
talen@opensuse:/> sudo swapon /swapfile
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
swapon: /swapfile: swapon failed: Invalid argument
talen@opensuse:/> sudo chmod 0600 /swapfile
talen@opensuse:/> sudo swapon /swapfile
swapon: /swapfile: swapon failed: Invalid argument
参考:
https://github.com/sebastian-philipp/btrfs-swapon
https://superuser.com/questions/539287/swapon-failed-invalid-argument-on-a-linux-system-with-btrfs-filesystem