I just changed the hardware system because the hard disk space is too small, and want to use the new hard disk as the system? No problem. It is very easy to clone Ubuntu to other hard disks. In fact, UBUNTU provides a tool for cloning the entire hard disk (including windows partitions, if any. Ubuntu is very good at doing this.
At the beginning of cloning, three things need to be done:
1. Check how Ubuntu arranges disk space
2. Install the ddrescure software for disk cloning
3. After ddrescure is installed, use gparted to adjust disk partitions.
If the tires cannot be replaced while the vehicle is driving, it is best not to clone the disk while it is in use, so you must use your Ubuntu to install CD. Start from Ubuntu installation CD and select "Try Ubuntu ".
Note that the following operations are performed in the live mode of ubuntu CD. Except for the final test, you cannot enter the Ubuntu on the hard disk.
Prepare for cloning
First, back up all valuable private data to CD/DVD-R/RW, U disk or other hard disks. This is to avoid data loss caused by misoperations. Second, check for disk errors. If any errors exist, fix them. Third, remove all mobile storage devices, such as USB flash drives, card readers, and MP3 players, to avoid confusion during partition adjustment.
Open the terminal and enter the following command to list the partitions of the hard disk:
$ Sudo fdisk-l
The following is the display of my test system:
Disk/dev/SDA: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 Cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Disk identifier: 0x1c381c37
Device boot start end blocks ID system
/Dev/sda1*1 4742 38090083 + 7 HPFs/NTFS
/Dev/sda2 4743 9964 41945715 5 extended
/Dev/sda5 4743 9744 40178533 + 83 Linux
/Dev/sda6 9745 9964 1767118 + 82 Linux swap/Solaris
Disk/dev/SDB: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 Cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Disk identifier: 0xb94838a4
Disk/dev/SDB doesn' t contain a valid Partition Table
Two hard disks are displayed in the result: I have highlighted them in red. The above results also show the detailed technical information of the hard disk.
Obviously, "/dev/SDB" is a new partition because it has no partition (note "Disk/dev/SDB doesn't contain a valid Partition Table "). "/Dev/SDA" is my old Ubuntu disk. The display may be slightly different, depending on your hard disk.
Now you have found your new disk. My name is "/dev/SDB". Enter the following command to start the cfdisk program and create a disk partition table on the new hard disk.
$ Sudo cfdisk-z/dev/SDB
Enter "Shift + W" (uppercase "W") in cfdisk, and a prompt is displayed. Select "yes" and enter "Q" to exit. Ignore the warnings.
Clone Hard Disk
With this information, we can install the "ddrescue" software to clone the hard disk. Ddrescure is not the default system tool, so you need to install it. In our Ubuntu livecd mode, we can install software from the "software source" on the network. First, make sure that the "Universe" software source is available. Click "System"-"management"-"software source", select "Open Source Software for community maintenance", click "close", and agree to refresh the source.
Run the following command to install ddrescue:
$ Sudo apt-Get install gddrescue
After the installation is complete, enter the following command:
$ Sudo ddrescure-V/dev/SDA/dev/SDB
The "-V" parameter indicates the display progress. "/dev/SDA" indicates the original hard disk and "/dev/SDB" indicates the new hard disk. Note: If the disk order is incorrect, the original hard disk data may be completely cleared.
The cloning process may take one hour or more based on the hard disk size. Close the computer, remove the old hard disk, and start the test with the new hard disk. Note: The "Windows Genuine Advantage" prompt may appear for Windows XP/Vista on the hard disk due to the new hard disk. Please reactivate it. Ubuntu does not have to worry. Everything works well.
After completing this step, we will proceed to the next step: Expand the disk partition to make full use of the space of the new hard disk.
Extended partition
Before performing partition expansion, check the Ubuntu file system. Use the Ubuntu installation CD to enter the livecd mode, open the terminal, and enter:
$ Sudo fsdk. ext3-F/dev/sda5
Close the terminal. Click "System"-"manage"-"partition manager ".
The following work depends on your own situation. To increase the partition size of ubuntu, follow these three steps:
1. In the "partition list", right-click the "Linux-Swap" partition and choose "swapoff ". This prevents access to swap partitions in the livecd mode of ubuntu, so that swap partitions can be moved.
2. first, you must expand the partition where Ubuntu is located. Right-click "extended" and choose "resize/move". In the displayed dialog box, set "Free Space following (MIB) "Enter 0 in the input box, and type" tab ". Then the partition will be extended to the entire partition space and click" resize/move. Note: you do not need to click the "Apply" button now. We will finish it at the last time.
3. Same as above, the swap partition space is also extended to the entire partition.
4. Return to the gparted exit, right-click the "ext3" item, and select "resize/move". Adjust the settings in the same step.
5. Click the "Apply" button on the gparted toolbar and wait for the partition to move and change the size.
6. Close the program after gparted is completed. Open the terminal and enter the following command to re-check whether the hard disk has an error:
$ Sudo fsck. ext3-F/dev/sda5. If an error occurs, the system prompts whether to fix it. Generally, select "yes ".
After the check is complete, you can restart the computer. Now we can see that the Ubuntu partition has become larger.
If you want to discard the old hard disk or send it to someone else, you must ensure that the data is completely destroyed. Please check "safe data deletion ". but do not do this until you make sure your new system is 100% running.