Upgrade the hard drive of Linux

Source: Internet
Author: User
Upgrade the hard disk of the Linux system-general Linux technology-Linux technology and application information. The following is a detailed description. There are two ways to add a hard disk for Linux: one is to add a hard disk to store data, and the other is to replace the original system with a new hard disk, that is, replacing the original system hard disk. This article will explain separately.
  
Add new data disks for Linux


Because Linux uses different methods to access the hard disk and DOS, the installation directory method is used. Therefore, adding a hard disk is different from the method usually used in DOS/Windows, which is divided into five steps.

1. Physical installation: Turn off the power supply, patch the hard disk, and install the new hard disk. This step is very simple. After the boot, the BIOS is able to recognize the dual hard disk, indicating that the operation was successful. The device names of the hard disk vary depending on the jumper method (as shown in the following table, the IDE hard disk is used as an example ):

No. Cable and jumper position device name
1 ide0 master disk/dev/had
2 ide0 slave Disk/dev/hdb
3 ide1 master disk/dev/hdc
4 ide1 slave Disk/dev/hdd


2. Partition the hard disk: as it is used as a data disk, you can divide it into one partition. Log on to the system as a root user, and use fdisk/dev/hdb (/dev/hdb as an example below) to enter the fdisk operation interface. Common commands for fdisk include: delete partition: d; add partition: n; Save and exit: w; activate partition: a; display partition: p; change partition type: t; show Help information: m.

3. Install the file system: Because Linux uses the ext2 file system, the ext2 file system needs to be installed on the new hard disk. Run the following command: mkfs. ext2/dev/hdb.

4. Create an installation point: Create an installation point in the root directory. In the future, the new data disk will be installed in this directory (take the data directory as an example ):

Mkdir/data

Mount-t ext2/dev/hdb1/data

5. Modify the/etc/fstab file to automatically install the file system at startup.

After manual installation, you can use the new hard disk (that is, the/data subdirectory). Enter the command df to view information about all the installed file systems. However, we also need to modify/etc/fstab so that the new hard disk is automatically installed every time the computer restarts. Use vi to open the file and modify it. The first column of the/etc/fstab file is the device location, and the second column is the installation point. Just copy the other columns.

Now you can use the new hard disk.


Upgrade the original system disk with a new hard disk


When upgrading the original system disk with a new hard disk, the main problem is how to copy data. In addition, the swap partition settings must be taken into account in hard disk partitioning.

1. Shut down and install the hard disk.

2. Partition the hard disk. When partitioning, refer to the original partition, which must not be smaller than the original partition settings. Note that all partitions created by fdisk are Linux native. To change to the Linux swap format, enter the command t and the Linux swap number 82.

3. Create an installation point for the new hard disk, such as/newdisk.

4. Install the new hard disk to the newly created Installation Point, for example:

Mount-t ext2/dev/hdb2/newdisk

5. create/tmp and/proc sub-directories on the new hard disk, and change the/tmp attribute to 777. The command is mkdir/newdisk/tmp; mkdir/newdisk/proc; chmod 777/newdisk/tmp.

6. Enter the single-user mode and copy the original data to the new hard disk.

· Enter single-user mode:/sbin/telinit 1

· Copy sub-directories: cp-a/var/bin/usr/sbin/boot/newdisk

· Copy the files in the root directory: cp-dp /*/.*

/Newdisk

If the sub-directories on the computer are inconsistent with those listed above, change the sub-directories as per your needs. Note that the installation points of the new hard disk are listed at the end.

7. Check whether/newdisk/etc/fstab is suitable. Note that although the new hard disk is the second hard disk and the device name is/dev/hdb, it will become the first hard disk after upgrade, therefore, the locations listed in/newdisk/etc/fstab should be in the first hard disk.

8. Create a boot disk, remove the old hard disk, switch the new hard disk to the master disk, and restart the computer. The command for creating a boot disk is makebootdisk.

9. After the computer restarts, run fdisk to set the hard disk partition to movable. Configure lilo to guide the system later. Generally, if it is the same as the original system partition, you only need to enter lilo and press Enter. Otherwise, you need to modify the/etc/lilo. conf file.

10. Remove the boot floppy disk and restart the disk to check whether the disk can be started. If the disk cannot be started, use a floppy disk to check the cause. Possible causes: the partition is not activated, and the lilo configuration is incorrect. If an error occurs when installing the file system during startup, check/etc/fstab.

So far, Linux on the new hard disk should be able to run normally.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.