You need to move a busy MySQL data directory from the root disk to a new, faster volume. Plan it.
IntermediateScenarioStorage, disks and filesystems
Answer
Situation read → Short downtime is unavoidable for a consistent copy unless you replicate.
What I'd do →
- Pre-sync while running:
rsync -aHAX /var/lib/mysql/ /mnt/newvol/mysql/. - Stop MySQL, run a final
rsync -aHAX --delete(fast, only changes). - Mount the new volume at
/var/lib/mysqlvia fstab (better than changingdatadir). - Fix SELinux labels if enforcing:
restorecon -Rv /var/lib/mysql. - Start MySQL, check the error log and run a test query. Keep the old copy for a few days.
Why → Two-pass rsync keeps downtime to the size of the delta, and mounting at the original path avoids config and SELinux changes.
Interview tip → For zero downtime, mention building a replica on the new volume and failing over.
More on Storage, disks and filesystems
You get paged at 3 AM: the root filesystem on a production server is at 98% and climbing. Walk through your response.BeginnerA new 200 GB EBS volume is attached to an EC2 instance. How do you make it usable and persistent across reboots?BeginnerThe `/var` LVM logical volume is nearly full and there is free space in the volume group. How do you grow it online?BeginnerThe volume group has no free space. You've been given a new disk. How do you add it to grow `/var`?IntermediateA cloud VM's root disk was enlarged from 30 GB to 80 GB in the console, but `df` still shows 30 GB. What do you do?BeginnerA team wants a shared directory mounted on 10 app servers. How do you set up NFS?Beginner