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

fstab 添加 swap file 无效?

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

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

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

    [email protected]:~# 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
    
    [email protected]:~# ls -al /var/swapfile 
    -rw------- 1 root root 4294967296 Nov 13 15:17 /var/swapfile
    [email protected]:~# 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
    [email protected]:~# mount -a
    [email protected]:~# free -h
                  total        used        free      shared  buff/cache   available
    Mem:           2.0G        1.8G         70M         15M         70M         13M
    Swap:            0B          0B          0B
    
    
    [email protected]:~# 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
    
    [email protected]:~# vi /etc/fstab 
    [email protected]:~# mount -a
    [email protected]:~# 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
    [email protected]:~# 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
        1
    263   2017-11-13 21:48:18 +08:00   ♥ 1
    /var/swapfile none swap defaults 0 0
    关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   4117 人在线   最高记录 5043   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.3 · 30ms · UTC 01:37 · PVG 09:37 · LAX 17:37 · JFK 20:37
    ♥ Do have faith in what you're doing.