1

I am running CentOS 7.

I have /var on a separate hard drive, and smartctl shows that it has some read error. Hence, I would like to move /var to another hard drive.

For the new hard drive, I used gparted to create two partitions (1MB alignment).

Then, I mounted one partition to /mnt/var_new and then rsync -avHPSAX --filter='-x security.selinux' /var/ /mnt/var_new/. And as expected, one file was failed to sync (that just confirmed why smartctl got read errors):

WARNING: cache/yum/x86_64/7/centos-sclo-sclo/gen/primary_db.sqlite failed verification -- update discarded (will try again).
cache/yum/x86_64/7/centos-sclo-sclo/gen/primary_db.sqlite
      1,607,680 100%    2.81MB/s    0:00:00 (xfr#3, ir-chk=1309/1607)
rsync: read errors mapping "/var/cache/yum/x86_64/7/centos-sclo-sclo/gen/primary_db.sqlite": Input/output error (5)
ERROR: cache/yum/x86_64/7/centos-sclo-sclo/gen/primary_db.sqlite failed verification -- update discarded.

And no other file was failed to sync (I re-ran rsync again to confirm).

Then, I correctly removed the entry that mounted the old /var and added a new entry to mount the new /var.

Then, I rebooted and then it failed to start with tons of failures (just plain black screen).

Then, I booted into emergency mode, and the new /var did mount correctly that I could see the related files there.

I did read some articles that /var needed to be in 755 mode and /var/tmp needed to have the sticky bit set. I had both.

What did I do wrong?

Thanks!

HCSF
  • 213
  • 2
  • 9

1 Answers1

2

In recovery mode:

  1. chroot into your system
  2. mount /var if it's not mounted
  3. restorecon -rv /var and then try booting normally again.

Make sure your /var entry in /etc/fstab is correct.

Artem S. Tashkinov
  • 26,392
  • 4
  • 33
  • 64