環境
$ uname -r 2.6.32-431.5.1.el6.x86_64 $ grep CONFIG_SWAP /usr/src/kernels/`uname -r`/.config CONFIG_SWAP=y $ grep CONFIG_BLK_DEV_RAM /usr/src/kernels/`uname -r`/.config CONFIG_BLK_DEV_RAM=y CONFIG_BLK_DEV_RAM_COUNT=16 CONFIG_BLK_DEV_RAM_SIZE=16384 $ cat /proc/swaps Filename Type Size Used Priority /dev/dm-1 partition 835576 0 -1
swap file on ext4 @/tmp -> PASS
$ mount (近頃(?) /tmp は RAM 扱いではない模様) $ dd if=/dev/zero of=/tmp/swapfile bs=1M count=1 $ mkswap -f /tmp/swapfile Setting up swapspace version 1, size = 1020 KiB no label, UUID=fd6633bd-5d5c-4e6a-99fc-f8ee9741eacc $ file /tmp/swapfile /tmp/swapfile: Linux/i386 swap file (new style) 1 (4K pages) size 255 pages $ chmod 600 /tmp/swapfile # swapon -v /tmp/swapfile swapon on /tmp/swapfile swapon: /tmp/swapfile: found swap signature: version 1, page-size 4, same byte order swapon: /tmp/swapfile: pagesize=4096, swapsize=1048576, devsize=1048576 # swapon -s Filename Type Size Used Priority /dev/dm-1 partition 835576 0 -1 /tmp/swapfile file 1016 0 -2 # swapoff /tmp/swapfileちなみに、swapon -v オプションを有効にしているとスワップファイルの permission が 600 でないと警告されたが、 600 であっても root 以外がオーナになら警告すべきだが警告されなかった。
$ swapon -V swapon: (util-linux-ng 2.17.2)stable/v2.17 の swapon.c は util-linux/util-linux.git [kernel.org] で uid を確認していないが、最新 stable/v2.24 の swapon.c util-linux/util-linux.git [kernel.org] では、uid もチェックしている模様。
ちなみに、util-linux [wikipedia.org] によると、util-linux-ng は util-linux の後継として開発されたが、また util-linux という名前に戻ったらしい。
swap file on ramfs @/dev/ram0 -> FAIL
# mkdir /mnt/ram0 # mount -t ramfs /dev/ram0 /mnt/ram0 # dd if=/dev/zero of=/mnt/ram0/swapfile bs=1M count=1 # mkswap -f /mnt/ram0/swapfile Setting up swapspace version 1, size = 1020 KiB no label, UUID=7a23a073-c7a0-4e13-abfb-a0746abe3afc mkswap: unable to relabel /mnt/ram0/swapfile to system_u:object_r:swapfile_t:s0: Operation not supported # file /mnt/ram0/swapfile /mnt/ram0/swapfile: Linux/i386 swap file (new style) 1 (4K pages) size 255 pages # chmod 600 /mnt/ram0/swapfile # swapon -v swapfile swapon on swapfile swapon: /mnt/ram0/swapfile: found swap signature: version 1, page-size 4, same byte order swapon: /mnt/ram0/swapfile: pagesize=4096, swapsize=1048576, devsize=1048576 swapon: swapfile: swapon failed: Invalid argument # dmesg | tail -1 swapon: swapfile has holes # cp /tmp/swapfile /mnt/ram0/ # chmod 600 /mnt/ram0/swapfile # swapon -v /mnt/ram0/swapfile swapon on /mnt/ram0/swapfile swapon: /mnt/ram0/swapfile: found swap signature: version 1, page-size 4, same byte order swapon: /mnt/ram0/swapfile: pagesize=4096, swapsize=1048576, devsize=1048576 swapon: /mnt/ram0/swapfile: swapon failed: Invalid argument # dmesg | tail -2 swapon: swapfile has holes swapon: swapfile has holes
swap file on ext2 @/dev/ram0 -> PASS
# mkfs /dev/ram0 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 4096 inodes, 16384 blocks 819 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=16777216 2 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193 Writing inode tables: done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 23 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. # mount -t ext2 /dev/ram0 /mnt/ram0 # dd if=/dev/zero of=/mnt/ram0/swapfile bs=1M count=1 # mkswap -f /mnt/ram0/swapfile Setting up swapspace version 1, size = 1020 KiB no label, UUID=acaff689-a570-43a7-8c97-2c8c80045bbc # chmod 600 /mnt/ram0/swapfile # swapon -v /mnt/ram0/swapfile swapon on /mnt/ram0/swapfile swapon: /mnt/ram0/swapfile: found swap signature: version 1, page-size 4, same byte order swapon: /mnt/ram0/swapfile: pagesize=4096, swapsize=1048576, devsize=1048576 # swapon -s Filename Type Size Used Priority /dev/dm-1 partition 835576 0 -1 /mnt/ram0/swapfile file 1004 0 -2 # dmesg | tail -1 Adding 1004k swap on /mnt/ram0/swapfile. Priority:-2 extents:5 across:1020k # swapoff /mnt/ram0/swapfile
swap partition @/dev/ram0 -> PASS
# mkswap /dev/ram0 Setting up swapspace version 1, size = 16380 KiB no label, UUID=efac3cf3-9d79-4f68-935c-f4da81845dbb # swapon -v /dev/ram0 swapon on /dev/ram0 swapon: /dev/ram0: found swap signature: version 1, page-size 4, same byte order swapon: /dev/ram0: pagesize=4096, swapsize=16777216, devsize=16777216 # swapon -s Filename Type Size Used Priority /dev/dm-1 partition 835576 0 -1 /dev/ram0 partition 16376 0 -2 # dmesg | tail -1 Adding 16376k swap on /dev/ram0. Priority:-2 extents:1 across:16376k # swapoff
swap file on tmpfs -> FAIL
# mkdir /mnt/tmp # mount -t tmpfs tmpfs /mnt/tmp # dd if=/dev/zero of=/mnt/tmp/tmpfsswap bs=1M count=1 # mkswap -f /mnt/tmp/tmpfsswap Setting up swapspace version 1, size = 1020 KiB no label, UUID=ed44d266-47e6-40a2-8ac7-7f925d88fa6e # chmod 600 /mnt/tmp/tmpfsswap # swapon -v /mnt/tmp/tmpfsswap swapon on /mnt/tmp/tmpfsswap swapon: /mnt/tmp/tmpfsswap: found swap signature: version 1, page-size 4, same byte order swapon: /mnt/tmp/tmpfsswap: pagesize=4096, swapsize=1048576, devsize=1048576 swapon: /mnt/tmp/tmpfsswap: swapon failed: Invalid argument # dmesg | tail (no message invoked by this swapon)tmpfs 自体 swap を使うのだから swap を tmpfs 上に作れるとは思えなかったが、念のためやってみた。
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.