V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
gamexg
V2EX  ›  Linux

fstab 添加 swap file 无效?

  •  
  •   gamexg · 2017-11-13 15:27:37 +08:00 · 2684 次点击
    这是一个创建于 2568 天前的主题,其中的信息可能已经有所发展或是发生改变。

    fstab 添加了 swapfile,但是开机不自动使用,mount -a 也无效,而且没有任何错误提示。 swapon 可以正常启用 sqapfile。

    请问这是什么原因照成的?

    root@jd00000:~# 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=53030b5c-5cb7-490d-9a5b-767b10cafc02 /               ext4    errors=remount-ro 0       1
    /var/swapfile	none	swap	sw	0	0
    
    root@jd00000:~# ls -al /var/swapfile 
    -rw------- 1 root root 4294967296 Nov 13 15:17 /var/swapfile
    root@jdu4e00u53f7:~# mkswap /var/swapfile 
    mkswap: /var/swapfile: warning: wiping old swap signature.
    Setting up swapspace version 1, size = 4 GiB (4294963200 bytes)
    no label, UUID=3731d030-49f9-47ee-a9c1-eb420497d65a
    root@jd00000:~# mount -a
    root@jd000007:~# free -h
                  total        used        free      shared  buff/cache   available
    Mem:           2.0G        1.8G         70M         15M         70M         13M
    Swap:            0B          0B          0B
    
    
    root@jdu00000:~# 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=53030b5c-5cb7-490d-9a5b-767b10cafc02 /               ext4    errors=remount-ro 0       1
    /var/swapfile swap swap defaults 0 0
    
    root@jd00000:~# vi /etc/fstab 
    root@jd00000:~# mount -a
    root@jdu0000:~# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            981M     0  981M   0% /dev
    tmpfs           201M  5.6M  195M   3% /run
    /dev/vda1        30G   12G   17G  40% /
    tmpfs          1001M   16K 1001M   1% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs          1001M     0 1001M   0% /sys/fs/cgroup
    overlay          30G   12G   17G  40% /var/lib/docker/overlay2/42273be454d07f9a62d4807d5203d55e143e693b7d215990bf55932acaa636a3/merged
    shm              64M  4.0K   64M   1% /var/lib/docker/containers/8af0a8d68cd4d5b5845c9c53c2dcd9a3d7aed18b5e6c04438146d2d682185cf1/shm
    tmpfs           201M     0  201M   0% /run/user/0
    root@jd00000:~# free -h
                  total        used        free      shared  buff/cache   available
    Mem:           2.0G        1.8G         71M         15M         61M         10M
    Swap:            0B          0B          0B
    
    
    
    1 条回复    2017-11-13 21:48:18 +08:00
    263
        1
    263  
       2017-11-13 21:48:18 +08:00   ❤️ 1
    /var/swapfile none swap defaults 0 0
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   908 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 22:06 · PVG 06:06 · LAX 14:06 · JFK 17:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.