Description of the process of transferring Ubuntu 9.10 to another hard drive (without using Ghost, Acronis True Image etc ...)
I think that many had such a situation when it becomes necessary to transfer the system from one screw to another. So my need has ripened.
Installed system on a disk with a capacity of 80 GB (second channel SATA - sdb). There is one / deb / sdb1 port on the disk, the system does not have swap.
transfer the system to another 320 GB hard drive connected to the first SATA (sda) channel, create and connect the swap swap partition on the new hard drive, place user directories in a separate partition as well.
Turn off the computer (the system is installed on the hard drive in the sdb1 partition)
Connect the second screw to the first SATA channel (receiver screw - sda)
We boot from LiveCD Start
Gparted and create partitions, which we will use in future for SWAP, / and home
Next: open the terminal and create subdirectories in the / mnt directory: Mount partitions on the created directories Copy the data from the / mnt / oldsys / home directory to / mnt / newhome, the same steps must be performed for / mnt / oldsys, only now from the copy process you will need to exclude the / mnt / oldsys / home directory, since a copy of this directory was made before. For this, I used the rsync utility: The next number in our program will be editing the / etc / fstab file: by default, fstab uses their UUIDs instead of file system names (for example: / dev / sdb1) if you do not plan to connect the drive to different SATA channels or If you transfer it to another computer, you can explicitly register the name of the file system, in our case it will look like this:
Otherwise, if you want to use the UUID, you can get it using the blkid utility: Now you need to transfer grub, since ubuntu 9.10 uses grub 2, the transfer occurs in a slightly different way than the old rude: Before installing the rude, I did the following steps (not required)
Next, use the mount command to remount the / dev and / proc directories in the / mnt / newsys / dev and / mnt / newsys / proc directories, respectively, using the --bind option - this is necessary so that in the chroot environment in the / directory dev there were device files / dev / sda *: We wrap in / mnt / newsys / Create device.map for grub As a result of this command, the file device.map will be created in / boot / grub / with the following contents (it will look different on different systems ) I have so:
We create a configuration file for grub
If errors did not come out and rude said approximately the following
Install grub. Since / dev / sda will be the boot disk on my system, I install the bootloader in mbr of this screw:
(here, instead of / dev / sda, you can put hd0 see the file /boot/grub/device.map).
The output of this command for my system is:
We leave from the circle
We do umount for / dev, / proc and / mnt / newsys Reboot, if everything is done correctly, then the system should boot without problems. To everyone who read to the end, thank you for your attention. I will be glad to comments and comments. UPD: Thank you all for karma, transferred to Ubuntarium.
And so we have:
Installed system on a disk with a capacity of 80 GB (second channel SATA - sdb). There is one / deb / sdb1 port on the disk, the system does not have swap.
Need to do:
transfer the system to another 320 GB hard drive connected to the first SATA (sda) channel, create and connect the swap swap partition on the new hard drive, place user directories in a separate partition as well.
Go:
Turn off the computer (the system is installed on the hard drive in the sdb1 partition)
Connect the second screw to the first SATA channel (receiver screw - sda)
We boot from LiveCD Start
Gparted and create partitions, which we will use in future for SWAP, / and home
- SWAP - 4 Gb, FS - SWAP (sda1)
- / - 40 Gb (sda2), FS - ext4 // * Important !!! Make partition bootable
- home - 251 Gb (sda3), FS - ext4
Next: open the terminal and create subdirectories in the / mnt directory: Mount partitions on the created directories Copy the data from the / mnt / oldsys / home directory to / mnt / newhome, the same steps must be performed for / mnt / oldsys, only now from the copy process you will need to exclude the / mnt / oldsys / home directory, since a copy of this directory was made before. For this, I used the rsync utility: The next number in our program will be editing the / etc / fstab file: by default, fstab uses their UUIDs instead of file system names (for example: / dev / sdb1) if you do not plan to connect the drive to different SATA channels or If you transfer it to another computer, you can explicitly register the name of the file system, in our case it will look like this:
sudo mkdir /mnt/oldsys
sudo mkdir /mnt/newsys
sudo mkdir /mnt/newhome
sudo mount /dev/sdb1 /mnt/oldsys # для монтирования корневого раздела старого винта
sudo mount /dev/sda2 /mnt/newsys # для монтирования корневого раздела нового винта
sudo mount /dev/sda3 /mnt/newhome # для монтирования раздела на новом винте, который будет использоваться под /home
sudo rsync -qaHEAXh --progress /mnt/oldsys/home/* /mnt/newhome
sudo rsync -qaHEAXh --progress --exclude 'home' /mnt/oldsys/* /mnt/newsys
proc / proc proc defaults 0 0
/ dev / sda1 swap swap defaults 0 0
/ dev / sda2 / ext4 errors = remount-ro 0 1
/ dev / sda3 / home ext4 defaults, owner, nodev 0 2
Otherwise, if you want to use the UUID, you can get it using the blkid utility: Now you need to transfer grub, since ubuntu 9.10 uses grub 2, the transfer occurs in a slightly different way than the old rude: Before installing the rude, I did the following steps (not required)
sudo blkid /dev/sda2
/dev/sda2: UUID="e681c419-5ba5-4b78-ac00-def757e65585" TYPE="ext4"
- Unmounted / mnt / oldsys:
sudo umount /mnt/oldsys
- Unmounted / mnt / newhome:
sudo umount /mnt/newhome
Next, use the mount command to remount the / dev and / proc directories in the / mnt / newsys / dev and / mnt / newsys / proc directories, respectively, using the --bind option - this is necessary so that in the chroot environment in the / directory dev there were device files / dev / sda *: We wrap in / mnt / newsys / Create device.map for grub As a result of this command, the file device.map will be created in / boot / grub / with the following contents (it will look different on different systems ) I have so:
sudo mount --bind /dev /mnt/newsys/dev
sudo mount --bind /proc /mnt/newsys/proc
sudo chroot /mnt/newsys /bin/bash
sudo grub-mkdevicemap
(hd0) / dev / sda
(hd1) / dev / sdb
We create a configuration file for grub
grub-mkconfig > /boot/grub/grub.cfg
If errors did not come out and rude said approximately the following
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-2.6.31-17-generic
Found initrd image: /boot/initrd.img-2.6.31-17-generic
Found linux image: /boot/vmlinuz-2.6. 31-16-generic
Found initrd image: /boot/initrd.img-2.6.31-16-generic
Found linux image: /boot/vmlinuz-2.6.31-15-generic
Found initrd image: /boot/initrd.img- 2.6.31-15-generic
Found linux image: /boot/vmlinuz-2.6.31-14-generic
Found initrd image: /boot/initrd.img-2.6.31-14-generic
Found memtest86 + image: / boot / memtest86 +. bin
done
Install grub. Since / dev / sda will be the boot disk on my system, I install the bootloader in mbr of this screw:
sudo grub-install /dev/sda
(here, instead of / dev / sda, you can put hd0 see the file /boot/grub/device.map).
The output of this command for my system is:
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install '.
(hd0) / dev / sda
(hd1) / dev / sdb
We leave from the circle
exit
We do umount for / dev, / proc and / mnt / newsys Reboot, if everything is done correctly, then the system should boot without problems. To everyone who read to the end, thank you for your attention. I will be glad to comments and comments. UPD: Thank you all for karma, transferred to Ubuntarium.
sudo umount /mnt/newsys/dev
sudo umount /mnt/newsys/proc
sudo umount /mnt/newsys/