Best practice/plan for moving /data to another partition (Linode)

Events happening in the community are now at Drupal community events on www.drupal.org.
jim kirkpatrick's picture

Hello all,

I want to split up my BOA install so that /data lives in another partition/disk within my Linode.

I see many approaches...:

... but I just wanted to double check there's nothing I've forgotten. My rough plan, minus commands, is...

  1. Create a /data.new directory to hold the old /data folder
  2. Add a new Linode partition (~10Gb)
  3. Mount it at /data.new, update fstab
  4. Stop NGINX and MYSQL
  5. Copy everything from /disk to /disk.new (either with 'cp -af' or tar [some magic])
  6. Rename /disk to disk.old
  7. unmount /disk.new and rename/re-mount it at /disk, update fstab
  8. Restart NGINX and MYSQL, pray, test
  9. Attempt an out-of-hours restart to double-check the auto-mount works

So what do you think? This is a live webserver running a BOA setup so a little downtime is ok, but I don't want to break it!

I'll be importing more sites and expanding its capacity soon, hence the need to want to give the sites space to grow without losing the ability to just backup the whole image if needs be -- or send web data to another Linode and leave this one running email and databases.

Is approach a good one? Your ideas, commands, scripts or other tips warmly welcomed.

Thanks, Jim

Comments

Pantheon Valhalla filesystem

Jackinloadup's picture

It would be great if something was able to be build similar to Pantheon's Valhalla file system.

https://getpantheon.com/news/inside-pantheon-valhalla-filesystem

Seems like an extremely valuable and useful piece of software for Drupal.

First add your new mount

memtkmcc's picture

First add your new mount point like /var/whatever to the open_basedir list in the /opt/etc/php.ini file, run service php-fpm reload and then touch /opt/etc/custom.php.ini to avoid overwriting in on Barracuda upgrade. Next you could simply mount new disk/partition at /var/whatever, then mv /data /var/whatever/. When it is complete, type ln -s /var/whatever/data /data. The only downtime will be when mv command will delete /data directory, not while it is running cp -a for you behind the scenes. There is no need to restart Nginx or MySQL. It is tested and working, simple how-to.

Great, thank you

jim kirkpatrick's picture

I'll give this a go soon, thank you very much for the tips.

Reporting back -- a tip and a minor pitfal

jim kirkpatrick's picture

I did it last night with some variations and minor issues... In the interests of expanding this how-to I did the following:

  1. I mounted the disk in /mnt/disk instead of /var/whatever because /mnt was already set in the 'open_basedir' variable in /opt/etc/php.ini that Barracuda set up... This way I can get updates to php.ini during Barracuda upgrades seamlessly with no override faff.
  2. To do this I ran a mkdir /mnt/disk followed by a mount -t ext3 /dev/xvdd /mnt/data to mount the disk device into the new folder.
  3. I added a line in /etc/fstab as follows
    /dev/xvdd       /mnt/data              ext3     noatime,errors=remount-ro 0       1

    so the mount is recreated after reboots.

  4. I used the Linode manager to back up the whole disk.
  5. To move the files I ran mv /data/* /mnt/data/ which unfortunately deleted each subdir right after it was copied, so there was a little more downtime than I'd hoped. Had a moment of paranoia and added the *, which caused this minor issue.
  6. I should have run both commands consecutively was mv /data /mnt/data ; ln -s /mnt/data /data so there was no gap between the move and re-linking the directory.

So thanks Grace, this works well. My use of /mnt instead means I can get php.ini enhancements with each Barracuda updates, which keeps things simple and is a tip worth passing on to others I reckon.

Next I'd like to move the regularly changing/bloating stuff (like NginX's speed cache, other bits in /var, /tmp etc.) to another disk and then I can back up only what's needed. I'll use roughly the same processes again.

BOA

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week