Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 3326

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<HTML
><HEAD
><TITLE
>Filesystem Migration</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="Linux + XFS HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE=" Kernel Configuration and Installation "
HREF="x106.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Linux + XFS HOWTO: Linux on Steroids</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x106.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
>&nbsp;</TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN154">4. Filesystem Migration</H1
><P
>The final part of this whole process is probably actually the
 trickiest  and most dangerous as far as the possibility of losing
 your data goes.   I strongly suggest that you make a complete backup
 of the system (or at least all important data) before attempting
 the migration to XFS.   This part is also the most difficult to explain
 as there are probably  hundreds of ways you can do this based on
 the set up of your existing filesystem.  I will give you the basic
 commands for creating the new filesystems, try to give some pointers
 on how to go about shuffling  filesystems, and in general just relay
 to you the way I went about  migrating my own filesystems.   
 </P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN157">4.1. Migrating the / filesystem</H2
><P
>Probably the trickiest part of creating a fully XFS system is
 migrating  the / filesystem since that is the system that supports
 the entire rest  of the system and it cannot actually be unmounted
 while the system is  running.  If you have extra partitions that
 can be mounted as / then you will be able to do it something like
 this(I am using /dev/hda4 as the  spare partition and /dev/hda2 as
 / for this example):   
  </P
><P
>  <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>$ mkfs -t ext2 /dev/hda4 
$ mkdir /mnt/temp 
$ mount -t ext2 /dev/hda4 /mnt/temp 
$ cd / 
$ tar lcf - .|(cd /mnt/temp; tar xpvf - )   
  </PRE
></FONT
></TD
></TR
></TABLE
>
  </P
><P
>Notice I have used tar here to copy the files from the / fs to
 the spare partition.  Alternatively you could use cp -dpR, but if
 you use tar like I've shown here with the -l flag it will copy only
 files from within the / fs (i.e. if you have another partition mounted
 as /usr it won't copy those).   
  </P
><P
>The next step will be to change all references to /dev/hda2 to
 /dev/hda4 in  /etc/fstab and in /etc/lilo.conf and run lilo.  You'll
 then need to reboot the system again.   
  </P
><P
>After rebooting the system /dev/hda4 will be mounted as / and
 your original / filesystem (/dev/hda2) will not be mounted.  You
 can now create the new  XFS filesystem on /dev/hda2.   
  </P
><P
>  <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>$ mkfs -t xfs /dev/hda2   
  </PRE
></FONT
></TD
></TR
></TABLE
>
  </P
><P
>Then mount the new xfs fs:   
  </P
><P
>  <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>$ mount -t xfs /dev/hda2 /mnt/temp   
  </PRE
></FONT
></TD
></TR
></TABLE
>
  </P
><P
>And copy the original / fs back to its original home:   
  </P
><P
>  <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>$ cd / 
$ tar lcf - .|(cd /mnt/temp; tar xpvf -)   
  </PRE
></FONT
></TD
></TR
></TABLE
>
  </P
><P
>Once again you will need to change all instances of /dev/hda4
 in /etc/fstab and /etc/lilo.conf and run lilo.  You will also need
 to change the filesystem type for / in /etc/fstab.  It should now
 look something like this:   
  </P
><P
>  <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>/dev/hda2               /                       xfs    defaults 1 1   
  </PRE
></FONT
></TD
></TR
></TABLE
>
  </P
><DIV
CLASS="NOTE"
><P
></P
><TABLE
CLASS="NOTE"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TH
ALIGN="LEFT"
VALIGN="CENTER"
><B
>Note</B
></TH
></TR
><TR
><TD
>&nbsp;</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>   On some linux distributions the options given to the out-of-box
 fstab  may be more in depth than just "defaults."  For
 instance, on Debian systems  they use "defaults,errors=remount-ro."
 The mount options are different for  every filesystem with the exception
 of the keyword "defaults."  Unless you  know the specific
 XFS mount options you want you should stick with just the  defaults
 option.  In the Debian example given, the errors option is not  available
 with XFS and will cause your filesystem not to mount.   
   </P
><P
>   Additionally, filesystem labels are becoming more popular so you may see an
 entry in your fstab that looks something like this:
    <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>LABEL=/                 /                       ext2    defaults        1 1
    </PRE
></FONT
></TD
></TR
></TABLE
>
   The easiest way to avoid problems is to simply replace the referenced label 
 with the proper device file name (i.e. if /dev/hda1 is labeled / replace "LABEL=/" 
 with "/dev/hda1"). 
   </P
></TD
></TR
></TABLE
></DIV
><P
>Now reboot the system with the new xfs / filesystem.   
  </P
><P
>Of course there are a lot of other ways to accomplish the root
 filesystem  migration and if you think you have a good one I would
 definitely like to  hear it and will put it in this doc if it seems
 like a simpler way than what  is here.  I, myself, didn't have a
 spare partition to work with but had a CD burner so I burnt a cd
 of my root filesystem to mount as root while I created the new xfs
 /.  In all cases, however, the basic commands for creating and mounting
 the new filesystem will be the same.   
  </P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN183">4.2. Finishing up</H2
><P
>The last of the process is fairly simple and essentially the
 same process of swapping around partitions while making new filesystems
 as was done for /.  I recommend that you do the rest of this process
 with the system in single user mode so you can unmount everything
 other than / and do all of the swapping without having to reboot
 a million times.  You can boot to single user mode by either issueing
 a runlevel change command to the init process like so:   
  </P
><P
>  <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>$ telinit 1   
  </PRE
></FONT
></TD
></TR
></TABLE
>
  </P
><P
>or by rebooting and asking for single user mode at the Lilo prompt:
 
  </P
><P
>  <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>LILO Boot: xfs single   
  </PRE
></FONT
></TD
></TR
></TABLE
>
  </P
><P
>This will boot the system and drop you into a root shell with
 no outside connections or virtual terminals so there is no chance
 of any of the filesystems being in use by other users or processes
 (causing them to be busy so you can't unmount them). Now you can
 mount the spare partition, as before, copy one of the remaining filesystems
 to be migrated onto it (you will probably have to remove the existing
 contents leftover from /), unmount the old filesystem, create the
 xfs filesystem on it, remount it as xfs, and copy the old filesystem
 back onto it.  Lets say you have a /dev/hda3 partition  mounted as
 /usr.  The process would go something like this:   
  </P
><P
>  <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="PROGRAMLISTING"
>$ mount -t ext2 /dev/hda4 /mnt/temp 
$ cd /usr 
$ tar lcf - .|(cd /mnt/temp; tar xpvf - ) 
$ cd /mnt/temp
$ umount /usr 
$ mkfs -t xfs /dev/hda3 
$ mount -t xfs /dev/hda3 /usr 
$ tar lcf - .|(cd /usr; tar xpvf - )   
  </PRE
></FONT
></TD
></TR
></TABLE
>
  </P
><P
>Don't forget to change the filesystem type in /etc/fstab for
 /usr to xfs.   
  </P
><P
>That's all there is to it.  The rest of the filesystems to be
 migrated will work the  same way, then you can reboot to full miltiuser
 mode and you've got your "Linux on  Steroids!"   
  </P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x106.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>&nbsp;</TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Kernel Configuration and Installation</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>&nbsp;</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>