root下,直接创swapfile
dd if=/dev/zero of=/swapfile bs=1M count=8192
然后
mkswap swapfile
swapon swapfile
修改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).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee / ext4 errors=remount-ro 0 1
/swapfile none swap defaults
然后
systemctl daemon-reload
如果fstab写错了这里就会报错
没报错就可以rebootl了文章来源:https://www.toymoban.com/news/detail-660452.html
如果想看是否成功文章来源地址https://www.toymoban.com/news/detail-660452.html
free -h
到了这里,关于linux不分区直接在文件系统根上开swap的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!