Operating System - Linux
1752505 Members
5571 Online
108788 Solutions
New Discussion юеВ

Linux: Move data to a new smaller LUN

 
Coolmar
Esteemed Contributor

Linux: Move data to a new smaller LUN

Hi,

We have a 150GB LUN that only 6GB are used and needed. Therefore, a 20GB LUN has been presented to the system and we have to move the data from the 150GB to the 20GB.

Any suggestions on how to do this? I know with HP-UX we always mirrored and then broke the mirrors...but when I did that it was always to a LUN of equal size.
8 REPLIES 8
TwoProc
Honored Contributor

Re: Linux: Move data to a new smaller LUN

if you can take a application shutdown, just bring down applications and/or databases.
Make a new mount point and copy everything from the old to the new. Unmount both the old and the new file system.
Fix the fstab to mount the new smaller file system where the old large one was. Then fix the fstab to mount the old large one to a temporary name (like old_mount). Then remount both of them, and make sure same number of files, etc. Then make sure you've got the new smaller one where the old used to be, and restart your applications.

The get rid of the old mount, lvol, LUN (if desired), etc.
We are the people our parents warned us about --Jimmy Buffett
John Guster
Trusted Contributor

Re: Linux: Move data to a new smaller LUN

make a tar out of this 6GB files, then untar to the new locaiton. Make sure there is no I/O during this so no data will be lost. It should just take a couple of minutes.
Coolmar
Esteemed Contributor

Re: Linux: Move data to a new smaller LUN

we need to keep the same filesytem name. What about a pvmove?
Steven E. Protter
Exalted Contributor

Re: Linux: Move data to a new smaller LUN

Shalom,

dd will work.

apps down though.

If its a cooked file system and apps are down cp -rp will work.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
TwoProc
Honored Contributor

Re: Linux: Move data to a new smaller LUN

I don't think pvmove is gonna do it for you. It'll just move a pv to another lvm. The sizing problems would just come from the old pv right into the new volume group.
We are the people our parents warned us about --Jimmy Buffett
Matti_Kurkela
Honored Contributor

Re: Linux: Move data to a new smaller LUN

> we need to keep the same filesytem name.

Linux ext2/ext3 filesystems have an actual filesystem name, but it isn't usually visible to the users or normal applications at all. You can use "tune2fs -L" to change it while the filesystem is not mounted.

But I guess you meant the mount point name, or the volume group name.

Keeping the same mount point name is rather simple:
1.) mount the new LUN to a temporary location, for example /mnt

2.) use "cp -a" or equivalent to copy the data from the old LUN to the filesystem in the temporary location

3.) Set the ownership and permissions of /mnt to match the ownership and permissions to match the old mountpoint.

4.) unmount the old LUN and the new LUN

5.) edit /etc/fstab so that the new LUN automatically mounts into the old mountpoint instead of the old LUN

6.) mount the new LUN into the old mountpoint: the users and applications should see all files exactly as before.

7.) if you need to do any clean-up, you can mount the old LUN to a temporary location; or you can just un-present it if you don't need it any more.

If the problem is the VG name, it can be solved by using the "vgrename" command. A VG must be deactivated first (unmount all filesystems, vgchange -a n ) before it can be renamed.

MK
MK
Gerardo Arceri
Trusted Contributor

Re: Linux: Move data to a new smaller LUN

Are you using LVM to manage the filesystem ?
If so
pvcreate /dev/newlun
vgextend your_vg /dev/newlun
pvmove /dev/oldlun /dev/newlun
vgreduce your_vg /dev/oldlun
pvremove /dev/oldlun.

If you are not using LVM then the best option is to:
1) Stop apps/db/anything using files on the old filesystem
2) format a similar filesystem on the new lun
3) Mount the new lun to some dir (like /mnt/newfs) and make sure it has the same perms as the old filesystem.
4) Use rsync to copy the files:
rsync -avzp /old_fs /mnt/newfs
5) umount both the old and new filesystems
6) modify /etc/fstab so the filesystem points to the new lun
7) mount the new filesystem on the correct mountpoint.
8) start your apps
9) Be happy.

Steven E. Protter
Exalted Contributor

Re: Linux: Move data to a new smaller LUN

Shalom,

It occurred to me that you could use resize2fs to reduce the file system size. You could then use lvreduce on the logical volume and get it the same size as the new target disk.

This would open up many more replication options.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com