1

请不要再在这个问题上浪费你的时间了......我最终删除了整个 VM 并创建了另一个。我这样做所花费的时间少于解决问题所花费的时间。我有几个处于 RAID 模式的 SSD。

感谢所有尝试解决问题的人!

我在运行命令时遇到了 ubnuntu 未显示活动交换空间的问题cat /proc/swaps。这是我运行的命令列表。我什至添加了一个新的交换空间(文件:/swapfile1)只是为了确保至少有一个交换空间,但我仍然一无所获。

hebbo@ubuntu-12-lts:~$ sudo fdisk -l
[sudo] password for hebbo: 

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders, total 52428800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e3a7a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *    46569472    52426751     2928640   82  Linux swap / Solaris
/dev/sda2            2046    46567423    23282689    5  Extended
/dev/sda5            2048    46567423    23282688   83  Linux

Partition table entries are not in disk order
hebbo@ubuntu-12-lts:~$ sudo su

root@ubuntu-12-lts:/home/hebbo# cat /proc/swaps 
Filename                Type        Size    Used    Priority
root@ubuntu-12-lts:/home/hebbo# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 1.18755 s, 452 MB/s
root@ubuntu-12-lts:/home/hebbo# mkswap /swapfile1
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=cb846612-5f27-428f-9f83-bbe24b410a78
root@ubuntu-12-lts:/home/hebbo# chown root:root /swapfile1
root@ubuntu-12-lts:/home/hebbo# chmod 0600 /swapfile1
root@ubuntu-12-lts:/home/hebbo# swapon /swapfile1


root@ubuntu-12-lts:/home/hebbo# cat /proc/swaps 
Filename                Type        Size    Used    Priority
root@ubuntu-12-lts:/home/hebbo# 

知道如何解决这个问题吗?

这是在 vmware VM 中运行内核 3.9.0 的 ubuntu 12.04 LTS。

提前致谢!

4

3 回答 3

0

我最终删除了整个 VM 并创建了另一个。我这样做所花费的时间少于解决问题所花费的时间。我有几个处于 RAID 模式的 SSD。而且我已经在同一台主机上完成了所有下载。总而言之〜7分钟。

感谢所有帮助解决问题的人。

于 2013-11-01T18:01:48.973 回答
0

要在 Linux 系统重新启动后激活 /swapfile1,请在 /etc/fstab 文件中添加条目。使用 vi 等文本编辑器打开此文件:

# vi /etc/fstab

添加以下行:

/swapfile1 swap swap defaults 0 0

保存并关闭文件。下次重新启动后 Linux 出现时,它会自动为您启用新的交换文件。

这里查看更多信息。

于 2013-11-01T08:40:09.810 回答
0

我刚试过,它适用于我的盒子。

Linux fileserver 3.8.0-32-generic #47~precise1-Ubuntu SMP Wed Oct 2 16:19:35 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

ortang@fileserver:~$ cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/dm-2                               partition       4194300 0       -1
ortang@fileserver:~$ sudo su
root@fileserver:/home/ortang# dd if=/dev/zero of=/swapfile bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 0.695721 s, 772 MB/s
root@fileserver:/home/ortang# chmod 600 /swapfile
root@fileserver:/home/ortang# mkswap /swapfile
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=63cdcf3d-ba03-42ce-b598-15b6aa3ca67d
root@fileserver:/home/ortang# swapon /swapfile
root@fileserver:/home/ortang# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/dm-2                               partition       4194300 0       -1
/swapfile                               file            524284  0       -2

我可以想象为什么它在我的盒子上工作的一件事是我已经有一个工作交换分区,而你似乎没有。

也可能是你使用的内核造成的,3.9.0不是普通的12.04.3 LTS内核?你自己构建过内核吗?

什么是输出

grep CONFIG_SWAP /boot/config-`uname -r`

或者

zcat /proc/config.gz | grep CONFIG_SWAP

您的内核中是否启用了交换?

于 2013-11-01T09:09:33.023 回答