Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOWTO] lvm2 for root, swap and software suspend2 (edit)
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4, 5, 6  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Heinzi
n00b
n00b


Joined: 26 May 2007
Posts: 31

PostPosted: Sun Dec 23, 2007 4:29 pm    Post subject: Reply with quote

Thank you very much!
I already thought about doing without lvm2 or without suspend2 - until I found your howto :)
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Sun Dec 23, 2007 8:39 pm    Post subject: Reply with quote

Glad to see it is of use. Please post how your install goes. There have been enough changes since I first wrote this that it may be time for some updates.
Back to top
View user's profile Send private message
the.ant
n00b
n00b


Joined: 26 Dec 2007
Posts: 64

PostPosted: Thu Dec 27, 2007 11:12 pm    Post subject: Reply with quote

That script seems to address exactly the problem I have been dealing with.
It's exactly how my ubuntu machine is set up, in the long term I would like to
replace ubuntu with gentoo but I did not find out how to set this up.
However, I could not try it yet because my current machine does not have
support for loop devices and right now, I don't feel like recompiling the kernel.
But eventually I will try it and post the results here.
Back to top
View user's profile Send private message
Heinzi
n00b
n00b


Joined: 26 May 2007
Posts: 31

PostPosted: Tue Jan 01, 2008 4:01 pm    Post subject: Reply with quote

It doesn't work as it should :(
I went through the points 4,5 and 6 of your tutorial to add suspend2 to my already existing gentoo lvm2 system.
The new kernel booted and I stopped the x-server and used the console to log in. I got the tip to try hibernate first without X in console.
I typed "hibernate -n" and everything went well. So I typed "hibernate" and also everything seemed to go well. He wrote the image, went atomic and switched power off. I switched power on and selected again the TuxOnIce-grub and now my computer should recognize the image and load that, but it doesn't.
He boots as if there were no image. Mysqld for example is wondering why the socket-file already exists.
What can I do?
I have a little boot partition and a windows-partition on one sata-harddrive. The rest of this harddrive is filled by a lvm2-partition. On a second harddrive I have only a lvm2-partition.
Here my lvm2-configuration:
Code:
$ lvm lvs
  LV   VG     Attr   LSize   Origin Snap%  Move Log Copy%
  home system -wi-ao 239.90G
  root system -wi-ao  36.00G
  swap system -wi-a-   2.00G

Here the way I tried to install hibernation:
I emerged hibernate-script and added hibernate-cleanup to the boot runlevel.
I redirected the /usr/src/linux-symlink to /usr/src/linux-2.6.23-tuxonice-r6
I compiled the tuxonice-2.6.23-r6 kernel, copied /usr/src/linux/boot/bzImage to /boot/bzImage-tuxonicehowto.
I created the initramdisk with your script - scriptoptions: "-M gentoo 2.6.23-tuxonice-r6"
I ran module-rebuild, so that my ati-card will work.
I added a TuxOnIce-Grub-Entry into menu.lst:
Code:
title TuxOnIce
    root (hd0,1)
    kernel /bzImage-tuxonicehowto ro root=/dev/ram0 lvm2root=/dev/system/root lvm2resume2=/dev/system/swap
    initrd /initrd-lvm2-2.6.23-tuxonice-r6.gz

My hibernate.conf:
Code:
TryMethod suspend2.conf
#TryMethod disk.conf
#TryMethod ram.conf

suspend2.conf:
Code:
# Example suspend2.conf file.
#
# See hibernate.conf(5) for help on the configuration items.
#
# NOTE: Suspend2 is an improved version of suspend-to-disk which currently
#       requires patching your kernel. For more information, see www.suspend2.net
#
#       If you do not wish to patch your kernel but still be able to suspend to
#       disk, see disk.conf instead.

### suspend2 (for Software Suspend 2)
UseSuspend2 yes
Reboot no
EnableEscape yes
DefaultConsoleLevel 1
Compressor lzf
Encryptor none
# ImageSizeLimit 200

## useful for initrd usage:
SuspendDevice /dev/system/swap

## Powerdown method - 3 for suspend-to-RAM, 4 for ACPI S4 sleep, 5 for poweroff
PowerdownMethod 5

## Any other /proc/software_suspend setting can be set like so:
ProcSetting expected_compression 50

## Or traditionally like this:
# Suspend2AllSettings 0 0 2056 65535 5

## Or even from the results of hibernate --save-settings with this:
# Suspend2AllSettingsFile /etc/hibernate/suspend-settings.conf

## For filewriter:
# FilewriterLocation /suspend_file 1000
# VerifyFilewriterResume2 yes

## Specify a userui like this:
# ProcSetting userui_program /usr/local/sbin/suspend2ui_text

# Scale CPU to full speed to make sure we suspend as fast as possible.
FullSpeedCPU yes

#Partitionen, auf die (waehrend Linux suspended ist) zugegriffen werden soll, muessen unmounted und remounted werden
Unmount /windows
OnResume 20 mount /windows

Include common.conf

Lines without # as first char in common.conf:
Code:
Verbosity 0
LogFile /var/log/hibernate.log
LogVerbosity 1
Distribution gentoo
SaveClock restore-only
RadeonTool yes
FullSpeedCPU yes
LockKDE yes
OnSuspend 20 echo "Good night!"
OnResume 20 echo "Good morning!"
UnloadBlacklistedModules yes
LoadModules auto
DownInterfaces eth0
UpInterfaces auto
SwitchToTextMode yes
XStatus kde
XSuspendText Preparing to suspend...
XResumeText Resuming from suspend...

When booting I get a message like "BLKFSBUF: Device or resource busy". But the message is too quick out of sight and I have no idea how to slow down boot process or where I can find a boot protocol.
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Tue Jan 01, 2008 4:45 pm    Post subject: Reply with quote

Well that looks correct. Here is something you can try. This might give you a usable error message. First boot with the option lvm2rescue. This should drop you into a shell before anything has happened. Then try the following.
Code:

echo /dev/system/swap >/proc/suspend2/resume2
echo > /proc/suspend2/do_resume
Back to top
View user's profile Send private message
Heinzi
n00b
n00b


Joined: 26 May 2007
Posts: 31

PostPosted: Wed Jan 02, 2008 1:12 am    Post subject: Reply with quote

The folder /proc/suspend2 doesn't exists - neither in the lvm2rescue-shell nor in the booted system.
I also searched a folder named tuxonice and didn't found any in /proc.
But tuxonice should be compiled into my kernel. Here the important config parts:
Code:
CONFIG_HIBERNATION_SMP_POSSIBLE=y
CONFIG_HIBERNATION=y
CONFIG_PM_STD_PARTITION="/dev/system/swap"
CONFIG_TOI_CORE=y
CONFIG_TOI_FILE=y
CONFIG_TOI_SWAP=y
CONFIG_TOI_CRYPTO=y
CONFIG_TOI_USERUI=y
CONFIG_TOI_USERUI_DEFAULT_PATH="/usr/local/sbin/tuxonice_fbsplash"
# CONFIG_TOI_KEEP_IMAGE is not set
CONFIG_TOI_REPLACE_SWSUSP=y
# CONFIG_TOI_CLUSTER is not set
CONFIG_TOI_CHECKSUM=y
CONFIG_TOI_DEFAULT_WAIT=-1
# CONFIG_TOI_PAGEFLAGS_TEST is not set
CONFIG_TOI=y
CONFIG_SUSPEND_SMP_POSSIBLE=y
CONFIG_SUSPEND=y
# CONFIG_USB_SUSPEND is not set
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Wed Jan 02, 2008 1:30 am    Post subject: Reply with quote

OK. That was for the older kernels. I should have said do

Code:

echo /dev/system/swap >/sys/power/suspend2/resume2
echo > /sys/power/suspend2/do_resume
Back to top
View user's profile Send private message
Heinzi
n00b
n00b


Joined: 26 May 2007
Posts: 31

PostPosted: Wed Jan 02, 2008 12:59 pm    Post subject: Reply with quote

There is no /sys/power/suspend2, but I found in the booted system a folder /sys/power/tuxonice with the files do_resume and resume (not resume2) in it.
The content of /sys/power/tuxonice/resume is /dev/system/swap.
But when I boot the lvm2rescue - shell, there aren't any files in /sys. /sys is just an empty folder. Strange
Another strange thing is the part of the boot-log I can see above the cursor, when the lvm2rescue-shell is started. There is a message "TuxOnIce: Can't translate "/dev/system/swap" into a device id yet." and a few lines later "initrd: Activating LVM2 volumes". Isn't that the wrong order?
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Wed Jan 02, 2008 1:07 pm    Post subject: Reply with quote

I'm not sure what tuxonice is, but from what you are telling me, I'm pretty sure my script is not supporting it.

I guess you will need to mount /sys from the rescue shell. You can do that with mount -t sysfs none /sys
Back to top
View user's profile Send private message
Heinzi
n00b
n00b


Joined: 26 May 2007
Posts: 31

PostPosted: Wed Jan 02, 2008 2:41 pm    Post subject: Reply with quote

Suspend2 was renamed to tuxonice - it's just another name for the newer versions of suspend2.
I modified your script, so that it also works with tuxonice. With that modification, it works now. Thanks for your help!
In your script, there is a section where you distinguish between /proc and /sys/power. There I added a if-statement for tuxonice.
From line 169 on:
Code:
# Setup software suspend2

if [ -n "$resume2" ]; then
        mount -t sysfs none /sys

        if [ -f /proc/suspend2/resume2 ]; then
                echo "Setup suspen2 hibernation"
                echo $resume2 >/proc/suspend2/resume2
                echo > /proc/suspend2/do_resume
        elif [ -f /sys/power/suspend2/resume2 ]; then
                echo "Setup suspen2 hibernation"
                echo $resume2 >/sys/power/suspend2/resume2
                echo > /sys/power/suspend2/do_resume
        elif [ -f /sys/power/tuxonice/resume ]; then
                echo "Setup suspen2 hibernation"
                echo $resume2 >/sys/power/tuxonice/resume
                echo > /sys/power/tuxonice/do_resume
        else
                echo "Can't resume!"
        fi

fi

Maybe you can update your script that way so that it works for newer versions too.
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Wed Jan 02, 2008 2:43 pm    Post subject: Reply with quote

Cool. I will update my script.
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Sat Apr 19, 2008 2:24 am    Post subject: Script update Reply with quote

I have re-worked the script to use a cpio initrd instead of a ramdisk. This makes it easier to build the initrd. Since you no longer need to mount a loopback device you can probably run the script as a non root user (other than it wanting to put the initrd in /boot).

There is no longer a need for ramdisk_size, since we are not using the ramdisk anymore and you can compile the kernel with ramdisk as a module. Just be sure to turn on the initrd stuff.
Back to top
View user's profile Send private message
Halahad
n00b
n00b


Joined: 15 Mar 2005
Posts: 57
Location: Shanghai, PRC

PostPosted: Fri May 09, 2008 2:01 pm    Post subject: Reply with quote

it works for baselayout2?

Last edited by Halahad on Sun May 11, 2008 2:21 pm; edited 2 times in total
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Fri May 09, 2008 2:11 pm    Post subject: Reply with quote

Halahad wrote:
Is it works for baselayout2?


No idea. I won't be playing with baselayout2 until it is in the stable tree.
Back to top
View user's profile Send private message
Halahad
n00b
n00b


Joined: 15 Mar 2005
Posts: 57
Location: Shanghai, PRC

PostPosted: Sun May 11, 2008 2:15 pm    Post subject: Reply with quote

It seems like that cpio is much faster than the original ramdisk one. thx for your great work.
Back to top
View user's profile Send private message
weedy
Apprentice
Apprentice


Joined: 24 Jun 2005
Posts: 247

PostPosted: Sat May 17, 2008 1:24 am    Post subject: Reply with quote

Raffi wrote:
Halahad wrote:
Is it works for baselayout2?


No idea. I won't be playing with baselayout2 until it is in the stable tree.

baselayout2 does not have MAKEDEV
Back to top
View user's profile Send private message
ali3nx
l33t
l33t


Joined: 21 Sep 2003
Posts: 722
Location: Winnipeg, Canada

PostPosted: Sat May 17, 2008 2:04 am    Post subject: Reply with quote

Most definitely verified that makedev does not exist at least on my system...

https://forums.gentoo.org/viewtopic-p-5095275.html#5095275
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Sat May 17, 2008 4:19 am    Post subject: Reply with quote

Presumably there is a MAKEDEV equivalent available. Does anyone know what it is?
Back to top
View user's profile Send private message
ali3nx
l33t
l33t


Joined: 21 Sep 2003
Posts: 722
Location: Winnipeg, Canada

PostPosted: Fri May 23, 2008 12:28 am    Post subject: Reply with quote

Raffi wrote:
Presumably there is a MAKEDEV equivalent available. Does anyone know what it is?


It would seem that someone anticipated various legacy apps needing MAKEDEV with baselayout 2.

Code:
anvil ~ # emerge -pv sys-apps/makedev

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] sys-apps/makedev-3.23.1  USE="-build (-selinux)" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB
Back to top
View user's profile Send private message
Halahad
n00b
n00b


Joined: 15 Mar 2005
Posts: 57
Location: Shanghai, PRC

PostPosted: Sat May 24, 2008 2:54 pm    Post subject: Reply with quote

ali3nx wrote:
Raffi wrote:
Presumably there is a MAKEDEV equivalent available. Does anyone know what it is?


It would seem that someone anticipated various legacy apps needing MAKEDEV with baselayout 2.

Code:
anvil ~ # emerge -pv sys-apps/makedev

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] sys-apps/makedev-3.23.1  USE="-build (-selinux)" 0 kB

Total: 1 package (1 reinstall), Size of downloads: 0 kB


This kind of makedev has a completely deferent syntax and configurations.
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Sat May 24, 2008 3:04 pm    Post subject: Reply with quote

It is starting to sound like I should bite the bullet and upgrade one of my machine to baselayout2. Not sure when I will have the time, but I will try to get to it this week.
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Tue May 27, 2008 4:17 pm    Post subject: Reply with quote

I have updated the script. Use the -M gentoo-b2 option if you are using baselayout 2. Be sure to emerge makedev first. I have also added support for xen systems, the script this was tested on is a xen domu with /dev/xvda being a pv and the entire system using lvm.
Back to top
View user's profile Send private message
dantrell
l33t
l33t


Joined: 01 Jun 2007
Posts: 915
Location: Earth

PostPosted: Thu May 29, 2008 4:08 am    Post subject: Reply with quote

Raffi wrote:
I have updated the script. Use the -M gentoo-b2 option if you are using baselayout 2. Be sure to emerge makedev first. I have also added support for xen systems, the script this was tested on is a xen domu with /dev/xvda being a pv and the entire system using lvm.

I used the updated script like so:
Code:
./lvm2ci -M gentoo-b2 -c /etc/lvm/lvm.conf

Important output was as follows:
Code:
lvm2ci -- make LVM initial ram disk /boot/initrd-lvm2-2.6.24-gentoo-r5.gz

lvm2ci -- finding required shared libraries
lvm2ci -- adding required /dev files
don't know how to make device "consoleonly"
lvm2ci -- copying initrd files to ram disk
lvm2ci -- creating symlinks to busybox
lvm2ci -- creating new /tmp/mnt.16998/sbin/init
lvm2ci -- copying /etc/lvm/lvm.conf to /tmp/mnt.16998/etc/lvm/lvm.conf
8821 blocks
--------------------------------------------------------
Your initrd is ready in /boot/initrd-lvm2-2.6.24-gentoo-r5.gz

I noticed something failed during bootup but it scrolled by to fast to see, I'll check it out later. Regardless everything apparently works.

Thanks. :)
_________________
Dantrell B.
Back to top
View user's profile Send private message
Raffi
l33t
l33t


Joined: 17 Mar 2003
Posts: 731
Location: Moscow, Id.

PostPosted: Thu May 29, 2008 4:11 am    Post subject: Reply with quote

The error in my script of

don't know how to make device "consoleonly"

is nothing to worry about, I was just too lazy to make the script not ask for something that the new makedev could not do. Any errors in your normal startup cause by what my script does (or does not do) is something I do want to hear about.
Back to top
View user's profile Send private message
dantrell
l33t
l33t


Joined: 01 Jun 2007
Posts: 915
Location: Earth

PostPosted: Thu May 29, 2008 6:57 am    Post subject: Reply with quote

Raffi wrote:
[...] Any errors in your normal startup cause by what my script does (or does not do) is something I do want to hear about.

Turned out to be nothing related to your script (as far as I could tell).

Thanks again. :)
_________________
Dantrell B.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 4 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum