Reducing a Digital Ocean volume in size

 
Line 5: Line 5:
 
|categories=system administration,Digital Ocean,volumes
 
|categories=system administration,Digital Ocean,volumes
 
}}
 
}}
Reducing a Digital Ocean volume size:
+
For my own future reference:
  
# Create new volume
+
# Create new volume.
# Mount it: <code>sudo mount -o discard,defaults,noatime /dev/disk/by-id/scsi-0DO_Volume_data2 /mnt/data2</code>
+
# Mount it: <pre>sudo mount -o discard,defaults,noatime /dev/disk/by-id/scsi-0DO_Volume_data2 /mnt/data2</pre>
# Add entry to fstab: <code>/dev/disk/by-id/scsi-0DO_Volume_data2 /mnt/data2 ext4 defaults,nofail,discard 0 0</code>
+
# Stop Apache: <pre>sudo apache2ctl stop</pre>
# Copy everything from old to new with rsync -av /mnt/data/ /mnt/data2/ (note trailing slashes)
+
# Copy everything from old to new with rsync (note trailing slashes): <pre>rsync -av /mnt/data/ /mnt/data2/</pre>
Unmount the old volume: sudo umount /mnt/data
+
# Unmount the old volume: <pre>sudo umount /mnt/data</pre>
Edit fstab to remove the old volumn and change the new one's to /mnt/data
+
# Mount new to old place: <pre>sudo mount -o discard,defaults,noatime /dev/disk/by-id/scsi-0DO_Volume_data2 /mnt/data</pre>
Mount new to old place: sudo mount -o discard,defaults,noatime /dev/disk/by-id/scsi-0DO_Volume_data2 /mnt/data
+
# Restart Apache: <pre>sudo apache2ctl start</pre>
unmount: sudo umount /mnt/data2
+
# Edit the entry in fstab to use the new volume ID:<pre>/dev/disk/by-id/scsi-0DO_Volume_data2 /mnt/data2 ext4 defaults,nofail,discard 0 0</pre>
sudo rmdir data2/
+
# Remove the temporary mount point: <pre>sudo rmdir data2/</pre>
# Restart to make sure everything comes back up as it should (this isn't really a good way to do this, but I'm lazy and not many people use this server).
+
# Restart to make sure everything comes back up as it should (this isn't really a good way to do this, but I'm lazy and not many people use this server).<pre>sudo shutdown -r now</pre>
#* <pre>sudo shutdown -r now</pre>
 

Latest revision as of 00:42, 4 February 2020

Fremantle

For my own future reference:

  1. Create new volume.
  2. Mount it:
    sudo mount -o discard,defaults,noatime /dev/disk/by-id/scsi-0DO_Volume_data2 /mnt/data2
  3. Stop Apache:
    sudo apache2ctl stop
  4. Copy everything from old to new with rsync (note trailing slashes):
    rsync -av /mnt/data/ /mnt/data2/
  5. Unmount the old volume:
    sudo umount /mnt/data
  6. Mount new to old place:
    sudo mount -o discard,defaults,noatime /dev/disk/by-id/scsi-0DO_Volume_data2 /mnt/data
  7. Restart Apache:
    sudo apache2ctl start
  8. Edit the entry in fstab to use the new volume ID:
    /dev/disk/by-id/scsi-0DO_Volume_data2 /mnt/data2 ext4 defaults,nofail,discard 0 0
  9. Remove the temporary mount point:
    sudo rmdir data2/
  10. Restart to make sure everything comes back up as it should (this isn't really a good way to do this, but I'm lazy and not many people use this server).
    sudo shutdown -r now
Retrieved from ‘https://samwilson.id.au/index.php?title=Reducing_a_Digital_Ocean_volume_in_size&oldid=3056