#!/bin/bash # Author: Interbird, interbird1964 at gmail.com # Version: 20071107 #4 # DISCLAIMER: ## If this script kills your cat then *you and only you* are responsible for that. ## ## In no way am I responsible for any damage caused by this script. ## # WARNING: ## Before you run this script, do a cp -a /boot /boot.backup as root. ## # WARNING: ## Be sure to have at least 30MB free in /boot. ## # This script tries to fix the quirk that seems to be in the gutsy initramfs code. # It does this by modifying the initrd.img image. # Make sure you have at least 30MB of free space in /boot. # Note that this hack is not a proper solution. # Make sure long lines are not wrapped when you paste this script in your editor. # This script uses sed. # USAGE: Put this script anywhere you want. # Make it executable with: chmod +x fix-gutsy-initramfs # Then run: sudo ./fix-gutsy-initramfs # After the script is done, make sure the new initrd.img is present in the /boot directory. # Reboot your computer. # Kernel log-lines should now appear after a few seconds. # If you put fbcon and vesafb in /etc/modules you can remove them because they are now loaded in the initrd image. # History: 20071107 #4 - Set language variable to en_US to prevent cpio from generating "mailformed number" errors # on other language-settings like en_IN. # - Added check if initrd image exists, aborting if it does not. # - Added check if backup-file exists so the backup does not get overwritten # if this script is used multiple times. # - Added check for existnnce of new initrd at end of script, restoring the backup if not present. # 20071107 #3 - Changed the sebang from #!/bin/sh to #!/bin/bash so popd and pushd are available. # - Removed the apt-get install for tclx # 20071107 #2 - Incorrectly added tclx to solve missing pushd/popd commands. # They are a bash feature and not supported by dash, which is Ubuntu's default shell. # 20071106 - first version # I hope this script works for you. # If you have trouble using it you can mail me at the above address. # Message header clear echo "" echo "###############################################################################" echo " This script changes your initramfs to unconditionally load the vesafb driver. " echo " After the script has run, check that /boot contains the new initrd.img. " echo "###############################################################################" echo "" echo " Press ENTER to continue, press Ctrl-C to abort..." read # On some other language settings, like en_IN, cpio generates a "malformed numer" error. # So let's set the language to standard US English while this script runs. export LANG="en_US" # We need sed, so lets make sure it is installed. apt-get install sed # Enter the directory where the initrd image resides. pushd /boot # Get the version of the running kernel. kv="$(uname -r)" # Compose the filename of the initrd image. initrd_img="initrd.img-$kv" # This is the name of the temporary directory we use to extract the initrd image. tmpdir="tmp-initrd" # The framebuffer driver we want loaded. # This driver should work on any vesa 2.0 compliant videocard. fbdriver="vesafb" # First we check the initrd image exists. if [ ! -e $initrd_img ]; then echo "" echo "ERROR: No /boot/$initrd_img found !!" echo "Aborting..." echo "" exit 1 fi # Second we make a backup of the current initrd image if that does not exist yet. if [ ! -e $initrd_img.backup ]; then cp -a $initrd_img $initrd_img.backup fi # Remove the temporary directory if it exists so this script can be run from scratch more than once. rm -rf $tmpdir # Create the temprary directory mkdir -p $tmpdir # Unzip the current initrd image to the temporary directory. gzip -cd $initrd_img > $tmpdir/$initrd_img # Enter the temporary directory. pushd $tmpdir # Unpack the initrd image. cpio -i < $initrd_img # Remove the unpacked initrd image to prevent it from being included in the new initrd image. rm $initrd_img # Enter the directory where the blacklist files are. pushd etc/modprobe.d # Make a backup. cp -a blacklist-framebuffer blacklist-framebuffer.backup # Unblacklist the framebuffer module. cat blacklist-framebuffer.backup | sed -e 's/^.*blacklist '$fbdriver'/#blacklist '$fbdriver'/' > blacklist-framebuffer # Back to temporary directory. popd # Now one would think that this would be enough but it seems it still does not load. # So, we change a script too to make the modules load unconditionally. # Enter boot-scripts directory. pushd scripts/init-top # We don't want duplicate lines, so remove them if they are present present. cat framebuffer | sed -e '/modprobe fbcon/d;/modprobe '$fbdriver'/d' > framebuffer.tmp # Now add the modules to the end of the script so they will be loaded unconditionally. echo "modprobe fbcon" >> framebuffer.tmp echo "modprobe $fbdriver" >> framebuffer.tmp # Rename the script to its original name. mv -f framebuffer.tmp framebuffer # Make it executable again. chmod +x framebuffer # Back to temporary directory. popd # Now create a new initrd image and put it in the parent directory which is /boot. # This overwrites the bad one. find . | cpio -V -H newc -o | gzip -9 > ../$initrd_img # Back to /boot directory popd # Cleanup the temporary directory. rm -rf $tmpdir #rm /boot/$initrd_img #rm /boot/$initrd_img.backup # Check there is an initrd image present. if [ ! -e "/boot/$initrd_img" ]; then echo "" echo "ERROR: /boot/$initrd_img does not exist !" echo " Trying to restore the backup made by this script..." echo "" if [ ! -e "/boot/$initrd_img.backup" ]; then echo "" echo "ERROR: /boot/$initrd_img.backup does not exist !" echo " Do *not* reboot your computer now !" echo " Restore the backup you made with cp -a before running this script !" echo "" exit 1 fi # Restore the backup version cp -a $initrd_img.backup $initrd_img echo "" echo "NOTE: Something went wrong..." echo " The script has restored the backup-version of the initrd image." echo " Your initrd image has *not* been modified." exit 1 fi echo "" echo "NOTE: Looks like things went OK." echo " Check /boot to be sure and then restart your computer." echo "" # Back to wherever this scripts was called from. popd