Placing data on a separate disk partition

My Linode has be happily running for a few months now and my uses for it are increasing. I'm thinking it might be a good idea to move my data into a separate ext3 partition from the one occupied by the Linux disk image, so that if I need to reinstall or install a new disk image I can do so without having to re-upload my data. Perhaps I could also setup a third partition with a different disk image in it for testing, and have that system also access the same data 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

If you have enough disk quota available on your linode, you would want to:

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

Thanks for the info guys, I'll give this a try this weekend.

Regards,

Stephen

I successfully performed the data migration this morning. I was able to use the dash board's "image options" control to shrink my system partition, then create a new partition and add it into the system by editing the "configuration profile". Initially I missed the step of changing the configuration profile, and so couldn't figure out which was the new device that should be mounted. Once I had changed the configuration so that the new partition was assigned to a device and rebooted I was able to mount the partition, copy across the data, modify the /etc/fstab so that it would be mounted at boot and the key directory mapped to the right place.

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 :-) ) should be pretty easy to do.

Well done Linode guys!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct