调整swap分区大小后,可以休眠却不能正常唤醒问题(解决办法)

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

调整swap分区大小后,可以休眠却不能正常唤醒问题(解决办法)

#1

帖子 zxpz0 » 2009-10-23 8:43

我的本子有2G的内存,安装9.10beta时,我分了2G的分区作为swap,1G给/tmp,后来发现这两个分区的利用率太低,就打算把/tmp用tmpfs挂载,把swap调整为1G,只要能保证休眠就够了。调整完后(漫长的等待!!!),发现休眠可以,但唤醒是变成了重新启动。
放狗后,找到这样一篇文章:http://www.bamweb.nl/index.php?Itemid=4 ... task=view 是关于增加swap分区大小的。我发现我应该是少作了一步,大意如下:
在这篇文章中,记录了扩大swap分区的方式和过程,主要有以下几点:

1.使用gparted

2.卸载要处理的分区

3.调整(时间很长)

4.改变配置—-注意

a.用blkid查找相应的改变后的UUID

b.在fstab中改变相应的值

c.在/etc/initramfs-tools/conf.d/resum中,改变swap分区的UUID,这是作为重启动时首先指向的分区3

d.重新生成initramfs,sudo update-initramfs -k all -u 注:这里用”all”是因为我用了两个内核。

以上红字的部份就是我少做了的,做了这一部后就可以正常唤醒了。
附我的配置文件:

1.fstab

# /etc/fstab: static file system information.
#
# Use ‘blkid -o value -s UUID’ 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>
proc /proc proc defaults 0 0
# / was on /dev/sda1 during installation
UUID=af04b906-1761-4047-96ef-2758d7c3bc4c / ext4 errors=remount-ro 0 1
# /home was on /dev/sda4 during installation
UUID=7c9da8c9-426d-47ea-b91b-d7dde31fa215 /home ext4 defaults 0 2
# swap was on /dev/sda2 during installation
UUID=4c0f4d3f-07e3-4150-ae20-4e9ad8db1ad4 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
none /tmp tmpfs defaults,size=256m 0 0
none /var/tmp tmpfs defaults,size=32m 00
2./etc/initramfs-tools/conf.d/resum

RESUME=UUID=4c0f4d3f-07e3-4150-ae20-4e9ad8db1ad4

以下为原文:

**********************************************************************************************************************************************************

After this we will use the UUID in the /etc/fstab and in /etc/initramfs-tools/conf.d/resume. Now we are going to reinitialize the ramfs by using this command:

通过Ubuntu, swap, hibernate.

Just a couple of days ago I wanted to increase my swap space to 1 GB instead of 512 MB. This way I could finally do an hibernate. Most of the time I wasn’t able to because I have 1 GB of RAM and with firefox and thunderbird running it uses a lot.

So what did I do. I installed Gparted to adjust my disks. As you can see further below my swap partition is for my biggest partition. So I had to resize and move my data a bit to the right so I could grew my swap partition. Make sure do this when you have enough time. I took me around 3 hours. The following commands where used.

apt-get install gparted

Make sure you have unmounted the partition you want to edit, you are also able to do it with Gparted, but it crashed on my machine. So I did it by hand. NOTE: remember the partition you are using.

System > Administration > Partition Editor

Now we are going to create the swap partition.

mkswap /dev/sda5

After this we will use the UUID in the /etc/fstab and in /etc/initramfs-tools/conf.d/resume. Now we are going to reinitialize the ramfs by using this command:

update-initramfs -u

After this has finished you may reboot normally.
Extra information

The following commands may help you during the way.

# fdisk -l

Disk /dev/sda: 60.0 GB, 60011642880 bytes
255 heads, 63 sectors/track, 7296 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×8f8002b1

Device Boot Start End Blocks Id System
/dev/sda1 1 12 96358+ de Dell Utility
/dev/sda2 * 13 1290 10265535 7 HPFS/NTFS
/dev/sda3 1291 2197 7285477+ 83 Linux
/dev/sda4 2198 7296 40957717+ 5 Extended
/dev/sda5 2198 2327 1044193+ 82 Linux swap / Solaris
/dev/sda6 2328 7296 39913461 83 Linux

# blkid
/dev/sda1: SEC_TYPE=”msdos” LABEL=”DellUtility” UUID=”07D5-081A” TYPE=”vfat”
/dev/sda2: UUID=”66DC7E18DC7DE2AB” TYPE=”ntfs”
/dev/sda3: UUID=”51853ab8-929e-4c6e-ada7-f8da01e2d18a” SEC_TYPE=”ext2″ TYPE=”ext3″
/dev/sda5: TYPE=”swap” UUID=”34c13693-7a5d-4274-a002-623cc82b062d”
/dev/sda6: UUID=”1452744c-4c0e-4da5-a30b-39549a44de83″ SEC_TYPE=”ext2″ TYPE=”ext3″

# cat /proc/swaps
Filename Type Size Used Priority
/dev/sda5 partition 1044184 0 -1
Error section

These could be found/seen during booting or in dmesg.

Unable to find swap-space signature

activating swap [fail]
Ubuntu 9.10RC@Dell 710M
/Intel(R) Pentium(R) M processor 1.60GHz
/2048MB Memory/
60G IDE HD
/855GM Integrated Graphics Device
http://blog.chinaunix.net/u3/104343/
回复