[SOLVED] Moving /var from a mirror to another disk
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I looked around a lot before posting here and I really hope you will be able to give me some advice on how to achieve this... (important: please do not assume I know, because chances are I don't as I am relatively new to the Linux world).
2x8G USB2 mirrored (this is for the OS)
2x3T SATA disks mirrored (this is for my storage)
Personalities : [raid1]
md1 : active raid1 sda sdb
2930135360 blocks super 1.2 [2/2] [UU]
md0 : active raid1 sdd1 sdc1
7514048 blocks super 1.2 [2/2] [UU]
# / was on /dev/md0 during installation
UUID=1ff6b579-38f0-455c-a9c8-b486025adfd8 / ext4 discard,noatime,errors=remount-ro 0 1
/dev/sdc1 /media/usb0 auto rw,user,noauto 0 0
/dev/sdc2 /media/usb1 auto rw,user,noauto 0 0
/dev/sdd1 /media/usb2 auto rw,user,noauto 0 0
/dev/sde1 /media/usb3 auto rw,user,noauto 0 0
Since I boot from USBs, I would like to move the /var to another disk. I don't know how to do this properly since /var is used at all times. Any ideas on how to achieve this? Please let me know if you need more information.
I believe the following will work, note: the shutdown logs will be in the old directory, not the new.
1. initialize the new partition (or the whole disk if you want) with mkfs
2. mount the new partition in /mnt - for the purpose below, create a directory var in /mnt and mount it as /mnt/var. The contents will be empty.
3. cp --preserve=all /var /mnt/var
This will copy all current files and security labels that may be in use.
4. mv /var /var.old
This will preserve the existing directory (which will have open files)
5. mkdir /var
Make sure the new directory has the same permissions/labels as /var.old
6. Change/add the mount for the new filesystem (currently mounted on /mnt/var) to /etc/fstab to allow the next boot to use it.
IF everything works as you expect, you can then do "rm -rf /var.old", but do it ONLY after rebooting.
If something didn't work, you can still boot into single user mode (or from a rescue disk) and rename the /var.old back to /var (deleting the directory /var) and reboot again.
Sorry for the delay, I didn't have the time to test it earlier. I was looking for a plan on how to do this actually and your response provides me with one. That worked fine. Thank you very much! Much appreciated!