# [solved]determine whether initramfs was used or not for boot

## toralf

Wakeup from suspend2disk does not work at my system w/o an initramfs. Sometimes I boot a straight kernel (make && make install && make modules_install). Therefore I'd like to put a test into my suspend2[ram|disk] script to prevent me from doing the wrong thing.Last edited by toralf on Sun Jul 15, 2012 7:46 pm; edited 1 time in total

----------

## nlsa8z6zoz7lyih3ap

I have no idea whether this is helpful or not, but I do use and initramfs at boot

and dmesg gives me: *Quote:*   

> dmesg|grep -1  initramfs
> 
> PCI: CLS 64 bytes, default 64
> 
> Trying to unpack rootfs image as initramfs...
> ...

 

----------

## wcg

You could use CONFIG_LOCALVERSION to append some identifier

for the initramfs kernels to the kernel name. For example, I have

```

CONFIG_LOCALVERSION=-md

```

for a kernel with raid support enabled.

When I run

```

uname -r

```

while one of those kernels is booted,

the output of "uname -r" is

```

[kernel version]-gentoo-md

```

(You could grep for your own custom suffix in a script that

runs "uname -r".)

Maybe

```

CONFIG_LOCALVERSION=-irfs

```

so that "uname -r" shows

```

[kernel version]-gentoo-irfs

```

if you are running a kernel with initramfs support

enabled.

(CONFIG_LOCALVERSION_AUTO is not set. That does something

a little different, according to the make menuconfig help description

for that kernel config option.)

This does not show that you actually booted from an initramfs,

only that you booted a kernel where that LOCALVERSION

string was configured in. You would have to remember to leave

it out of kernels that you boot without the initramfs for it to

be a reliable indicator.

----------

## toralf

Although dmesg has a  limitation due to the buffer size, the version string has some other disadvantages - I took the dmesg approach.

Thx guys for the hints.

----------

## khayyam

 *toralf wrote:*   

> Although dmesg has a  limitation due to the buffer size, the version string has some other disadvantages - I took the dmesg approach.

 

toralf ...  for dmesg its best not to use grep ... the following will be alot less greedy ...

```
awk '$2=="initrd" {print ; exit}' <(dmesg)
```

best ... khay

----------

## gorkypl

 *toralf wrote:*   

> Although dmesg has a  limitation due to the buffer size

 

Just set a high value for CONFIG_LOG_BUF_SHIFT

----------

