| Partitionen mit rsync kopieren |
| Linux - Quick & Dirty |
| Donnerstag, den 10. Februar 2011 um 00:00 Uhr |
|
Mit dieser Anleitung wird kurz beschrieben wie man unter Linux (Debian Squeeze) mit Hilfe von rsync alle Daten der root Partition inklusive Bootloader auf eine zweite Festplatte überträgt.
1. Zweite Festplatte einbauen und mit fdisk partitionieren
Quellpartition: /dev/sda1 Zielpartition: /dev/sdb1
2. Dateisystem und Auslagerungsdatei auf neu erstellter Partition anlegen. mkfs.ext3 /dev/sdb1
mkswap /dev/sdb2 3. Daten von /dev/sda1 auf /dev/sdb1 kopieren mkdir /mnt/quelle && mount /dev/sda1 /mnt/quelle
mkdir /mnt/ziel && mount /dev/sdb1 /mnt/ziel rsync -avH --progress /mnt/quelle/ /mnt/ziel/ 4. Grub auf Zielfestplatte installieren: grub-install --root-directory=/mnt/ziel /dev/sdb
4. Mit dem Befehl blkid die UUID der Partitionen anzeigen lassen. root@debian:~# blkid /dev/sda1: UUID="d440dc07-d8a5-4c12-b6a5-0678dae3be7e" TYPE="ext3" /dev/sda5: UUID="99029539-cb3d-4724-8534-6e2666b34e06" TYPE="swap" /dev/sdb1: UUID="3b2ce02a-01a4-4612-8735-cfcafab9a4ea" TYPE="ext3" /dev/sdb2: UUID="223eb52b-5e0a-4f14-9458-5c6a9cd9d4d3" TYPE="swap" 5. Anschließend die Datei /mnt/ziel/etc/fstab entsprechend anpassen # /etc/fstab: static file system information. # # Use 'vol_id --uuid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 # / was on /dev/sdb1 during installation UUID=3b2ce02a-01a4-4612-8735-cfcafab9a4ea / ext3 errors=remount-ro 0 1 # swap was on /dev/sdb2 during installation UUID=223eb52b-5e0a-4f14-9458-5c6a9cd9d4d3 none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0 6. Auch in der Konfigurationsdatei des Bootloaders Grub Version 2 müssen die UUIDs der Partition /dev/sdb1 eingetragen werden: /mnt/ziel/boot/grub/grub.cfg #
# DO NOT EDIT THIS FILE # # It is automatically generated by grub-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # ### BEGIN /etc/grub.d/00_header ### if [ -s $prefix/grubenv ]; then load_env fi set default="0" if [ "${prev_saved_entry}" ]; then set saved_entry="${prev_saved_entry}" save_env saved_entry set prev_saved_entry= save_env prev_saved_entry set boot_once=true fi function savedefault { if [ -z "${boot_once}" ]; then saved_entry="${chosen}" save_env saved_entry fi } function load_video { insmod vbe insmod vga insmod video_bochs insmod video_cirrus } insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set 3b2ce02a-01a4-4612-8735-cfcafab9a4ea if loadfont /usr/share/grub/unicode.pf2 ; then set gfxmode=640x480 load_video insmod gfxterm fi terminal_output gfxterm insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set 3b2ce02a-01a4-4612-8735-cfcafab9a4ea set locale_dir=($root)/boot/grub/locale set lang=de insmod gettext set timeout=5 ### END /etc/grub.d/00_header ### ### BEGIN /etc/grub.d/05_debian_theme ### set menu_color_normal=cyan/blue set menu_color_highlight=white/blue ### END /etc/grub.d/05_debian_theme ### ### BEGIN /etc/grub.d/10_linux ### menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-686' --class debian --class gnu-linux --class gnu --class os { insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set 3b2ce02a-01a4-4612-8735-cfcafab9a4ea echo 'Loading Linux 2.6.32-5-686 ...' linux /boot/vmlinuz-2.6.32-5-686 root=UUID=3b2ce02a-01a4-4612-8735-cfcafab9a4ea ro quiet echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-2.6.32-5-686 } menuentry 'Debian GNU/Linux, with Linux 2.6.32-5-686 (recovery mode)' --class debian --class gnu-linux --class gnu --class os { insmod part_msdos insmod ext2 set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set 3b2ce02a-01a4-4612-8735-cfcafab9a4ea echo 'Loading Linux 2.6.32-5-686 ...' linux /boot/vmlinuz-2.6.32-5-686 root=UUID=3b2ce02a-01a4-4612-8735-cfcafab9a4ea ro single echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-2.6.32-5-686 } ### END /etc/grub.d/10_linux ### ### BEGIN /etc/grub.d/20_linux_xen ### ### END /etc/grub.d/20_linux_xen ### ### BEGIN /etc/grub.d/30_os-prober ### ### END /etc/grub.d/30_os-prober ### ### BEGIN /etc/grub.d/40_custom ### # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. ### END /etc/grub.d/40_custom ### ### BEGIN /etc/grub.d/41_custom ### if [ -f $prefix/custom.cfg ]; then source $prefix/custom.cfg; fi ### END /etc/grub.d/41_custom ### Danach kann der Rechner herunter- und die Festplatten ausgetauschet werden. |