Operating System - HP-UX
1834156 Members
2740 Online
110064 Solutions
New Discussion

moving files to a new filesystem

 
SOLVED
Go to solution
hpuxhelp
Regular Advisor

moving files to a new filesystem

I plan to move one of the filesystem along with its data to a newly created one. Is there a simple way to achieve such task
10 REPLIES 10
Ian Kidd_1
Trusted Contributor

Re: moving files to a new filesystem

Do you mean you want to move data from one logical volume mount point to another?

If so, I'd use cpio and do something like:
cd {original_mount_point}
find . -xdev -depth -print | cpio -padmucx {new_mount_point}

for example cd /u01 ; find . -xdev -depth -print | cpio -padmucx /new/u01

let me know if I interpreted your question properly.
If at first you don't succeed, go to the ITRC
Ian Kidd_1
Trusted Contributor

Re: moving files to a new filesystem

One caveat to my suggestion above is that it will not work for files greater than 2GB. Per the man page on cpio:

"Because of industry standards and nteroperability goals, cpio does not support the archival of files larger than 2GB or files that have user/group IDs greater than 60K. Files with user/group IDs greater than 60K are archived and restored under the user/group ID of the current process."
If at first you don't succeed, go to the ITRC
Michael Tully
Honored Contributor

Re: moving files to a new filesystem

We use cpio to do this task. As long as there are no files over 2Gb, your fine

Create your new logical volume and mount it on a mount point like /copy

# mount /dev/myvg/mylvol /copy
# cd /oldfilesystem
# find . -xdev | cpio -pdumv /copy
# unmount /copy
# cd /
# umount /oldfilesystem
# mount /dev/myvg/mylvol /oldfilesystem

Don't forget to update the /etc/fstab file with the new logical volume information on the old mount point name.

Regards
Michael
Anyone for a Mutiny ?
Sridhar Bhaskarla
Honored Contributor
Solution

Re: moving files to a new filesystem

Steven,

What did you mean by "along with"?. You create a new file system and then copy the data.

1. Create a new file system with desired size.

lvcreate -n lv_name -L size_in_mb vg01
newfs -F vxfs /dev/vg01/rlv_name
mkdir /templv
mount /dev/vg01/lv_name /templv

2. Copy data from old mount point to the temp mount point.

cd /oldlv
find . |cpio -pdvma /templv


3. Unmount /oldlv and /templv
#cd /
#umount /oldlv
(you will need to bring down the processes that use this filesystem)
#umount /templv

4. Edit /etc/fstab
(replace the lvol of oldlv with new lvol)
5. Mount the new lvol

#mount -a

Ensure new lvol is mount on /oldlv

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Scott Van Kalken
Esteemed Contributor

Re: moving files to a new filesystem

I like to use restore / vxrestore

It's generally faster and you don't need to worry about missing out on .profile or other "dot" files as you do with find.

This one comes from the restore man page.

dump 0f - /usr | (cd /mnt; restore xf -)


works like a charm and is generally pretty fast (faster than cpio anyhow)

Hope this helps.

Scott.
Rajeev  Shukla
Honored Contributor

Re: moving files to a new filesystem

I am wondering if you want to move all the data from one filesystem to another ( note: copying and moving)
which means you dont need the data at old place. Then simply use mv command (it wond move socket files, but dont worry they will be created when you start your application)
So Create a new filesystem and mount as said by people above and
cd /oldfilesystem
mv * /newfilesystem

Thanks
Rajeev
James R. Ferguson
Acclaimed Contributor

Re: moving files to a new filesystem

Hi Steven:

I have used the 'cpio' technique on many occassions as noted by several colleagues above. However, if largefiles (>2GB) and/or sparse files are an issue, you can use 'fbackup'/'frecover' thusly:

# cd /srcdir
# fbackup -i . -f - | (cd /dstdir; frecover -Xsrf -)

Regards!

...JRF...
Jean-Louis Phelix
Honored Contributor

Re: moving files to a new filesystem

Hi,

I think that all 'moving' answers have been covered, but since you made a post in the lvm forum, I just wanted to remind you that if you want to move a filesystem to another disk, you could also move directly the lvol using pvmove, or if you want a copy int the same vg, use lvextend/lvsplit to get an exact copy (unmount first to be sure).

Regards.
It works for me (© Bill McNAMARA ...)
hpuxhelp
Regular Advisor

Re: moving files to a new filesystem

if using fbackup and restore...do I still have to create a new filesystem prior to doing the backup?
or can the filesystem be mounted during this procedure???
hpuxhelp
Regular Advisor

Re: moving files to a new filesystem

Please ignore the previous question...i am reading man page on fbackup and frestore..and trying to do it on /usr..thanks for your help