Placing data on a separate disk partition
From what I've read I'll just need to edit the /etc/fstab file to get the system to mount the data partition in the appropriate subdirectory on the root file system at boot time?
Is this feasible? Does anyone do this? Is there a better approach?
4 Replies
0. Back up important information off the linode.
1. Create a new disk image via LPM.
2. Bring your system up to single-user mode.
3. Mount the new partition in a temporary location.
4. rsync -arv the data over to the new location.
5. Remove the data from the existing location
6. Configure fstab to mount the new partition in the correct location
7. Possibly shrink your system 'disk' via the LPM to recover the quota.
8. Reboot to regular usage.
If you don't have enough quota to hold the data twice during the move then you'll probably have to move it off your linode.
There is a slight chance you could work out getting additional quota for a few days while you do the change without paying for a full month, YMMV.
@vca:
Is this feasible? Does anyone do this? Is there a better approach?
I have the setup that you describe:
system partition (2GB, but that is more than necessary)
spare system partition (2GB)
data partition
This means if I want to make any major changes (like trying a new distro), I can set it up in the spare partition. Then, if it all goes pear-shaped, I can quickly go back to the original and trouble-shoot from there. You can also use chroot to run a terminal in the new system, from the old system.
jhmartin has described well how to do it.
My data doesn't need as much rigour as he/she describes - to transfer the data I just used:
cp -av <source> <destination></destination>
from a root login. So I didn't use single-user login, and didn't use rsync. But you need to decide what your data needs - the most important thing is that no changes get made to the data while you are copying it. (Though the -u option with cp can be useful in that case.)
Another approach that you might find easier (though this is maybe harder work for the servers), and you might feel safe doing without fully backing up first (though you should have a backup of anything important anyway):
You can duplicate entire virtual partitions from the linode dashboard now so, providing you had twice as much space as you need, you could do:
shut down linode
shrink image to smallest size (needs to be half or less of what you have available)
duplicate the image using the dashboard
start linode
mount duplicated image
delete system files (anything that is not 'data') from duplicated image
delete 'data' files from original image
if necessary, remount duplicated image in it's final resting place
shutdown and resize images from the dashboard
Personally, I like to mount the whole partition, then remount bits of it elsewhere, like this (note the last line from my /etc/fstab):
/dev/xvda / ext3 defaults 0 1
/dev/xvdb none swap auto,defaults 0 0
/dev/xvdc /mnt/data ext3 auto,defaults 0 0
/dev/xvdd /mnt/spare ext3 auto,defaults 0 0
/mnt/data/home /home none rw,bind 0 0
Then after some tests to see all was ok I was able to remove the original directory tree, freeing up space on the system partition and then shrink the system partition and increase the size of the data partition.
Only thing I didn't do was to set up a second system partition to load up a different operating system image for testing. I've left some free space to do this at a later time, but I'm confident that this should be pretty straight forward. It also looks like adding some more space to the data partition at a later time (maybe when the next "free upgrade" come along
Well done Linode guys!