2

The purpose here is about adding the 'noatime' property in /etc/fstab. We're running CentOS5.

On both servers A and B, we called a maintenance window with our users and stopped MySQL and Apache services.

On Server A, my client properly installed /var/lib/mysql and /home into separate partitions when I checked /etc/fstab. I was able to set the noatime property and remount the volumes, and when I checked with "mount -l" they showed the noatime property. Indeed, the server performance was much snappier when we fired up MySQL and Apache and told the users to get back on.

On Server B, however, my client just put everything on /. Is there an easy way at command line to break up /home and /var/lib/mysql from / so that we can apply noatime?

I'm just wanting to avoid having to do a complete server OS reinstall and then restoring cPanel accounts again.

ServerChecker
  • 1,498
  • 2
  • 14
  • 32

3 Answers3

4

Well, first you need to create a partition to hold /home.
(This is the hard part and is left as an exercise for the reader -- It could be as simple as just carving off a chunk of unallocated disk space (not likely), moderately difficult via LVM & filesystem resizing, or as complex/painful as "You're screwed. Make a backup and reinstall with a proper partition table.")

Then you need to get everyone to log off so you can move the data from your old /home to the new partition.
(If it's your workstation just go single-user and move everything over to the new partition. If you had to reinstall based on the above you'll be restoring from the backup.).

Then you need to update /etc/fstab to reflect the new partition & mount point
(If you were reinstalling this is done for you. If not man fstab has everything you could ever want to know about editing /etc/fstab :-) -- Reboot and you should be done :)

voretaq7
  • 79,345
  • 17
  • 128
  • 213
  • You're faster than me -- I was writing pretty much the same answer. I will add, though, that after you unmount the new partitions from their temporary mount points, you can simply run `mount -a` to mount them to their proper places -- a full reboot isn't necessary (although doesn't hurt). – Kromey May 24 '11 at 21:27
  • @kromey true - `mount -a` & going back to multi-user mode is also fine. The big point is "Don't manually mount it without testing your new fstab, lest you screw up and render the machine unusable" – voretaq7 May 24 '11 at 21:40
  • What if I could resize / back to only used space + 2GB, then take the unallocated space and map it to /home2 and /var/lib/mysql2, and then do the switcheroo to remount them as /home and /var/lib/mysql? Is that possible? – ServerChecker May 25 '11 at 01:35
  • Ah, looks like I follow the instructions at the bottom of this web page: http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-disk-storage.html However, it doesn't look easy and can come with its risks. – ServerChecker May 25 '11 at 01:39
3

Is there any reason you can't apply noatime to the whole filesystem? I run several systems like that without issues.

mount -o remount,noatime /

Modify /etc/fstab adding noatime to make it stick.

If you can't do that you just have to partition some extra space and copy the files over. Edit: Follow @voretaq7's post for this, which explains the procedure more thoroughly than I did.

Eduardo Ivanec
  • 14,531
  • 1
  • 35
  • 42
2

You can modify /etc/fstab to reflect the noatime parameter on the / filesystem. Edit /etc/fstab and make the entry for / look something like:

LABEL=/                 /                       ext3    noatime         1 1

This would need to be followed by a reboot.

Granted, there are other practical reasons to split the partitions apart like on Server A, but this will work for the short-term.

See: Turning off atime on a filesystem

ewwhite
  • 194,921
  • 91
  • 434
  • 799
  • Not a bad idea provided you're willing to lose `atime` on `/` (possibly the whole system from what was described above). Potentially much less painful than repartitioning too. – voretaq7 May 24 '11 at 21:26
  • Uh, I would think there's a huge risk in implementing noatime on the entire filesystem. Better to do it only on /var/lib/mysql and /home since we know it doesn't affect those from a programming standpoint. The /home only stores WordPress sites for the most part. – ServerChecker May 25 '11 at 01:28
  • Nope. No risk to running without atime. There's more risk involved in trying to separate partitions in your case. – ewwhite May 25 '11 at 01:53
  • @ewwhite -- got any proof that there's no risk of doing noatime on the entire root (/) partition of a CentOS5 Linux server used for LAMP hosting with cPanel? I mean, there are no APIs in any apps you know of that rely on the atime parameter? – ServerChecker May 25 '11 at 06:52
  • 1
    http://serverfault.com/questions/199697/turning-off-atime-on-a-filesystem – ewwhite May 25 '11 at 07:50
  • @ewwhite -- we just applied noatime to / on two of our lesser used servers since we had a fallback plan, and so far no errors or issues. Note we stopped LAMP services while we did this and remounted /. – ServerChecker May 25 '11 at 08:03
  • 1
    I have a lot of different servers all running with noatime on all partitions. No problems with it. – rvs May 25 '11 at 08:13
  • I'm curious, why is a reboot recessary? Wouldn't `mount -o remount /` do the job? – Ztyx Sep 27 '12 at 12:07