Operating System - HP-UX
1824987 Members
3106 Online
109678 Solutions
New Discussion юеВ

Re: Moving a filesystem to an seperate LV.

 
Mitchell Gaddy
Occasional Contributor

Moving a filesystem to an seperate LV.

I wanted to know the proper way to move data from an filesystem on /var to its on seperate LV. I guess I'm looking for the proper syntax for the tar or dd command.
10 REPLIES 10
James R. Ferguson
Acclaimed Contributor

Re: Moving a filesystem to an seperate LV.

Hi Mitchell:

You could use 'cpio' or 'tar' easily:

# cd srcdir && find . -depth -print | cpio -pudlmv dstdir

# cd srcdir && tar cf - . | ( cd dstdir && tar xpf - )

Regards!

...JRF...

Mark Nieuwboer
Esteemed Contributor

Re: Moving a filesystem to an seperate LV.

Hi Mitchell,

Why not use cp.

grtz. Mark
Robert-Jan Goossens
Honored Contributor

Re: Moving a filesystem to an seperate LV.

Hi Mitchell,

Create a new logical volume and mount it on mnt

# cd /var/xxx
# find . | cpio -pcmudv /mnt
# rm -r /var/xxx
# mkdir /var/xxx
# umount /mnt
mount the new filesystem on the /var/xxx mount point and add this to the /etc/fstab.

You will have to be sure that there are no open files inside this /var/xxx directory.

Hope this helps,
Robert-Jan
Sivakumar TS
Honored Contributor

Re: Moving a filesystem to an seperate LV.


Dear Mitchell,

1. If the other filesystem (destination) is already UP then you can use "cp" itself.

1a. mount the new f/s in a temp_mountpint

1b. use #cp -R -p

( The -p option preserves the permissions

1c. umount both existing&temp_mnt and mount the new f/s in the reqd mountpoint or make necessary changes in /etc/fstab and reboot the server.

Otherwise

2. use #tar -cvf /dev/rmt/0m /

and use #tar -xvf to restore back in the new lv.

With Regards,

Siva.
Nothing is Impossible !
Chan 007
Honored Contributor

Re: Moving a filesystem to an seperate LV.

Mitchell,

Use CP or CPIO for doing that.

Also note, /var has few mounted file systems like /var/adm/crash etc, so if you do a find use -nodepth option.

Finally note that /var is required by system, so ensure that it is also mirrored to resolve a Single point failure.

Chan
Alzhy
Honored Contributor

Re: Moving a filesystem to an seperate LV.

Likely you're running 11.0 and above, so - the cleanest would be:

vxdump 0f - /var|(cd /destfs;vxrestore rf -)

Others:

CPIO:

cd /var;find ./ -depth -print|cpio -pdvmu /destdir

DD: Fastest (assuming destination LV is sized exactly as source - do prefrably in single user mode):

dd if=/dev/vg00/rlvolX bs=4096 of=/dev/vgXX/rlvolX

(where rlvolX is the raw LVOL name of your /var if you use regular LV names, rvar if using named LVOLS. Destivation LVOL should not be mounted. Also, fsck the destination LVOL after the dd is done.)

HTH.

Hakuna Matata.
Lolupee
Regular Advisor

Re: Moving a filesystem to an seperate LV.

Mitchell,

/var is a system area and why do you want to move data to another file system instead of extending the file system online.

If you must, you may have to be on single user level for some directory. can we know the specific directory you plan to move.
Ajitkumar Rane
Trusted Contributor

Re: Moving a filesystem to an seperate LV.

Mitchell,


Use tar in a pipeline to copy the entire file system hierarchy under fromdir to todir:

cd fromdir ; tar cf - . | ( cd todir ; tar xf - )

This works fine, from my personel experience.


Rgds,

Ajit
Amidsts difficulties lie opportunities
A. Clay Stephenson
Acclaimed Contributor

Re: Moving a filesystem to an seperate LV.

The cp command is an extremely poor choice for this. The data will be moved w/o problem but the metadata (those little things like file mode, owner, group, Xtime) will not be fully preserved even with cp -p. Use tar, cpio, or fbackup to preserve the metadata.

Moreover, generally the entire /var filesystem is not moved but rather directories beneath var are given their own mountpoints (e.g. /var/spool, /var/mail, /var/tmp, /var/adm/sw, /var/opt/omni --- depending upon your applications and needs). It's so easy to fill up /var/spool that it is an extremely good candidate for its own filesystem. Fill up /var/spool is really no big deal -- lp may break but filling up /var can kill your entire system.

If it ain't broke, I can fix that.
Lolupee
Regular Advisor

Re: Moving a filesystem to an seperate LV.

Mitchell,

brief steps if you must mv directory.
make new file systems and mount on junk

mkdir /tmp/junk_new
mount /dev/vg00/lvol?? /tmp/junk_new

Move to your source files

cd /var/junk_old

tar cvf - *|(cd /tmp/junk_new; tar xvf -)

above would tar the files from /var/junk_old and dump them on /tmp/junk_new

after confirming the files are the same, then follow the next step

Hopefully, the files system or files you plan to move are those that could be moved withput an outage.

If the directory is a file system, try to mount, if it does then you may be ok. If not you might need to be on single user level before you can do that or maintenance level.

If it is a dirctory, if it is in use it could be difficult to mount on.

Let us knowthe directory in question.