Mesclar / inicializar e reorganizar as entradas do grub2

2

Eu usei o 10.10 e agora, para fins de teste, instalei o 10.04 em uma partição separada. 10.10 está atualmente em uma única partição, enquanto que para 10.04 eu decidi separar / inicializar em uma terceira partição. Agora minhas perguntas:

  • Como posso mover e mesclar o 10.10 / boot na nova partição / boot
  • O que devo modificar para reorganizar as entradas (automáticas)?
  • Como posso ter as entradas contendo o nome da distribuição para reduzir a confusão?
  • Como posso ter certeza de que a configuração do grub permanece idêntica nas atualizações de distribuição?
por Tobias Kienzler 09.01.2011 / 09:58

1 resposta

1

Isto é como mover a inicialização do seu 10.10 para a partição separada:

Having /boot on its own partition is useful if you use many linux 
distributions, especially on different hard disks. Besides, if your 
root filesystem gets corrupted, you’ll still be able to boot if your /boot 
is separate.
Let’s get started.. first of all we need to create a new ext3 partition 
which will be our new /boot. In order to decide how big it should be, let’s 
see how much space our current /boot is taking up. A value of 100Mb should 
suffice for most needs (unless you’re a kernel hacker with lots of images 
in /boot):

$ du -h /boot

Once we have an idea about the size, go ahead and create the partition. You 
can use GParted… or if you prefer the command line, use mkfs:
# mkfs -t ext3 /dev/hda#
Now let’s assume that the partition you just created is /dev/hdaX (replace X 
with the actual digit). We’ll proceed as follows (prepend sudo before each 
command, or relogin as root):
1. # mkdir /mnt/newboot
2. # mount /dev/hdaX /mnt/newboot
3. # cp -dpR /boot/* /mnt/newboot/
4. # mv /boot /oldboot
5. # mkdir /boot
6. # nano -w /etc/fstab
and modify the /boot line to:
/dev/hdaX /boot ext3 ro 0 0
Note that we want /boot to be mounted read-only after the OS boot process. 
You can also delete the whole entry altogether to prevent /boot from being 
mounted.
7. # umount /mnt/newboot
8. # mount /dev/hdaX /boot
9. # nano -w /boot/grub/menu.lst
Now change the entries corresponding to your old root partition to /dev/hdaX. 
In grub’s terms, that translates to (hd0,X-1) if it’s the first hard drive. 
For eg, /dev/hda8 is (hd0,7). Note that you also need to change /boot/xxx.x 
entries to /xxx.x since the /boot partition is itself the root partition in 
grub’s eyes. For eg, /boot/grub becomes /grub. Finally, install grub onto the 
MBR. Issue:
10. # grub-install /dev/hda
(Replace /dev/hda with the /dev/… entry of the hard disk where you want to 
install Grub to).
All done! Now reboot.
P.S: Any time you want to write to /boot, do a:
$ sudo mount -o remount,rw /boot

Referência: link

E isso é como editar as entradas automáticas:

Creating the Custom Menu

The user can either edit the default /etc/grub.d/40_custom file or create a 
new one. The easiest way to create the content of a custom menu is to copy a 
working entry from /boot/grub/grub.cfg. Once copied, the contents of 
40_custom can be tailored to the user's desires.

According to the default sample custom file (/etc/grub.d/40_custom) the 
first two lines of any custom file in /etc/grub.d should be:
#!/bin/sh
exec tail -n +3 $0
The user can copy existing menuentries from the /boot/grub/grub.cfg file (...)

General menuentry Construction Rules:

The first line must start with menuentry and end with {
The area between the quotation symbols is what will appear on the GRUB 2 menu. 
Edit as desired.
The last line of the menuentry must be }
Do not leave empty spaces at the end of lines
The set root= line should point to the GRUB 2 /boot location ( (hdX,Y) )
The root reference in in the linux line should point to the system partition.
If GRUB 2 cannot find the referenced kernel, try replacing the UUID with the 
device name (example: /dev/sda6 ).
A sample entry copied from the grub.cfg and altered by the user might look 
like this:
menuentry "My Default Karmic" {
set root=(hd0,1)
search --no-floppy --fs-uuid --set cb201140-52f8-4449-9a95-749b27b58ce8
linux /boot/vmlinuz-2.6.31-11-generic root=UUID=cb201140-52f8-4449-9a95-749b27b58ce8 ro quiet splash
initrd /boot/initrd.img-2.6.31-11-generic
}

Referência: link

    
por desgua 02.04.2011 / 04:25