📜 ⬆️ ⬇️

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 I have such a need.
And so we have:

The installed system on an 80 GB drive (second SATA channel - sdb). There is one system / deb / sdb1, swap on the system.
Need to do:

transfer the system to another 320 GB hard drive connected to the first SATA channel (sda), create and connect the swap paging section on the new hard drive; user catalogs should also be placed on a separate partition.
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 (screw receiver - sda)
Load from LiveCD
We start Gparted and create partitions, which we will later use for SWAP, / and home

Next: open the terminal and create subdirectories in the / mnt directory:
sudo mkdir /mnt/oldsys
sudo mkdir /mnt/newsys
sudo mkdir /mnt/newhome


Mount partitions on created directories
sudo mount /dev/sdb1 /mnt/oldsys #
sudo mount /dev/sda2 /mnt/newsys #
sudo mount /dev/sda3 /mnt/newhome # , /home


We copy the data from the / mnt / oldsys / home directory into / mnt / newhome, the same actions need to be performed for / mnt / oldsys, only now the directory / mnt / oldsys / home will need to be excluded from the copy process, since a copy of this directory was made before. For this, I used the rsync utility:
sudo rsync -qaHEAXh --progress /mnt/oldsys/home/* /mnt/newhome
sudo rsync -qaHEAXh --progress --exclude 'home' /mnt/oldsys/* /mnt/newsys


The next number of our program will be the edit of the file / etc / fstab: by default in fstab instead of file system names (for example: / dev / sdb1) their UUIDs are used, if you do not plan to connect the drive to different SATA channels or transfer it to another computer, then You can explicitly set the file system name, in our case it will look like this:

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 a UUID, you can get it using the blkid utility:
sudo blkid /dev/sda2
/dev/sda2: UUID="e681c419-5ba5-4b78-ac00-def757e65585" TYPE="ext4"
sudo blkid /dev/sda2
/dev/sda2: UUID="e681c419-5ba5-4b78-ac00-def757e65585" TYPE="ext4"
sudo blkid /dev/sda2
/dev/sda2: UUID="e681c419-5ba5-4b78-ac00-def757e65585" TYPE="ext4"

')
Now you need to transfer grub, since grub 2 is used in ubuntu 9.10 in a slightly different way than the old rough:
Before installing the rough, I took the following steps (optional)



Next, using the mount command, you should re-mount the / dev and / proc directories into the / mnt / newsys / dev and / mnt / newsys / proc directories, respectively, using the --bind option - this is necessary for the chroot environment in the / directory. dev had device files / dev / sda *:
sudo mount --bind /dev /mnt/newsys/dev
sudo mount --bind /proc /mnt/newsys/proc

We twist in / mnt / newsys /
sudo chroot /mnt/newsys /bin/bash
Create device.map for grub
sudo grub-mkdevicemap
As a result of executing this command, the device.map file will be created in / boot / grub / with the following content (it will look different on different systems) with me like this:
(hd0) / dev / sda
(hd1) / dev / sdb


Create a configuration file for grub
grub-mkconfig > /boot/grub/grub.cfg
If the errors did not come out and rudely said something like 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 appear on my system boot disk, then I install the bootloader in the 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

Leaving the Chruta
exit
Make umount for / dev, / proc and / mnt / newsys
sudo umount /mnt/newsys/dev
sudo umount /mnt/newsys/proc
sudo umount /mnt/newsys/

Reboot, if everything is done correctly, the system should boot without problems.

All read to the end, thank you for your attention. I would welcome comments and comments.

UPD: Thank you all for your karma, moved to Ubuntarium.

Source: https://habr.com/ru/post/82509/


All Articles