how to edit initramfs to add a new partition after boot in CentOs how to edit initramfs to add a new partition after boot in CentOs shell shell

how to edit initramfs to add a new partition after boot in CentOs


I'm gonna go on a guess here.

If I understand what you want to do correctly, what you want to do is to make another ext3 partition visible in CentOS.

If so, you want to make sure that the partition exists. Maybe you have a disk called /dev/sda it might have 2 partitions:

     sda1 ext3 mounted at /bootand  sda2 ext3 mounted at /

To view this use sudo blkid, fdisk-l or similar. These partitions are loaded at boot from the list found in /etc/fstab.

Say you still have space left on the disk. Use fdisk/gparted to create a new ext3 partition sda3. Add a line for that disk in /etc/fstab.

Now it should be accessible after a reboot or after sudo mount -a.

I might have completely misunderstood your question.

Edit #1

I think I understand what you want to do now, and you probably want to edit the /etc/fstab within the initramfs. I have never tried doing this and I don't know if it would work, but it should. In any event, unless you really need to mount the partitions in initramfs, use the above to mount it in fstab.

Extracting the contents of and repacking an edited initramfs is rather complex, but here are some links explaining how to extract and repack, they are for gentoo but there should be no difference:

If you read those threads you should be able to use a script or C program to extract the contents of the initramfs, change the contents of /etc/fstab within initrams, and extract it back together. If you need to do this for different computers they will need to need the same contents in initramfs, or you need to do this for each computer setup.