Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Replacing/Upgrading a Data Disk ====== 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. If this is not the case, some of the commands below may need appropriate modifications for your environment.</note> ===== Supported Releases ===== Should work in all Ubuntu releases. Tested from 10.04 (Lucid Lynx) to 13.10 (Saucy Salamander) on Ubuntu 32/64-bit. ===== Required Packages ===== None, as the required tools should already be present. ===== Configuration ===== Firstly, shut the machine down and attach your new disk to the SATA/SAS/SCSI bus and give it some power. Once connected, restart the machine, log on and become root: <code>sudo -s</code> Create a list of the disks connected to the machine: <code>sudo lshw -C disk</code> The output will be similar to below: <code>*-disk description: ATA Disk product: IC25N040ATCS04-0 vendor: Hitachi physical id: 0 bus info: ide@0.0 logical name: /dev/sdb version: CA4OA71A serial: CSH405DCLSHK6B size: 37GB capacity: 37GB </code> Locate your new disk (by make/model) and make a note of its logical name. <note important>For the rest of this guide we'll use /dev/sdx but you should substitute your device name.</note> Now create a partition on the new disk using: <code>parted /dev/sdx</code> If your new disk is 2TB or below, complete the command as follows: <code> mklabel msdos mkpart pri 1 -1 quit </code> If your new disk is larger than 2TB, complete the command as follows: <code> mklabel gpt mkpart pri 1 -1 quit </code> Now format the new partition using: <code>mkfs -t ext4 /dev/sdx1</code> Mount the newly formatted parition at ''/mnt'' so that we can copy the data to it: <code>mount /dev/sdx1 /mnt</code> 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 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 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: <code>blkid</code> Locate the ''/dev/sdx1'' line in the output, similar to the following: <code>/dev/sdx1: UUID="24e13b29-9c40-4cab-96aa-31777017b031" TYPE="ext4"</code> Make a note (or better still, copy to the clipboard) the UUID of the new disk and then edit the fstab: <code>nano /etc/fstab</code> Locate the line that contains ''/srv'' and update the UUID entry in it, so that it looks similar to the following: <code>UUID=24e13b29-9c40-4cab-96aa-31777017b031 /srv ext4 defaults 0 2</code> Save the file and exit. You are now ready to shut the machine down, remove the failing/old disk and ensure the new one is securely mounted in its permanent position. When you restart the machine the new disk should automatically mount as ''/srv'' and contain all the data from the old one. ===== See Also ===== * [[tech:ubuntu_smart]] * [[sigma:how_to]] * [[sigma:contact]]