LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices


Reply
  Search this Thread
Old 09-15-2013, 04:05 PM   #1
vasis
LQ Newbie
 
Registered: Jul 2013
Posts: 19

Rep: Reputation: Disabled
Moving /var from a mirror to another disk


Hello All,

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).

OS:
Debian wheezy

My setup:
2x8G USB2 mirrored (this is for the OS)
2x3T SATA disks mirrored (this is for my storage)

/proc/mdstat:
Personalities : [raid1]
md1 : active raid1 sda[0] sdb[1]
2930135360 blocks super 1.2 [2/2] [UU]

md0 : active raid1 sdd1[0] sdc1[1]
7514048 blocks super 1.2 [2/2] [UU]

/etc/fstab:
# / 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

df -h:
Filesystem Size Used Avail Use% Mounted on
rootfs 7.1G 845M 5.9G 13% /
udev 10M 0 10M 0% /dev
tmpfs 387M 260K 386M 1% /run
/dev/disk/by-uuid/1ff6b579-38f0-455c-a9c8-b486025adfd8 7.1G 845M 5.9G 13% /
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 773M 0 773M 0% /run/shm
/dev/md1 2.7T 2.4G 2.6T 1% /media/md1_storage

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.

Thanks in advance!
 
Old 09-15-2013, 05:20 PM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,711

Rep: Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279
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.
7. reboot.

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.
 
1 members found this post helpful.
Old 09-19-2013, 02:20 PM   #3
vasis
LQ Newbie
 
Registered: Jul 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Thanks for the advice jpollard,

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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving var to hard disk on embedded Linux.... shylock_1 Red Hat 8 03-04-2010 06:18 AM
Moving /var... rnturn SUSE / openSUSE 4 11-21-2006 02:44 PM
Moving /var Maverick1182 Linux - Newbie 6 07-31-2006 07:37 PM
Moving /var/adm and /var/lib - why does it hurt? J_Szucs Linux - General 1 09-15-2004 07:46 PM
moving /var to a new hdd freelinuxcpp Linux - Software 4 11-02-2003 03:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration