[clug] Moving the contents of / to a new filesystem on Ubuntu?

Kevin Pulo kev at pulo.com.au
Mon Jul 26 18:46:31 MDT 2010


On Tue, Jul 27, 2010 at 12:10:59AM +1000, Michael Still wrote:

> I have a root file system at home on a disk which is failing. I also have 
> a RAID file system on this machine on disks which aren't failing [1].
>
> Is there a nice tool in Ubuntu which will support moving the contents of  
> / to this file system without a reinstall? I could do it manually, but  
> its fiddly to do while remote from the machine, which I will be for the  
> next 10 days.

After transferring with cp/rsync/tar/whatever, you'll still need to
switch over to the new root.  The simplest way is usually a reboot,
but changing from booting a "plain" root to an LVM+RAID setup could be
dicey while remote (ie. mess up the initrd and the system may not
boot).

You might be able to avoid the reboot by using pivot_root.  After
shutting down as much as possible (ie. get as close to single-user
mode without actually doing that, shutdown everything but ssh and any
other essential stuff) and doing the transfer, then do the pivot_root
to change the root to the new fs.  Existing processes will still be on
the "old" root, the main thing to fix is init, it'll need a SIGUSR1 to
reopen it's control fifo in /dev, followed by a telinit u to re-exec
init off the new root.

Then you can look towards stopping/restarting other things like udevd,
hald, sshd, etc.  When the old root will cleanly unmount, then
everything has been moved off it.  Then you need to move (or create)
/boot, and fix up the boot process, which could possibly wait until
you're back next to the machine, since even if it's on the failing
disk it shouldn't be used at all and could probably be copied
somewhere and then unmounted.

Of course, this is all pretty risky too, and I haven't tried any of
it.  :)  It does sound like fun, but maybe better to try out in a VM
first.  :)

Kev

-- 
Kevin Pulo
kev at pulo.com.au
http://www.kev.pulo.com.au/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/linux/attachments/20100727/c9d5ff66/attachment.pgp>


More information about the linux mailing list