怎样挂载交换分区

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
luoyangke
帖子: 111
注册时间: 2010-01-17 0:24

怎样挂载交换分区

#1

帖子 luoyangke » 2011-12-19 14:30

问题:已安装好的系统(Ubuntu 11.10),发现SWAP分区没有挂载上。现在用虚拟机,太卡。VMware提示说没有SWAP,才发现的。
当时分区时是给了3.9G的,中间重装了一次系统可能是忘记挂载了。现在怎么挂载上? :em01 谢谢。

swap应该没挂载上

代码: 全选

lushize@lushize-GateWay:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          2879       2710        169          0         78       1933
-/+ buffers/cache:        698       2181
Swap:            0          0          0
可能需要的信息:

代码: 全选

lushize@lushize-GateWay:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc	/proc	proc	nodev,noexec,nosuid	0	0
#Entry for /dev/sda11 :
UUID=9e0876d3-6bef-472c-9b26-334f5581e194	/	ext4	errors=remount-ro	0	1
#Entry for /dev/sda8 :
UUID=05c53272-2c28-4a3c-9e85-01b905aaaf94	/boot	ext4	defaults	02
#Entry for /dev/sda9 :
UUID=17f64e99-0b14-4a86-ba9f-df054eadc5bc	/home	ext4	defaults	02
#Entry for /dev/sda10 :
UUID=ca62e2dc-e9f9-434f-9a4b-4f230c8ca1f7	/tmp	ext4	defaults	02
#Entry for /dev/sda5 :
UUID=01CC470DE62E4240	/windows	ntfs-3g	defaults,locale=zh_CN.UTF-8	00
#Entry for /dev/mapper/cryptswap1 :
UUID=75b0e391-ec20-47e8-9d06-6ff2ae6ae95f	none	swap	sw	0	0
#UUID=b3c2404c-4339-4629-beac-50cfc89175e6	none	swap	sw	0	0

代码: 全选

lushize@lushize-GateWay:~$ sudo blkid
/dev/sda1: UUID="C0967D27967D1EDA" TYPE="ntfs" 
/dev/sda2: LABEL="Program" UUID="4E3268E03268CF11" TYPE="ntfs" 
/dev/sda5: LABEL="M-dM-;M-^SM-eM-:M-^S" UUID="01CC470DE62E4240" TYPE="ntfs" 
/dev/sda6: LABEL="Back" UUID="01CC470DEC98B700" TYPE="ntfs" 
/dev/sda8: UUID="05c53272-2c28-4a3c-9e85-01b905aaaf94" TYPE="ext4" 
/dev/sda9: UUID="17f64e99-0b14-4a86-ba9f-df054eadc5bc" TYPE="ext4" 
/dev/sda10: UUID="ca62e2dc-e9f9-434f-9a4b-4f230c8ca1f7" TYPE="ext4" 
/dev/sda11: UUID="9e0876d3-6bef-472c-9b26-334f5581e194" TYPE="ext4" 
/dev/mapper/cryptswap1: UUID="5c4c5b7f-cd17-472c-88f6-83e676ba1bbb" TYPE="swap" 

代码: 全选

lushize@lushize-GateWay:~$ swapon -s
Filename				Type		Size	Used	Priority

代码: 全选

lushize@lushize-GateWay:~$ sudo fdisk -l

Disk /dev/sda: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders, total 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xbf8d4326

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63    74123909    37061923+   7  HPFS/NTFS/exFAT
Partition 1 does not start on physical sector boundary.
/dev/sda2        74123912   202210154    64043121+   7  HPFS/NTFS/exFAT
/dev/sda3       202210216  1250263039   524026412    f  W95 Ext'd (LBA)
/dev/sda5       202210218   715727879   256758831    7  HPFS/NTFS/exFAT
Partition 5 does not start on physical sector boundary.
/dev/sda6       715727943   879574814    81923436    7  HPFS/NTFS/exFAT
Partition 6 does not start on physical sector boundary.
/dev/sda7       920717343   928894364     4088511   82  Linux swap / Solaris
Partition 7 does not start on physical sector boundary.
/dev/sda8       920524800   920715263       95232   83  Linux
/dev/sda9       928894976  1233051647   152078336   83  Linux
/dev/sda10     1233053696  1250263039     8604672   83  Linux
/dev/sda11      879575040   920522751    20473856   83  Linux

Partition table entries are not in disk order

Disk /dev/mapper/cryptswap1: 4186 MB, 4186635264 bytes
255 heads, 63 sectors/track, 508 cylinders, total 8177022 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Alignment offset: 512 bytes
Disk identifier: 0x2fd8fb64

Disk /dev/mapper/cryptswap1 doesn't contain a valid partition table
谢谢! :em06
上次由 luoyangke 在 2011-12-19 14:46,总共编辑 1 次。
问渠哪得清如许,为有源头活水来
头像
ljj_jjl2008
论坛版主
帖子: 14256
注册时间: 2007-09-16 8:29

Re: 怎样挂载交换分区

#2

帖子 ljj_jjl2008 » 2011-12-19 14:35

怀疑你已经挂载上swap了。
执行

代码: 全选

free -m
贴上来结果看看。
luoyangke
帖子: 111
注册时间: 2010-01-17 0:24

Re: 怎样挂载交换分区

#3

帖子 luoyangke » 2011-12-19 14:39

ljj_jjl2008 写了:怀疑你已经挂载上swap了。
执行

代码: 全选

free -m
贴上来结果看看。

代码: 全选

lushize@lushize-GateWay:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          2879       2710        169          0         78       1933
-/+ buffers/cache:        698       2181
Swap:            0          0          0
问渠哪得清如许,为有源头活水来
头像
ljj_jjl2008
论坛版主
帖子: 14256
注册时间: 2007-09-16 8:29

Re: 怎样挂载交换分区

#4

帖子 ljj_jjl2008 » 2011-12-19 14:47

没有挂上,free里面swap是0。
改你/etc/fstab里面这一行的uuid:

代码: 全选

UUID=75b0e391-ec20-47e8-9d06-6ff2ae6ae95f   none   swap   sw   0   0
fstab中存放了与分区有关的重要信息,其中每一行为一个分区记录,每一行又可分为六个部份,下面以/dev/hda7 / ext2 defaults 1 1为例逐个说明:
  1. 第一项是您想要mount的储存装置的实体位置,如hdb或如上例的/dev/hda7。
  2. 第二项就是您想要将其加入至哪个目录位置,如/home或如上例的/,这其实就是在安装时提示的挂入点。
  3. 第三项就是所谓的local filesystem,其包含了以下格式:如ext、ext2、msdos、iso9660、nfs、swap等,或如上例的ext2,可以参见/prco/filesystems说明。
  4. 第四项就是您mount时,所要设定的状态,如ro(只读)或如上例的defaults(包括了其它参数如rw、suid、exec、auto、nouser、async),可以参见「mount nfs」。
  5. 第五项是提供DUMP功能,在系统DUMP时是否需要BACKUP的标志位,其内定值是0。
  6. 第六项是设定此filesystem是否要在开机时做check的动作,除了root的filesystem其必要的check为1之外,其它皆可视需要设定,内定值是0。
这个时候 UUID 就派上用场了,UUID 全称是 Universally Unique Identifier,也就是说,每个分区有一个唯一的 UUID 值,这样就不会发生分区识别混乱的问题了。(这里注意,重新格式化分区有可能会改变UUID)
在 fstab 中用 UUID 挂载分区,看起来向这样:
UUID=1234-5678 /mnt/usb vfat utf8,umask=0 0 0
在 UUID= 后面填入分区相应的 UUID 值,就可以正确挂载分区了。
那么,我们如何知道一个分区的 UUID 呢?

有 3 个命令:
1. 通过浏览 /dev/disk/by-uuid/ 下的设备文件信息。
# ls -l /dev/disk/by-uuid/
2. 通过 vol_id 命令。
# vol_id /dev/sdb5
3. 通过 blkid 命令
# blkid /dev/sdb5

也可以通过各种图形界面的磁盘管理工具来查询。
头像
ljj_jjl2008
论坛版主
帖子: 14256
注册时间: 2007-09-16 8:29

Re: 怎样挂载交换分区

#5

帖子 ljj_jjl2008 » 2011-12-19 14:50

你的硬盘分区好像有问题呀!!
l
ushize@lushize-GateWay:~$ sudo fdisk -l

Disk /dev/sda: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders, total 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xbf8d4326

Device Boot Start End Blocks Id System
/dev/sda1 * 63 74123909 37061923+ 7 HPFS/NTFS/exFAT
Partition 1 does not start on physical sector boundary.
/dev/sda2 74123912 202210154 64043121+ 7 HPFS/NTFS/exFAT
/dev/sda3 202210216 1250263039 524026412 f W95 Ext'd (LBA)
/dev/sda5 202210218 715727879 256758831 7 HPFS/NTFS/exFAT
Partition 5 does not start on physical sector boundary.
/dev/sda6 715727943 879574814 81923436 7 HPFS/NTFS/exFAT
Partition 6 does not start on physical sector boundary.
/dev/sda7 920717343 928894364 4088511 82 Linux swap / Solaris
Partition 7 does not start on physical sector boundary.
/dev/sda8 920524800 920715263 95232 83 Linux
/dev/sda9 928894976 1233051647 152078336 83 Linux
/dev/sda10 1233053696 1250263039 8604672 83 Linux
/dev/sda11 879575040 920522751 20473856 83 Linux

Partition table entries are not in disk order

Disk /dev/mapper/cryptswap1: 4186 MB, 4186635264 bytes
255 heads, 63 sectors/track, 508 cylinders, total 8177022 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Alignment offset: 512 bytes
Disk identifier: 0x2fd8fb64

Disk /dev/mapper/cryptswap1 doesn't contain a valid partition table
怎么会有这种提示?
luoyangke
帖子: 111
注册时间: 2010-01-17 0:24

Re: 怎样挂载交换分区

#6

帖子 luoyangke » 2011-12-19 14:58

ljj_jjl2008 写了:你的硬盘分区好像有问题呀!!
l
ushize@lushize-GateWay:~$ sudo fdisk -l

Disk /dev/sda: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders, total 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xbf8d4326

Device Boot Start End Blocks Id System
/dev/sda1 * 63 74123909 37061923+ 7 HPFS/NTFS/exFAT
Partition 1 does not start on physical sector boundary.
/dev/sda2 74123912 202210154 64043121+ 7 HPFS/NTFS/exFAT
/dev/sda3 202210216 1250263039 524026412 f W95 Ext'd (LBA)
/dev/sda5 202210218 715727879 256758831 7 HPFS/NTFS/exFAT
Partition 5 does not start on physical sector boundary.
/dev/sda6 715727943 879574814 81923436 7 HPFS/NTFS/exFAT
Partition 6 does not start on physical sector boundary.
/dev/sda7 920717343 928894364 4088511 82 Linux swap / Solaris
Partition 7 does not start on physical sector boundary.
/dev/sda8 920524800 920715263 95232 83 Linux
/dev/sda9 928894976 1233051647 152078336 83 Linux
/dev/sda10 1233053696 1250263039 8604672 83 Linux
/dev/sda11 879575040 920522751 20473856 83 Linux

Partition table entries are not in disk order

Disk /dev/mapper/cryptswap1: 4186 MB, 4186635264 bytes
255 heads, 63 sectors/track, 508 cylinders, total 8177022 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Alignment offset: 512 bytes
Disk identifier: 0x2fd8fb64

Disk /dev/mapper/cryptswap1 doesn't contain a valid partition table
怎么会有这种提示?
我也纳闷。
装的是双系统:Win7+Ubuntu 11.10
问渠哪得清如许,为有源头活水来
头像
TeliuTe
论坛版主
帖子: 7675
注册时间: 2007-11-25 13:29
系统: 16/18/20/w7
来自: 新疆博乐
联系:

Re: 怎样挂载交换分区

#7

帖子 TeliuTe » 2011-12-19 18:31

这么多分区。。有 swap 分区安装的时候一般会自动挂载上
回复