Several years ago I wrote a series of posts on how to run EL6 with its root filesystem on tmpfs. This post is a continuation of that series, and explains step by step how to run CentOS 7 with its root filesystem in memory.
The post is a bit terse to focus on the concept, and several of the steps have potential for improvements. A build host is needed to prepare the image to boot from.
Create some directories that will be used later, however feel free to relocate these to somewhere else:. I expect that most people would like to create their own disk image from scratch, but this is outside the scope of this post. Use virt-builder to download a pre-built CentOS 7. Production environments should have SELinux enabled.
How to Re-generate initramfs and vmlinuz for Rescue Kernel with Current Kernel in CentOS/RHEL 7
The initramfs will be based on BusyBox. Create the root filesystem archive using tar. The following command also uses xz compression to reduce the final size of the archive from approximately 1 GB to MB :. Home Posts CentOS 7 root filesystem on tmpfs. The following is a screen recording from a host running CentOS 7 in tmpfs: Build environment A build host is needed to prepare the image to boot from.
The boot procedure will be, simply put: Fetch kernel and a custom initramfs.
Execute kernel. Mount the initramfs as the temporary root filesystem for the kernel. Create a tmpfs mount point. Extract our CentOS 7 root filesystem to the tmpfs mount point. Create initramfs.Corruption of initramfs can be occur by many ways for example after patching CentOS 7 Linux OS or installing a buggy device driver in server you found CentOS 7 Linux server has become unbootable. You may also encouter below kernel panic error because server initramfs got damaged.
In this tutorial I will demonstrate you how to recover the CentOS 7 Linux initramfs boot image in such scenario also where server does not have old or previous kernel to boot into it. During Linux booting initramfs load itself in memory and mount the root filesystem, initramfs contains kernel modules and initial scripts which are require for booting Linux system to next stage of booting.
Everytime when new kernel install in system new initramfs built. Utility dracut which can be use for managing and rebuilding initramfs in case of initramfs image get damage. You can see contents of current initramfs in CentOS 7 Linux system with command lsinitrd example below:. You might have noticed in above screenshot it is getting output of current booted kernel initramfs image.
It contains combination of commands, system files and directories these are require during booting of system. We will use dracut utility as I have mentioned above for recovering damaged initramfs for making CentOS7 Linux system bootable again. Also you can inspect the rebuilt initramfs image which is associated with current kernel version with below command:. This site uses Akismet to reduce spam. Learn how your comment data is processed.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up. After my last launch yum update my test box have kernel While installing, dracut generated initramfs How to generate new rescue initramfs image with new kernel and new kernel modules like zfs installed? This script checks for the presence of the rescue kernel and image and doesn't create new ones when additional kernels are installed.
Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Ask Question. Asked 3 years, 11 months ago. Active 3 years, 11 months ago. Viewed 9k times. Active Oldest Votes. Luke Dixon Luke Dixon 1 1 silver badge 4 4 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.
This is useful if you need to do something special to get your root partition visible to the kernel. For example, if it is an lvm partition, encrypted or on USB. You can also stay in the initramfs. This can be very useful for debugging, or if you just want a very fast booting system. Before we get to the fun bit, you'll need to create a few folders. The empty mdev. If it's compiled statically, it is usually the only binary file you will need in the initramfs image.
BusyBox can be compiled using glibc or uClibc. Both work just the same, but uClibc produces quite a lot smaller binaries. To use your own BusyBox, but make sure it's static. When passing an initramfs to the kernel using your bootloader the initrd option in Grubthe kernel is expecting a gzipped cpio archive. When building the initramfs image into the kernel, one of the easiest ways is to create a cpio archive.
We will be creating both files. This way you won't need to pass an initrd option to your bootloader, but when you update the initramfs image, you will also need to rebuild the kernel. If you do want to do this, give the path to the initramfs.
To pass the initramfs. Howto create an initramfs image Initramfs is the new way of doing stuff before the root partition is mounted. Creating the folder structure Before we get to the fun bit, you'll need to create a few folders. Creating the. Images by Mrs A.Help answer threads with 0 replies. Welcome to LinuxQuestions. You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features.
Registration is quick, simple and absolutely free. Join our community today! Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Are you new to LinuxQuestions. If you need to reset your password, click here. Having a problem logging in?CentOS - RAMFS vs TMPFS
Please visit this page to clear all LQ-related cookies. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration.
This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant.
They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click Here to receive this Complete Guide absolutely free. Initially after installing Centos 7 I had 2 entries in grub: Code:. Last edited by leniviy; at AM. Last edited by syg00; at AM. I think I found it: Code:. So you only get one per install - maybe ok for Servers, but as in my case, version updates leave it horribly out of date.
I guess they don't want to risk replacing it each kernel update in case you need to use the immediate prior one for a recovery.
And just to clean this up, yes the next kernel update did re-generate the rescue one it had been deleted. Tags dracut Thread Tools.
BB code is On. Smilies are On. All times are GMT The time now is AM. Open Source Consulting Domain Registration. Search Blogs. Mark Forums Read. How to re-generate rescue kernel image for current kernel?
User Name.Privacy Terms. Quick links. We've been weighing up the pro's and con's of the various options available to us and have decided to migrate out VM estate to Hyper-V. We've got the majority of our Windows servers moved over which are working well, however we have a couple of CentOS VM guests that are causing us some real problems. The migration over to Hyper-V works absolutely fine, but the guest refuses to boot and sticks on the screen shown in the attached screenshot.
You do not have the required permissions to view the files attached to this post. You need to rebuild the initramfs - which it sounds like you tried but I supsect you did it before the migration and you need to boot the rescue kernel the one that works and do it on the new "hardware" so that it autodetects what's present and builds the right initramfs file. Once you have one that works you can lsinitrd that and compare it to the same on a non-migrated initramfs and see what the differences are and then you can tell dracut what to include the stuff that's missing!
CentOS 6 will die in November - migrate sooner rather than later! Full time Geek, part time moderator.
Use the FAQ Luke. If I use the "rescue" grub system choice, it boots up. Does anybody know if there is anyway to get this to work, which I guess would require Centos 7 to try to load both bare metal and virtual drivers? Using this option, the resulting image will contain only those dracut modules, kernel modules and filesystems, which are needed to boot this specific machine.
Subscribe to RSS
The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I've been building my own kernel 4. Neither has helped.
Here I can load both the old and new kernel without any issue, as well as initramfs, but when I execute boot I get a kernel panic:. Naturally, it is my assumption that there is something wrong with my initramfs As an experiment, I tested if I could load the new kernel, but use the old initramfs 4.
I however cannot do the opposite, old kernel with new initramfs. So something is fishy with my new initramfs image. Getting smarter, my last experiment was mounting the old and new initramfs image with mount. They both mount successfully with no errors, and seem to have identical file structures. I have also compared both my new and old.
So the final question s are - What's wrong with the initramfs form these builds? What else can I do to validate it's integrity? Are there any. Disclaimer: So this actually an continuation of [this question], but I've simplified the problem a bit. Some background info there might be relevant.
Learn more. Custom built kernel produces non-bootable initramfs on Centos 7 Ask Question. Asked 10 months ago. Active 10 months ago. Viewed 72 times. Here I can load both the old and new kernel without any issue, as well as initramfs, but when I execute boot I get a kernel panic: end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block 1,0 Naturally, it is my assumption that there is something wrong with my initramfs My hard drive is xfswhat is the file system for the initramfs?
I can't for the life of me figure out what I did differently then. DrTarr DrTarr 1 1 gold badge 6 6 silver badges 28 28 bronze badges. The initramfs is populated from a cpio archive file. There is no such thing as an "initramfs image".