分类 Linux 下的文章

转自: http://chriseiffel.com/everything-linux/step-by-step-how-to-get-hibernate-working-for-linux-ubuntu-11-04-mint-11/

What Hibernation Is and Does

Hibernation takes all the data in your ram and stores it on your hard drive and then powers down the computer. The data is stored in a special type of partition called a swap partition (you can also have a swap file). When you power the computer on again the data stored from your old session is reloaded.

In the following article I am going to lead you through a systematic approach to diagnosing why Linux’s hibernation feature isn’t working on your computer and hopefully fix it. Here’s a Brief overview.

  1. Not Enough Swap
  2. Your Computer Isn’t Saving Your Session
  3. You Computer Isn’t Reading your Saved Session on Boot
  4. Your Computer Says “resuming from /dev/sdX” but freezes

1. Not Enough Swap

You should have as much swap as you have RAM plus some margin. If you try to hibernate and you are using more ram than you have swap the process will fail and sometimes hangs. Sometimes there is an error message that says “not enough swap” This is an easy problem to check for. Run the command in red.

 chris@Starace ~ $ free -m
             total       used       free     shared    buffers     cached
Mem:         10005       9922         82          0       1647       5844
-/+ buffers/cache:       2430       7574
Swap:         8100          0       8100

The output shows the amount of swap and ram on my computer. As you can see I have 8005 Mb of RAM and I have 8100 Mb of swap. For a hibernate to work you have to have more swap than used RAM not counting cached), Also if you run out of RAM during your session your swap is used. To hibernate you must have free swap greater than the sum of your RAM and your used swap. As a general rule you should have a swap partition slightly bigger than your RAM (hopefully you aren’t using swap during your session, if you are it’s time for a RAM upgrade.)

If you don’t have enough swap or if you don’t have any swap, roll up your sleeves you need to repartition your hard drive.

Repartitioning to add more SWAP

Remember to be careful with your repartitioning, you can destroy your OS easily.

Pull out your bootable CD/Jump Drive and boot It (we can’t repartition the drive we we are using it.) Run the “gparted” disk utility. If you have swap, right click -> Delete Right click on your linux partition -> Resize/Move Decrease the size of the partition by the amount of space you want to increase your swap. Click Okay Right click on the free space -> New Change the File System Type to “linux-swap,” click okay. Click the apply check mark in the top menu of gparted to apply the changes Right Click On the new swap partition -> Information Copy down the UUID value and /dev/sdXN value for later. Linux Create Parition Make Sure the File System is linux-swap

uuid info linux Copy down the UUID and path values. We will use them later.

Note:Remember to be careful with your repartitioning, you can destroy your OS easily. After repartitioning you will need to edit your Linux Hard Drive file. Open up terminal and run the command.

chris@Starace ~ $ sudo gedit /media/NAME_OF_YOUR_COMPUTER/etc/fstab

If you had a swap partition before, look for the line that has the word swap and change the /dev/sdXN to the new /dev/sdXN value. You can also use the UUID instead of the path as shown in red. If never had a swap partition to begin with add the following line to the bottom of the “/media/NAME_OF_YOUR_COMPUTER/etc/fstab” file.

UUID=a453-Your-UUID-Number-ea33 none swap sw

The path variable can change depending on how you have your hard drive plugged in (ex /dev/sda1 -> /dev/sdb1). This usually isn’t a problem if you don’t move your hard drives around in your computer. However, Using a UUID is more reliable. The /dev/sdXN designator can change, but the UUID is unique to the storage device and doesn’t change even if you move to another computer.

After you’ve made the changes to the fstab file, shut down and boot your computer normally. To make sure this all worked run the following command in red. You should see your swap partition listed.

 chris@Starace ~ $ cat /proc/swaps
Filename                Type        Size    Used    Priority
/dev/sdNX                         partition 8295420 0   -1

If you see this take you have successfully created/expanded your swap to accommodate hibernation.

  1. Your Computer Isn’t Saving Your Session If you’ve tried to get your computer to hibernate and it didn’t work it’s helpful to look at the hibernation log.

tail /var/log/pm-suspend.log

 chris@Starace ~ $ tail  /var/log/pm-suspend.log
Running hook /usr/lib/pm-utils/sleep.d/00powersave thaw hibernate:

/usr/lib/pm-utils/sleep.d/00powersave thaw hibernate: success.
Running hook /usr/lib/pm-utils/sleep.d/00logging thaw hibernate:

/usr/lib/pm-utils/sleep.d/00logging thaw hibernate: success.
Running hook /usr/lib/pm-utils/sleep.d/000kernel-change thaw hibernate:

/usr/lib/pm-utils/sleep.d/000kernel-change thaw hibernate: success.
Sun Jul 24 13:15:14 HST 2011: Finished.

If you see something that has a date and says “Finished” like the what is shown in blue, that means that your computer successfully saved the session. If you see a bunch of errors then get ready to roll up your sleeves again. Unfortunately this is the hardest error to fix. There could be dozens of reasons for this to happen, but in my case it had something to do with binding and unbinding peripheral devices. The following article explains what I did to fix the problem.

http://chriseiffel.com/everything-linux/how-i-got-suspend-and-hibernate-working-in-linux-ubuntu-11-04-mint-11/

One solution that I found that worked for a lot of people, but not me is this simple fix

http://www.ubuntugeek.com/fix-for-suspend-and-hibernation-problem-for-laptops.html/comment-page-2#comment-53547

Don’t lose hope if you get stuck in this step. Instead google everything you can on the problem. Google the errors you see in the log. Someone has solved the problem you just need to find the solution.

3. You Computer Isn’t Reading your Saved Session on Boot

So your computer successfully saves a session, but doesn’t resume the session upon power up? It acts as if it was rebooted rather than hibernated? Well the good news is that this is a fairly easy thing to fix. This is most likely because GRUB the bootloader doesn’t know to resume from your swap. Take a look at the GRUB profile.

 chis@Starace ~ $ sudo gedit /etc/default/grub

Look for the line that starts with.

GRUB_CMDLINE_LINUX

Add the following option in red.

GRUB_CMDLINE_LINUX=”resume=UUID=a353e-Your-SWAP-UUID-34eda other-option=value”

Or

GRUB_CMDLINE_LINUX=”resume=/dev/sdXN other-option=value”

You may or may nor have other options. Be careful that you type in the correct path or UUID for the drive here. If you don’t then when you try to resume you will have to boot in safe mode to fix the drive name and re-run the update-grub script. Save the file and then update grub with the following command.

 chris@Starace ~ $ sudo update-grub

In addition to grub we need to update/create one more file. Edit the following file.

 chris@Starace ~ $ sudo gedit /etc/initramfs-tools/conf.d/resume 

Add this line to the file.

 resume=UUID=41e86209-3802-424b-9a9d-d7683142dab7 

Then run this command to update.

 chris@Starace ~ $ sudo update-initramfs -u

Now hibernate your computer and cross your fingers! It just might work.

4. Your Computer Says “resuming from /dev/sdX” but freezes

Linux is so close to hibernating and resuming successfully that it even says it is resuming. Fortunately this is another easy fix. The problem with this comes from two programs that are redundant. Removing them should fix the problem.

 chris@Starace: sudo apt-get remove hibernate uswsusp

I know that the command may seem counterintuitive. but it worked for me so hopefully it will work for you.

All Done

Remember to check to make sure your USB ports work after the suspend/hibernate.

If you tried the steps above, please leave a comment below with your system setup (OS, Computer Hardware) so that we can create a reference that others can use.

Also I got a lot of my resources from the Ubuntu page on swap partitions. If you want to learn more about this subject read this article

https://help.ubuntu.com/community/SwapFaq

Happy Linuxing!

This entry was posted in ASUS G53SW Setup, Everything Penguin Related, Uncategorized. Bookmark the permalink.

首先修改内核:

Power management and ACPI options --->
    [*] Suspend to RAM and standby
    [*] Hibernation (aka 'suspend to disk')

然后安装 suspend 软件

emerge --ask sys-power/suspend

然后检查一下系统支持的模式

cat /sys/power/state

然后使用下面的命令就可以进入睡眠模式

echo mem > /sys/power/state

但是要使用休眠模式, 还需要增加一些操作.

  1. 在内核里面增加下面语句, 然后重新编译内核.

    resume=/dev/sda3 no_console_suspend
  2. 替换genkernel 软件, 原来的 genkernel 据说有 bug, 安装 genkernel-next软件, 替换原来的 genkernel 软件, 然后使用 genkernel --install initramfs, 重新生成 initramfs.

但是使用下面的命令进入休眠模式就有问题, 表现为系统休眠成功了, 但是唤醒不行, 变成冷开机了, 在冷开机的时候, 系统在 swap 里面发现了保存的东西, 但是不能从这么东西里面回复状态.

echo disk > /sys/power/state

这时候需要先安装 pm-utils 软件, 然后再使用下面几步:

  1. /etc/default/grub

    GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sda3"
  2. grub-mkconfig -o /boot/grub/grub.cfg
  3. genkernel --install initramfs
  4. vim /etc/pm/config.d/gentoo
    SLEEP_MODULE="kernel"

然后 reboot 系统, 使用 pm-hibernate 来进入休眠模式, 后可以顺利 resume.

休眠的前面两步是否需要, 等以后验证.

经过另外在 nas 上面验证, 只需要下面几个步骤即可:

1. Power management and ACPI options --->
    [*] Suspend to RAM and standby
    [*] Hibernation (aka 'suspend to disk')
2.  pm-utils 
3. 后面的配置.

注意: 不需要在内核里面的 resume 语句, 不需要换成 genkernel-next 软件.

转自: http://www.wowotech.net/pm_subsystem/hibernation.html

出于省电和快速开机的需求, Hibernation经常被应用到Laptop和移动终端上,本文就简单讲讲Hibernation的一种实现实现方法,SWSUSP( Swap Suspend),其实swsusp从2.6开始就已经被引入到内核版本树中了,所以如果想分析swsusp的代码实现的话,还是挺方便的,只要有有2.6之后的内核代码即可。

本文不会过分深入分析代码,但文章最后会给出hibernation 和 resume的整体流程图。

- 阅读剩余部分 -

转自: https://linux.die.net/man/8/pm-hibernate

Name pm-action - Suspend or Hibernate your computer

Synopsis pm-hibernate [--help]

pm-suspend [--quirk---help] pm-suspend-hybrid [--quirk---help] Description

This manual page documents briefly the pm-action, pm-hibernate, pm-suspend and pm-suspend-hybrid commands. This manual page was originally written for the Debian(TM) distribution and has been adopted by the pm-utils project.

- 阅读剩余部分 -

在gentoo 上面,如果需要下载 youku 的视频的话,可以使用 annie 这个软件来下载。annie 软件主页:https://github.com/iawia002/annie#installation. annie 支持以下网站:

Site URL  Videos  Images  Playlist  VIP adaptation 抖音 https://www.douyin.com
哔哩哔哩 https://www.bilibili.com ✓ ✓ ✓ 半次元 https://bcy.net
pixivision https://www.pixivision.net
优酷 https://www.youku.com ✓ ✓ YouTube https://www.youtube.com ✓ ✓
爱奇艺 https://www.iqiyi.com
芒果TV https://www.mgtv.com
Tumblr https://www.tumblr.com ✓ ✓
Vimeo https://vimeo.com
Facebook https://facebook.com
斗鱼视频 https://v.douyu.com
秒拍 https://www.miaopai.com
微博 https://weibo.com
Instagram https://www.instagram.com ✓ ✓
Twitter https://twitter.com
腾讯视频 https://v.qq.com
网易云音乐 https://music.163.com
音悦台 https://yinyuetai.com

先安装 go 语言:

emerge -av go

然后安装 annie

go get github.com/iawia002/annie

可以先用 annie -i URL 来查看视频相关信息,比如说不同的视频质量, 然后用 annie -f mp4hd2 URL 这样的命令来下载指定质量的视频。 对于 youku 的URL,比如说: https://v.youku.com/v_show/id_XMjY1NTc3NDc0OA==.html?spm=a2h0k.11417342.soresults.dtitle 可以只用 https://v.youku.com/v_show/id_XMjY1NTc3NDc0OA==.html 即可。

转自: https://blog.csdn.net/u010649766/article/details/78567629

Ubuntu 下使用 Thunderbird 做邮件客户端,因为实在是找不到类似 Foxmail 一样的软件了。 幸好,Ubuntu 自带这款软件,但是用起来有个问题就是只能接受邮件不能发送邮件。

工具 => 附加组件 => 搜索 “exchange” 安装 “ExQuilla” 工具 => 启动”ExQuilla for Microsoft Exchange” => “Add Microsoft Exchange account” 填写邮箱地址和密码, 其他默认, 然后下一步 直接点 “do auto discover”, 出现两个绿色的小原点就代表一切 OK, 然后下一步 欧了…… 从头到尾只需要填写邮箱和密码即可,其他默认

转自:http://blogs.umass.edu/Techbytes/2014/04/03/configuring-exchange-email-and-calendar-in-thunderbird/

Configuring Email clients can be a frustrating task due to the sheer number of different server settings that need to be properly entered in order for it to work properly and the variety of choices in desktop mail clients. Fortunately, this guide is written specifically for configuring UMass Amherst Exchange mail and calendaring for Thunderbird, an open source desktop mail client that is compatible with most Windows, OS X, and Linux distributions. For your convenience, the instructions and screenshots in this guide should exactly match what you see on your screen.

- 阅读剩余部分 -

转自:https://docs.cs.cf.ac.uk/notes/thunderbird-email-application/

Thunderbird is a portable mail application from Mozilla. It's available for Windows, Macintoshes and Linux systems and can be freely downloaded and installed.

Office 365 is a business software productivity service from Microsoft. Cardiff University has subscribed to Office 365 for its staff and student email and calendar service.

The University's IT Service recommends that users access Office 365 through a web browser (Outlook Web App) or through the latest Microsoft Outlook application program on Windows or Macintoshes.

But you can instead use Thunderbird for both mail and calendar access to Office 365. This Note tells you how to configure and use Thunderbird with Office 365.

- 阅读剩余部分 -

参考: Configuring Thunderbird and Using it to Access Office 365 Mail and Calendar in Cardiff University https://docs.cs.cf.ac.uk/notes/thunderbird-email-application/

Doesn't work with Thunderbird 60 https://github.com/Ericsson/exchangecalendar/issues/628

Configuring Exchange Email and Calendar in Thunderbird http://blogs.umass.edu/Techbytes/2014/04/03/configuring-exchange-email-and-calendar-in-thunderbird/

thunderbird 可以同步网络日历,比如说微软的 hotmail 的日历。首先到 hotmail 上面,配置 --> 共享日历 --> 发布日历 然后复制 ics 日历。 在thunderbird 里面新建日历,选择网络日历,然后把 ics 地址复制进去,就可以了, 后面只需要手动同步日历一下,就可以了。 但是这种方法只能用于接受 hotmail 的日历,不能推送给 hotmail。

经过,多次搜索,测试,终于找到能够双向更新的方法。 首先安装 Equilla 插件,这个用来配置 hotmail 的 exchange 服务,收取邮件。 然后安装 tbsync 插件,最后安装 exchange calendar 插件。

Equilla 和 tbsync 这两个插件都可以在 thunderbird 的 tools 里面找到安装。但是 exchange calendar 只能自己下载,然后安装,下载地址:https://github.com/ExchangeCalendar/exchangecalendar/releases.

安装 exchange calendar 之后,就可以新建 calendar 的时候选择 MS 格式了,然后安装需要配置即可。

thunderbird 163 smtp 如果要正常发送,配置如下:

server: smtp.163.com
port: 465
auth: Normal password
security: SSL/TLS

测试的时候如果提示: DT:SPM,这个是垃圾邮件的提示。测试邮件可以添加抄送给自己,这样不容易作为垃圾邮件被挡住。