Using disk upgrades

From PrgmrWiki

Backups

Before making any changes to your disk, we strongly recommend backing up any data you do not want to lose. Subject to availability, you may contact support to request either a disk snapshot, which may be taken while your server is running, or a full backup, which requires turning off your server. Both of these are on-site and for now are intended to only be available until you've started successfully using your additional disk space. Also if there's enough disk space, we could alternately make you an entirely new block device and let you copy over the files if it's too complicated to modify the existing disk (possibly this is the case if you're running NetBSD.)

Methods

There are two typical ways to use the additional disk space. One is to expand one of the partitions, the other is to add another partition. For both, you will probably need to boot into the rescue image.

Linux

Boot into the Linux-based live rescue image from option 6 of the Management console.

Log in as root.

Run

sfdisk -d /dev/xvda

You will get output like

# partition table of /dev/xvda
unit: sectors

/dev/xvda1 : start=     8192, size= 25157632, Id=83
/dev/xvda2 : start=        0, size=        0, Id= 0
/dev/xvda3 : start=        0, size=        0, Id= 0
/dev/xvda4 : start=        0, size=        0, Id= 0

Take this output and copy it somewhere outside of your server. Should you need to undo any changes to your partition table, it can be used to restore your original partition table by using it as input to 'sfdisk /dev/xvda'.

Expanding partition

Assuming you have the default of a single partition, run

parted /dev/xvda resizepart 1 100%

Reboot into your main file system instead of the rescue image. For an ext-based file system (the default) run

resize2fs /dev/xvda1

Adding partition

Use either 'fdisk /dev/xvda' or 'cfdisk /dev/xvda' to add a new partition. "cfdisk" has a graphical interface and is probably easiest to use. After adding the partition, format it as desired. This is a reasonable way to format the correct partition at the command line:

partprobe /dev/xvda
DEV=/dev/xvda2 #replace with 3 or 4 if needed
#check if this is blank partition
file -s $DEV #this should be found and not contain anything other than data
dd if=$DEV bs=512 count=1 | hexdump #blank will have output like
#1+0 records in
#1+0 records out
#512 bytes (512 B) copied, 0.000491492 s, 1.0 MB/s
#0000000 0000 0000 0000 0000 0000 0000 0000 0000
#*
#0000200
mkfs -t ext3 $DEV

Decide where to mount the new filesystem. If you need to copy over data, you will need to mount both at the same time. For example

mkdir /mnt/root
mkdir /mnt/new
mount /dev/xvda1 /mnt/root
mount /dev/xvda2 /mnt/new
tar cf - -C /mnt/root/new/mount/point . | tar xvf - -C /mnt/new

If you are copying data, when you are satisfied the data has been copied correctly, you can remove the old copies of the files from /mnt/root/new/mount/point. You will need to do this before rebooting as otherwise the new partition will be mounted over the old files and there will be no way to remove them.

If you copied data and are running with selinux on (the default for centos and fedora,) you will probably need to relabel after boot. Run

touch /mnt/root/.autorelabel 

Next you need to add this new mount point to /etc/fstab. Use your favorite text editor to edit /mnt/root/etc/fstab (possibly making a backup first) to add something like

/dev/xvda2 /new/mount/point  ext3    defaults,errors=remount-ro,barrier=0 1 1

unmount devices and reboot

umount /mnt/root
umount /mnt/new #if needed
reboot

If there is an issue after reboot, you may have an error in /etc/fstab or you may have chosen a file system that is not compatible with your current kernel. If necessary, you can reformat the new partition while booted from your main file system and also if necessary, boot back into the rescue image to copy files over while they are not in use.

NetBSD

This is WIP. You can use the netbsd installer as a rescue image, see Booting the NetBSD installer. Please refer to https://www.netbsd.org/docs/guide/en/chap-misc.html#chap-misc-adding-new-disk. The block device is 'xbd0d'.