User Tools

Site Tools


linux:filesystems:boot

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
linux:filesystems:boot [2012/04/25 15:34]
tkilla
linux:filesystems:boot [2022/03/12 21:14]
tkilla
Line 1: Line 1:
-====== boot ======+====== Bootloader ======
  
 **linux boot process tricks** **linux boot process tricks**
  
-=== howto clone harddisc and boot new system ===+==== howto clone harddisc and boot new system ====
  
-**To get the system-files transfered,** it's best to get a live USB-stick or CD and boot into it \\+**To transfer all system files,** it's best to get a live USB-stick or CD and boot into it \\
 (all live-distros from ubuntu to systemrescuecd are ok). \\ (all live-distros from ubuntu to systemrescuecd are ok). \\
-In a livesystem, you can mount the partitions and transfer the data anyway you like:+In a livesystem, you can mount the partitions and transfer the data anyway you like (as root user):
  
-1. rsync: 
-  parameters: " -a -v -z -h --perms -E -o -g  --times --compress --update --delete " 
-  excludes: " --exclude="/proc/*" --exclude="/sys/*" --exclude="/mnt/*" --exclude="/media/*" " 
  
-2copy with "cp": +1. **rsync** needs params and data must be excluded, (but works f&f in a running system), eg., :
-  $ sudo cp -afv /to/source//to/target/+
  
-3. dd can only be used, if both partitions have exactly the same size!+  rsync -a -v -z -h --perms -E -o -g  --times --compress --update --delete \ 
 +        --exclude="/proc/*" --exclude="/sys/*" --exclude="/mnt/*" --exclude="/media/*" / /mnt/newsys/
  
-4. gparted+-> may cause strange bugs, like permissions in /var/run/, maybe /dev probs 
 + 
 +2. simple **copy** with "**cp**" (untested): 
 +  cp -afv /from/sourcesystem/* /mnt/newsys/ 
 +  [ or ] 
 +  cp -ax /from/sourcesystem/* /mnt/newsys/ 
 +   
 + 
 +3. **dd** - clones each sector - can only be used, if both partitions have exactly the same size! 
 + 
 + 
 +4. **parted** - no ext4, only from livesystems
  
 etc... etc...
Line 24: Line 32:
 ---- ----
 \\ \\
 +**Fix partition-identifier UUIDs in fstab** of the new system.  \\
 +The UUIDs need to be replaced by the new UUIDs in **/mnt/newsys/etc/fstab**
 +This shows 'em all: :)
 +  ls -l /dev/disk/by-uuid/ 
  
-**Fix fstab** by mounting the new disc and editing /etc/fstab in there. \\ +---- 
-The UUIDs need to be replaced by the UUIDs of the new disc's partitions.+\\
  
-  $ ls -/dev/disk/by-uuid+**Install grub2 bootloader** to the new disc \\ 
 +unfortunately a complete change-root environment is required to fool grub-install: 
 + 
 +**mount dev, proc, sys** via "bind"-option **into the new root / chroot**: 
 +  mount -o bind /dev /mnt/newsys/dev 
 +  mount -t proc none  /mnt/newsys/proc 
 +  mount -t sysfs none /mnt/newsys/sys 
 + 
 + 
 +**Enter** the new (virtual) root system: 
 +  chroot /mnt/newsys/ 
 + 
 + 
 +Now inside this future system, grub2 installer scripts will work - \\ 
 +**generate a new (/mnt/newsys) /boot/grub/grub.cfg**:  
 +  update-grub 
 + 
 +In case of error "no such disc" run 
 +  grub-mkdevicemap 
 + 
 + 
 +**Install to the MBR (no partition number) of the new disc, finally:** 
 +  grub-install /dev/sdX 
 + 
 +reboot & good luck!
  
-.. shows 'em all :) 
  
 ---- ----
 \\ \\
  
-**Install grub2 - make the fresh harddisc bootable**+** initramfs ** 
 +the step after the bootloader needs all (fs, rais,..) modules to mount root, check: /etc/initramfs-tools/modules
  
-re-generate device.map+update existing initramfs: 
 +  update-initramfs -u -k all 
  
-  $ grub-mkdevicemap -m /icy/boot/grub/device.map+** RAID ** 
 +if you changed your raid setup, you need to update initramfs: 
 +  dpkg-reconfigure mdadm 
  
 +make sure these modules are in /etc/initramfs-tools/modules
 +  raid0
 +  raid1
 +  md
  
-install grub to MBR of new hdd (no partitionnumber, just the device)+\\ 
 +References: http://unix.stackexchange.com/questions/5297/debian-grub2-moving-root-partition-to-new-drive
  
-  $ grub-install --root-directory=/to/target-mountpoint/ /dev/sdX --recheck 
  
 +\\
 +==== howto boot from grub2 rescue console ====
 +
 +If you drop to the grub rescue after cloning a system disc or something, it's possible to boot an existing system.
 +
 +Enter this, to start a system on sda3 for example:  sda = hd0 + partition 3 = (hd0,3)
 +
 +  set prefix=(hd0,3)/boot/grub
 +  insmod (hd0,3)/boot/grub/linux.mod
 +
 +if this works, the console gets upgraded to standard grub console.
 +
 +if it doesn't work, try another partition. grub counts partitions from 1 (not 0), btw.
 +
 +This boots arch linux:
 +
 +  set root=(hd0,3)
 +  linux /boot/vmlinuz26 root=/dev/sda5
 +  initrd /boot/kernel26.img
 +  boot
 +
 +This is required to boot debian - unfortunately the filenames contain versionnumbers :( 
 +  set root=(hd0,3)
 +  linux /boot/vmlinuz-3.1.0-1-amd64 root=/dev/sda3
 +  initrd /boot/initrd.img-3.1.0-1-amd64
 +  boot
      
  
 +This should boot your system. Just re-install grub:
  
 +  update-grub
 +  grub-install /dev/sdX
  
 +
 +===== Bugs =====
 +
 +Inside a chroot, grub complains 
 +  # update-grub                                                                                                                                                                                                                   
 +  Generating grub configuration file ...
 +  WARNING: Device /dev/ram0 not initialized in udev database even after waiting 10000000 microseconds.
 +  ...
 +
 +Fix:
 +
 +Outside chroot /debian/:
 +
 +  mkdir /debian/run/udev
 +  mount --bind /run/udev /debian/run/udev
 +  mount --bind /run/udev /mnt/run/udev
 +
 +
 +===== Crypto Bugs =====
 +
 +
 +Grub complains root device couldn't be found 
 +
 +Fix: 
 +- set 
 +  GRUB_ENABLE_CRYPTODISK=y
 +
 +  apt install cryptsetup-initramfs lvm2
 +  
 +
 +- if it is a brtfs, set in /etc/initramfs/modules
 +  btrfs 
 +
 +
 +Commands to execute in chroot to reinstall grub:
 +
 +  update-initramfs -c -k all
 +  grub-install /dev/sdX
 +  update-grub
 +  
linux/filesystems/boot.txt · Last modified: 2022/11/06 21:39 by tkilla