COMP 3000 Lab 4 2010: Difference between revisions

From Soma-notes
No edit summary
Hesperus (talk | contribs)
Added a note about mem size. -- Munther
 
(10 intermediate revisions by 6 users not shown)
Line 6: Line 6:
# Add a new grub menu item which limits the standard kernel to 256M.
# Add a new grub menu item which limits the standard kernel to 256M.
# Add a second virtual disk and make it bootable: put the kernel and initial ram disk on it and then install grub.  Can you boot off of this disk?  What does it do?   
# Add a second virtual disk and make it bootable: put the kernel and initial ram disk on it and then install grub.  Can you boot off of this disk?  What does it do?   
# Mount the standard kernel's initial ram disk (initrd).  What program is first run in this environment?  What does it do?
# Examine the standard kernel's initial ram disk (initrd).  What program is first run in this environment?  What does it do?
# Modify the standard initial RAM disk so it pauses for 10 seconds and prints a message to the console on boot.
# What programs does upstart start on boot?
# What programs does upstart start on boot?


Line 12: Line 13:


Please add your hints below to help your fellow students!
Please add your hints below to help your fellow students!
=== Pro-tip ===
sudo update-grub (important!!! guess what it does!!!)


===Kernel command line options===
===Kernel command line options===


===GRUB configuration===
*On Ubuntu the user configuration is stored in /etc/default/grub, while system grub configuration is in /etc/grub.d.  The main grub files are stored in /boot/grub.  You can update grub's config with the update-grub command.
*to limit RAM, go to /etc/default/grub, and change default boot options so that mem=256M is included. Make sure to include the M in the mem=256M to denote MB. Otherwise, your Linux distribution will allocate 256 bytes ! Which means you won't be able to boot to the system again, since 256 bytes is not enough for the system to start.
=== Adding a new grub menu item ===
You need to edit the /etc/grub.d/40_custom file.  You can add custom menu items there using:
  menuentry "my menu item name"
  {
      boot parameters go here
  }
To find out what boot parameters you need, reboot your system and look at the grub boot menu (hold down shift if your grub menu is being hidden by default, or comment out the GRUB_HIDDEN_* items in /etc/default/grub)
Once at the grub menu, select the default Linux boot item (the first one), and press 'e';  What you will then be shown is the grub script necessary to start Linux.  To make your own menu item, you want to add all of these things, exactly as seen, plus any extra kernel parameters (like mem=256M)


===GRUB configuration===


===How GRUB works===
===How GRUB works===


===mounting RAM disks===
===Making a disk bootable===


*You'll need to use a loopback mount: mount -o loop <device> <mountpoint>
===Examining RAM disks===


*Ubuntu (Debian) store initial RAM disks in the cpio format.  'zcat <file> | cpio -i' will extract its contents.


===Upstart/init===
===Upstart/init===
Upstart "jobs" are config (.conf) files in /etc/init that require one of two options an "exec" line or a "script"
The exec line allows the upstart to just simply execute a script elsewhere, while script allows you to shell script in the upstart job.
A special upstart job is rc.conf which maintains the original runlevel init.d scripts. You will see that rc.conf simply executes all the /etc/init.d scripts.
See more on upstart jobs at http://upstart.ubuntu.com/getting-started.html
For those using the newer versions of Ubuntu and thus using Grub2
https://help.ubuntu.com/community/Grub2

Latest revision as of 17:19, 2 November 2010

All of the following should be done with an Ubuntu 10.04 distribution or equivalent. We recommend experimenting in a virtual environment because some of the exercises could make your system unbootable. (In fact, take a snapshot of your working system before starting these exercises so you can easily revert.)

Questions

  1. Change the grub command line at boot to limit the total available RAM to 256M. You'll need to get to select an entry and edit it from within grub.
  2. Add a new grub menu item which limits the standard kernel to 256M.
  3. Add a second virtual disk and make it bootable: put the kernel and initial ram disk on it and then install grub. Can you boot off of this disk? What does it do?
  4. Examine the standard kernel's initial ram disk (initrd). What program is first run in this environment? What does it do?
  5. Modify the standard initial RAM disk so it pauses for 10 seconds and prints a message to the console on boot.
  6. What programs does upstart start on boot?

Hints

Please add your hints below to help your fellow students!

Pro-tip

sudo update-grub (important!!! guess what it does!!!)

Kernel command line options

GRUB configuration

  • On Ubuntu the user configuration is stored in /etc/default/grub, while system grub configuration is in /etc/grub.d. The main grub files are stored in /boot/grub. You can update grub's config with the update-grub command.
  • to limit RAM, go to /etc/default/grub, and change default boot options so that mem=256M is included. Make sure to include the M in the mem=256M to denote MB. Otherwise, your Linux distribution will allocate 256 bytes ! Which means you won't be able to boot to the system again, since 256 bytes is not enough for the system to start.


Adding a new grub menu item

You need to edit the /etc/grub.d/40_custom file. You can add custom menu items there using:

  menuentry "my menu item name"
  {
      boot parameters go here
  }

To find out what boot parameters you need, reboot your system and look at the grub boot menu (hold down shift if your grub menu is being hidden by default, or comment out the GRUB_HIDDEN_* items in /etc/default/grub)

Once at the grub menu, select the default Linux boot item (the first one), and press 'e'; What you will then be shown is the grub script necessary to start Linux. To make your own menu item, you want to add all of these things, exactly as seen, plus any extra kernel parameters (like mem=256M)


How GRUB works

Making a disk bootable

Examining RAM disks

  • Ubuntu (Debian) store initial RAM disks in the cpio format. 'zcat <file> | cpio -i' will extract its contents.

Upstart/init

Upstart "jobs" are config (.conf) files in /etc/init that require one of two options an "exec" line or a "script"

The exec line allows the upstart to just simply execute a script elsewhere, while script allows you to shell script in the upstart job.

A special upstart job is rc.conf which maintains the original runlevel init.d scripts. You will see that rc.conf simply executes all the /etc/init.d scripts.

See more on upstart jobs at http://upstart.ubuntu.com/getting-started.html

For those using the newer versions of Ubuntu and thus using Grub2 https://help.ubuntu.com/community/Grub2