# 2 problems with TuxOnIce hibernating [solved]

## PsychoI3oy

fixed, but possibly relavent?

I have 3 1TB hdds with 4 primary partitions, raided with md:

    md1 is /boot, ~64MB, sd[abc]1 raid 1

    sd[abc]2 is swap

    md3 is / ~50GB, sd[abc]3 raid 1

    md4 is an lvm vg with /usr, /var, /opt, /home, etc. sd[abc]4 raid 5

Ignoring the various issues I originally had getting TuxOnIce working, once working I had issues with it crashing on resume from hibernate. I have 16GB of ram and had only 1GB of swap on each drive because I rarely touch it. Even though I had compression on I figured the X/E17/firefox/etc just couldn't fit in the 3gb.

So I booted parted magic and stole ~4GB from each sd[abc]3 to give to sd[abc]2. The next hibernation/resume worked fine, as did several subsuqent ones.

Several days later I figured out that md3 was no longer mounting and it was falling back to using sdc3. I rebooted to parted magic and tried reassembling, recreating, and a few other nondestructive things but fsck complained about the lack of superblock. I used fsck to put the ext3 superblocks back but then mdadm complained about the lack of md superblock. I gave up at this point.

2 problems with tuxonice: 

In all this I realized I had left my external USB hdd off (turned off during partitioning to avoid derps) and turned it on to make a fresh backup. The next hibernate resume crashed. Ultimately I figured out that having the hdd on or having my Android phone plugged into usb will cause it to crash on resume, regardless of what state it was when hibernated.

The final and most minor problem is that TuxOnIce won't turn the computer off after hibernating. It won't reboot if I hit R when hibernating, either.

So:

How do I fix md3 (assuming there's something smarter than blanking two of the drives and starting from scratch)? fixed

How do I keep TuxOnIce from crashing (kernel panic?) on resume with USB drives activated?

How do I make TuxOnIce turn off the computer after hibernating?

All this is on Gentoo stable amd64 with a 3.9 gentoo-sources kernel, but everything's about a month out of date because I didn't want to upgrade anything that'd touch the few partitions on / and drive md3 more out of sync.

I should be able to answer any other questions as needed. ( x-posted to reddit http://www.reddit.com/r/linuxquestions/comments/1k2x4s/3_problems_with_tuxonice_hibernating_and_md/ )

Edit a week later: See my madness below for solving the md issues; both problems with tuxonice seems to have solved themselves with an upgrade to gentoo-sources-3.10.6 and the corresponding ToI patch. Yay.Last edited by PsychoI3oy on Mon Aug 19, 2013 6:31 pm; edited 5 times in total

----------

## Hu

In what way does TuxOnIce crash?  Does it cause a spontaneous reboot, a kernel panic, or something else?  Can you try with the in-kernel hibernation support or uswsusp hibernation?

----------

## PsychoI3oy

 *Hu wrote:*   

> In what way does TuxOnIce crash?  Does it cause a spontaneous reboot, a kernel panic, or something else?  

 

I'm pretty sure it's a kernel panic, it just shows me the bottom several lines of a stack trace but it goes by too quick to see (I have no idea how to capture such things, but would be willing to try if there are mechanisms available). It does not reboot after this, though says something about the problem being found and fixed. It will, however, continue to crash at the same point (<25% of the restore bar) if I leave the external usb drive turned on. 

 *Hu wrote:*   

> Can you try with the in-kernel hibernation support or uswsusp hibernation?

 

I thought tuxonice was the in-kernel hibernation support; I'm pretty sure I have all those things enabled. ISTR googling 'gentoo hibernate' and arriving at the tuxonice page on the gentoo wiki and proceed from there.

----------

## dmpogo

 *PsychoI3oy wrote:*   

> 
> 
> I thought tuxonice was the in-kernel hibernation support; I'm pretty sure I have all those things enabled. ISTR googling 'gentoo hibernate' and arriving at the tuxonice page on the gentoo wiki and proceed from there.

 

Tuxonice is in-kernel (in a sense it is not userspace), but it is an alternative to standard hibernation distributed with kernel sources

----------

## PsychoI3oy

 *dmpogo wrote:*   

> 
> 
> Tuxonice is in-kernel (in a sense it is not userspace), but it is an alternative to standard hibernation distributed with kernel sources

 

Alrighty, then I guess I haven't tried that at all. Are there easy instructions to follow for non-tuxonice hibernation? 

That being said, the md problems are higher on my priority list than the other two, though if I can fix the other two without changes to /bin, /sbin, or /etc, I guess that's steps towards a less borken state.

----------

## PsychoI3oy

With the system booting from parted magic, this is what happens when I try to create md3: 

```
root@partedmagic:~# mdadm --create --verbose /dev/md3 --level=mirror --raid-devices=3 /dev/sdc3 /dev/sda3 /dev/sdb3

mdadm: /dev/sdc3 appears to contain an ext2fs file system

    size=44635136K  mtime=Sat Aug 10 02:47:25 2013

mdadm: Note: this array has metadata at the start and

    may not be suitable as a boot device.  If you plan to

    store '/boot' on this device please ensure that

    your boot-loader understands md/v1.x metadata, or use

    --metadata=0.90

mdadm: /dev/sda3 appears to contain an ext2fs file system

    size=44636600K  mtime=Tue Jun 18 13:31:36 2013

mdadm: /dev/sda3 appears to be part of a raid array:

    level=raid1 devices=3 ctime=Fri Jun 21 13:32:25 2013

mdadm: /dev/sdb3 appears to contain an ext2fs file system

    size=44636600K  mtime=Tue Jun 18 13:31:36 2013

mdadm: /dev/sdb3 appears to be part of a raid array:

    level=raid1 devices=3 ctime=Fri Jun 21 13:32:25 2013

mdadm: size set to 44602240K

Continue creating array? y

mdadm: Defaulting to version 1.2 metadata

mdadm: array /dev/md3 started.

```

ok... good enough, now to mount it: 

```
root@partedmagic:~# mount /dev/md3 /mnt/local/

mount.nilfs2: Error while mounting /dev/md3 on /mnt/local: Invalid argument
```

hmm, dmesg tail says 

```
[  477.407764]  md3: unknown partition table

[  695.249011] NILFS: Can't find nilfs on dev md3.
```

what about ... 

```
root@partedmagic:~# mount -t ext3 /dev/md3 /mnt/local

mount: wrong fs type, bad option, bad superblock on /dev/md3,

       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try

       dmesg | tail or so.

```

dmesg says: 

```
[  763.716132] EXT3-fs (md3): error: can't find ext3 filesystem on dev md3.
```

and fsck /dev/md3 says: 

```
root@partedmagic:~# fsck /dev/md3

fsck from util-linux 2.23.1

e2fsck 1.42.7 (21-Jan-2013)

ext2fs_open2: Bad magic number in super-block

/sbin/e2fsck: Superblock invalid, trying backup blocks...

/sbin/e2fsck: Bad magic number in super-block while trying to open /dev/md3

The superblock could not be read or does not describe a correct ext2

filesystem.  If the device is valid and it really contains an ext2

filesystem (and not swap or ufs or something else), then the superblock

is corrupt, and you might try running e2fsck with an alternate superblock:

    e2fsck -b 8193 <device>

root@partedmagic:~# 
```

I previously attempted to restore those superblocks on /dev/md3 and it did not work; restored them on sd[abc]3 and it worked for fscking the partitions individually and let me mount them individually but the md stuff gave me problems after that. I don't remember what I did to get it to the point it's at now where it'll assemble but not mount.

----------

## PsychoI3oy

I've just run 

dd if=/dev/sdc3 of=/mnt/backup/sdc3.dmp 

to get a copy of one of the drives. 

I've now reassembled md3 and after it's done syncing will run 

dd if=/mnt/backup/sdc3.dmp of=/dev/md3

and we'll see how that goes.

----------

## PsychoI3oy

dd didn't work, couldn't mount dump because mount didn't understand "linux raid member", so I just reformatted md3 and copied over (as files, with cp) from a different backup.

----------

## PsychoI3oy

With a few more tries and partition deletions/recreations, new filesystems, etc I now have an md3 that mounts, fscks, and operates reliably. I can mount it and chroot into it from the parted magic disk. 

But dracut won't assemble it on boot. Once inside it is trivial to mdadm --assemble it. 

I have tried two times to get a new dracut initrd working, by chrooting into the desktop and mounting all the things then running dracut. I have edited the grub.conf to point to the new UUID of md3 and edited mdadm.conf to point to the UUID given by mdadm --detail ... 

Dracut, however, doesn't want to admit md even is a thing. With the older initrd it'll grab md1 and 4 and then dump me in a shell complaining that it can't find md4. With any initrd created in the chroot, it doesn't do any md scanning at all.

----------

## PsychoI3oy

adding rd.auto to dracut made it kernel panic; but based on that grknight suggested it's newer md metadata that's throwing things off, so huge thanks to grknight on #gentoo for suggesting using genkernel instead of dracut to make the initrd. 

so I ran

```
genkernel --mdadm --lvm initramfs
```

I swapped the ramfs it created in to the line I'd been using with the newer dracut, took off rd.auto and added 'dolvm domdadm' and it booted up just fine. My arrays are now md127, md126, and md125 but as long as it knows what's up. 

I'm so happy to have ... a functional computer (much less working raid on / ) that I don't even care about the silly hibernation stuff right now.

----------

## PsychoI3oy

 *Hu wrote:*   

> Can you try with the in-kernel hibernation support or uswsusp hibernation?

 

Now I remember why I was using tuxonice, it supports spanning multiple swap partitions. I've got 3 5GB swaps across the 3 disks, and depending on what I'm doing I suspect that's not enough for the 16GB of ram in my machine. 

Hilariously, googling my issue with ToI not turning off the computer now brings up this thread as the top hit.

----------

## PsychoI3oy

And with an upgrade (from 3.9.2) to gentoo-sources-3.10.6 and the corresponding TuxOnIce patch, the computer just shut itself off after hibernating and didn't crash with my usb hdd turned on when I resumed. 

Yay.

----------

