Ubuntu - Remove the prompt to eject CD

How to remove the Ubuntu eject CD prompt: The following tutorial covers the process of removing the "Please remove the disk, close the tray (if any) and press ENTER to continue" prompt entirely from your USB Ubuntu installation.
The process is fairly simple and will allow your system to shutdown or restart without prompting you to remove the CD. Those booting from a USB stick, will surely be glad to get rid of the remove CD annoyance.

Essentials to Remove eject CD prompt

  • Ubuntu Live USB
  • CD-Rom drive
  • 3-4 GB free space on a USB storage device or hard drive (partitioned as ext2 or ext3) for storing the extracted filesystem

Removing the prompt to eject CD feature in Ubuntu

NOTE: This tutorial is intended for older versions. To remove the prompt to eject CD with the newer and most recent versions of Ubuntu or Debian, you can simply add the word noprompt to the kernel append line in your corresponding syslinux.cfg or grub.cfg configuration file.

The following procedure follows the same guidelines as the boot to ram tutorial with the exception that we will be removing a couple of files. The first step is extracting or decompressing filesystem.squashfs:

  1. Insert your Ubuntu Live USB.
  2. Reboot your PC, and press your BIOS Hotkey to enter BIOS during system post.
  3. Set your BIOS to boot from the USB drive, and proceed to boot from your Live USB.
  4. Open a terminal Ctrl+Alt+T
  5. Type the following command to list the drive letter/partition number you want to use:
    sudo fdisk -l
  6. Type the following commands, replacing sdx# with your actual drive letter/partition number found in step 4:
    sudo mkdir /c && mount /dev/sdx# /c
    sudo mount -o loop -t squashfs /cdrom/casper/filesystem.squashfs /mnt
    sudo mkdir /c/fix rsync -avx -P /mnt/. /c/fix/.
    sudo umount /mnt
  7. To remove the prompt to eject CD:
    sudo rm -r /c/fix/etc/rc0.d/*casper
    sudo rm -r /c/fix/etc/rc6.d/*casper
  8. To regenerate the initrd.gz:
    sudo chroot /c/fix /bin/bash
    sudo mkinitramfs -o /new-initrd.gz 2.6.20-15-generic
    exit
    sudo mv /c/fix/new-initrd.gz /c/initrd.gz
  9. To rebuild and compress the new filesystem.squashfs:
    sudo apt-get install squashfs-tools
    sudo mksquashfs /c/fix /c/filesystem.squashfs -noappend -always-use-fragments
  10. Insert your bootable USB Ubuntu pen drive and replace the old filesystem.squashfs and initrd.gz files with the new files from the "new" directory on your other USB drive or partition.
  11. Reboot, and enjoy an Ubuntu Live USB that no longer prompts you on shutdown to remove the disk and close the tray!