Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Move to a new block device with a mounted, active, FS?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
DingbatCA
Guru
Guru


Joined: 07 Jul 2004
Posts: 384
Location: Portland Or

PostPosted: Thu Oct 02, 2014 4:32 am    Post subject: Move to a new block device with a mounted, active, FS? Reply with quote

I am WAY of the deep end. I need to find a way to move from a source block device (/dev/sda) to a target block device (/dev/sdb) without ever disturbing the mounted, and active, XFS file system. Basically the equivalent of a VMware storage vmotion. Slow downs are fine, to a point. I can accept 10~15ms of freeze time for the actual cut over. Both block devices are of equal size.
Code:
root@nas:~# df -h /dev/sda
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda        200G   100G  100G  50% /oracle_db

#Insert magic here

root@nas:~# df -h /dev/sdb
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb        200G   100G  100G  50% /oracle_db
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Thu Oct 02, 2014 8:16 am    Post subject: Reply with quote

This thing is possible if you had used lvm below it. XFS gave me a headache in the past, I stick to ext4 these days.

I moved my lvm volume from 250gb to sdd in the past but I think it took some hours. I am not sure if the volume was running but the keyword was lvm snapshot if you are interested.

Quote:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Logical_Volume_Manager_Administration/VG_move.html


I think i did something different on the chunk level, but I forgot how.

Quote:
pvmove allows you to move the allocated physical extents (PEs) on SourcePhysicalVolume to one or more other physical vol‐
umes (PVs). You can optionally specify a source LogicalVolume in which case only extents used by that LV will be moved to
free (or specified) extents on DestinationPhysicalVolume(s). If no DestinationPhysicalVolume is specified, the normal
allocation rules for the Volume Group are used.


When your box is some sort of nas you should use something more feasable as lvm below it and not a classical desctop setup

I am pretty sure I did used pvmove
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6014

PostPosted: Thu Oct 02, 2014 6:11 pm    Post subject: Reply with quote

It looks like you're trying to move a live database between disks?

Use rsync, keep using it in a loop until the deltas are small enough, then shut down the DB (ALL the way, or it won't flush its memory buffers to disk), rsync again, and start up on the new disk.
Back to top
View user's profile Send private message
salahx
Guru
Guru


Joined: 12 Mar 2005
Posts: 437

PostPosted: Thu Oct 02, 2014 8:08 pm    Post subject: Reply with quote

Actually, it IS possible even if you didn't use LVM, but you'll have to manipulate the device mapper manually: http://wiki.gentoo.org/wiki/Device-mapper . Look at the "mirror" and "raid1" targets. If this is one-shot deal, you don't need metadata devices. If you want to keep them sync, or are worried the process will be interrupted, you can create metadata device either using free space on the end of disk (if any, unfortunately you cannot shrink XFS filesystem), or using a USB drive (the metadata will only be a few megabytes. Any cheap USB card/drive will work).

And of course, since we're manipulating the device mapper at a low level: BE CAREFUL. Make sure you get the order right! Try the excerises with the loop device in the wiki first to get a feel for it.

Actually it might not be perfect - you may get a "device busy" error if you try to establish a mirror with a mounted filesystem, so you may need to unmount the filesystem to create the mirror, but you can remount it as soon as the mirror is established and need not wait for it to complete.
Back to top
View user's profile Send private message
DingbatCA
Guru
Guru


Joined: 07 Jul 2004
Posts: 384
Location: Portland Or

PostPosted: Thu Oct 02, 2014 8:59 pm    Post subject: Reply with quote

Thanks Salahx! I spend lots of time working with multipath; not to worried about that part. This happens to be a 3.2TB Oracle DB running across 12 fiber channel block devices all from our SAN... Time to do some testing!
Back to top
View user's profile Send private message
DingbatCA
Guru
Guru


Joined: 07 Jul 2004
Posts: 384
Location: Portland Or

PostPosted: Thu Oct 02, 2014 9:19 pm    Post subject: Reply with quote

No joy:
Code:
root@pdxattest:/tmp/foo1# dmsetup create test-mirror-log0 --table '0 8192 linear /dev/mapper/foo1 0'
device-mapper: reload ioctl failed: Invalid argument
Command failed

root@pdxattest:/tmp/foo1# dmsetup create test-mirror-log0 --table '0 8192 linear /dev/mapper/foo2 0'
root@pdxattest:/tmp/foo1# df -h
Filesystem                                           Size  Used Avail Use% Mounted on
......
/dev/mapper/foo1                                      16G  161M   16G   1% /tmp/foo1

No problems with foo2, the unused devices. But it wont touch the mounted devices, foo1.
Back to top
View user's profile Send private message
salahx
Guru
Guru


Joined: 12 Mar 2005
Posts: 437

PostPosted: Thu Oct 02, 2014 9:41 pm    Post subject: Reply with quote

Yeah it looks like you'll have ot unmount the filesystem to create the mirror. It'll only take a few seconds (assuming its executed flawlessly, its kind of tricky because you'll be mounting the block device created by the device mapper). More than a few ms, but if you can schedule this during a period of low usage you can able to pull it off with minimal disruption.
Back to top
View user's profile Send private message
DingbatCA
Guru
Guru


Joined: 07 Jul 2004
Posts: 384
Location: Portland Or

PostPosted: Thu Oct 02, 2014 9:49 pm    Post subject: Reply with quote

I wish it was that simple. Slow for us is 200MB/s. Tons of active file handles on the mount in question. No possibility to get it unmounted, even for a few ms. :-(
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum