Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tech:ubuntu_replace_disk [16-Nov-2013 2:14pm] – created iantech:ubuntu_replace_disk [18-Nov-2013 12:11pm] (current) – Swapped fdisk to parted for disks greater than 2TB ian
Line 3: Line 3:
 In the unlucky event that one of your data disks starts to show [[wp>S.M.A.R.T.]] errors warning of its decline, or you are just running out of storage space, this article describes how to provision a new disk and migrate the data to replace the old one. In the unlucky event that one of your data disks starts to show [[wp>S.M.A.R.T.]] errors warning of its decline, or you are just running out of storage space, this article describes how to provision a new disk and migrate the data to replace the old one.
  
-<note tip>This guide assumes your old disk has a single partition, is formatted with the EXT4 file-system and is mounted at /srv during boot.</note>+<note tip>This guide assumes your old disk has a single partition, is formatted with the EXT4 file-system and is mounted at /srv during boot.  If this is not the case, some of the commands below may need appropriate modifications for your environment.</note>
  
 ===== Supported Releases ===== ===== Supported Releases =====
Line 44: Line 44:
 Now create a partition on the new disk using: Now create a partition on the new disk using:
  
-<code>fdisk /dev/sdx</code>+<code>parted /dev/sdx</code>
  
-The fdisk menu will appear.  Use the commands in the following order to complete the task:+If your new disk is 2TB or below, complete the command as follows:
  
-  - "n" to create a new parition +<code> 
-  - "p" for a primary partition +mklabel msdos 
-  "1" for the first partition +mkpart pri 1 -1 
-  "w" to write the partition table back to the disk and exit+quit 
 +</code> 
 + 
 +If your new disk is larger than 2TB, complete the command as follows: 
 + 
 +<code> 
 +mklabel gpt 
 +mkpart pri 1 -
 +quit 
 +</code>
  
 Now format the new partition using: Now format the new partition using:
Line 63: Line 72:
 Copy the data from the old disk to the new one using (omit the ''v'' from the options if you don't wish to see detailed output as the copy proceeds): Copy the data from the old disk to the new one using (omit the ''v'' from the options if you don't wish to see detailed output as the copy proceeds):
  
-<code>rsync -aAXv /srv /mnt</code>+<code>rsync -aAXv /srv/mnt 2> sync_errors.txt</code> 
 + 
 +Review the ''sync_errors.txt'' file (if any) created during the copy to check for any files that may not have copied completely.  This is easiest with: 
 + 
 +<code>less sync_errors.txt</code>
  
-<note tip>If you suspect any files may have changed during the copy process it is possible to simply re-run the above command to update them.  However, it is best to stop any processes that modify files on your data disk during the data transfer.</note>+<note tip>If you suspect any files may have changed during the copy process it is possible to simply re-run the rsync command to update them.  However, it is best to stop any processes that modify files on your data disk during the data transfer.</note>
  
 Now we must update ''/etc/fstab'' to mount the new disk to ''/srv'' during boot.  Ubuntu now uses UUIDs to mount disks during boot.  To locate these, run: Now we must update ''/etc/fstab'' to mount the new disk to ''/srv'' during boot.  Ubuntu now uses UUIDs to mount disks during boot.  To locate these, run: