Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Aug 2007 01:30:09 -0400 (EDT)
From:      Michael S <msherman77@yahoo.com>
To:        Vinny <vinny-mail-01+20070820usrmv@palaceofretention.ca>, FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: Trying to move /usr  - Fixed
Message-ID:  <228964.87960.qm@web88310.mail.re4.yahoo.com>
In-Reply-To: <46CA52E1.1080102@palaceofretention.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
I was able to rectify the problem by removing /home,
which was a link and was pointing to /usr/home and
then recreating it as a directory.

Thanks everyone for their suggestions,
Michael

--- Vinny
<vinny-mail-01+20070820usrmv@palaceofretention.ca>
wrote:

> Michael S wrote:
> > I reverted to the old /usr.
> > What I had done:
> > Initially I set up the newly installed drive (da2)
> > to have only one partition (da2s1d) which I chose
> to
> > be /user (note the e).
> > I tarred /usr to a file in /user
> > tar -cf /user/usr.tar /tar
> > 
> > and extracted the file
> > tar -xf usr.tar
> > I had the whole structure of /usr underneath
> /user/usr
> > 
> > And then
> > cd usr
> > mv * ..
> > 
> > to have everything under /user
> > 
> 
> After thinking about that mv command, I have come to
> the
> conclusion that /dev/da2s1d does not in fact contain
> a /usr directory structure and if mounted will be
> empty.  Why?
> 
> Note /dev/ad8s1e is an empty partition (a new disk,
> if you will on my system that I will in this
> demonstration).
> 
> Also, I'll use user and usrdemo as the names of the
> user and usr
> directories that Michael is using, respectively.  I
> don't want
> to overwrite my own usr directory needlessly.
> 
> Observe:
> 
> Create a mount point and mount the disk
> t# cd /
> t# mkdir user
> t# mount -t ufs /dev/ad8s1e /user
> 
> t# pwd
> /user
> t# mkdir -p usrdemo/path
> 
> Check our partition (there is a dot (.)after the df
> command,
> look closely):
> 
> t# df .
> Filesystem  1K-blocks Used  Avail Capacity  Mounted
> on
> /dev/ad8s1e    507630    6 467014     0%    /user
> 
> Create a file for no reason.
> 
> t# touch usrdemo/path/file.txt
> t# cd /
> t# ls -laR /user
> total 6
> drwxrwxrwt   3 root  wheel   512 Aug 20 22:05 .
> drwxr-xr-x  26 root  wheel  1024 Aug 20 21:59 ..
> drwxr-xr-x   3 root  wheel   512 Aug 20 22:05
> usrdemo
> 
> /user/usrdemo:
> total 6
> drwxr-xr-x  3 root  wheel  512 Aug 20 22:05 .
> drwxrwxrwt  3 root  wheel  512 Aug 20 22:05 ..
> drwxr-xr-x  2 root  wheel  512 Aug 20 22:05 path
> 
> /user/usrdemo/path:
> total 4
> drwxr-xr-x  2 root  wheel  512 Aug 20 22:05 .
> drwxr-xr-x  3 root  wheel  512 Aug 20 22:05 ..
> -rw-r--r--  1 root  wheel    0 Aug 20 22:05 file.txt
> t# cd /user
> 
> Let's look at what file system we're on again:
> 
> t# df .
> Filesystem  1K-blocks Used  Avail Capacity  Mounted
> on
> /dev/ad8s1e    507630    6 467014     0%    /user
> 
> Still on the new drive.
> 
> Now that we're in the /user directory let us try, as
> Michael
> says "to have everything under /user".  Right idea,
> but mv is not
> the tool in this case: The next command causes much
> trouble:
> 
> t# mv * ..
> 
> will in fact move the contents of /user to the
> parent directory
> which is in fact /, the root of the file system.
> 
> There is nothing left in /user:
> t# pwd
> /user
> 
> t# ls -la
> total 4
> drwxrwxrwt   2 root  wheel  512 Aug 20 22:06 .
> drwxr-xr-x  27 root  wheel  512 Aug 20 22:06 ..
> 
> If we change directory to the .. directory target
> (the same target as
> the mv command) we'll see the usrdemo directory.
> 
> t# cd ..
> t# ls
> .cshrc          compat          lib             proc
>            usb
> .profile        dev             libexec        
> rescue          usr
> .snap           dist            media           root
>            usrdemo
> COPYRIGHT       dvdrom          mnd             sbin
>            var
> bin             entropy         mnt             sdvd
> boot            etc             user            sys
> cdrom           home            portable        tmp
> 
> If we change to it and check our file system:
> 
> t# cd usrdemo/path/
> t# ls
> file.txt
> t# df .
> Filesystem  1K-blocks  Used  Avail Capacity  Mounted
> on
> /dev/ad4s1a    507630 99704 367316    21%    /
> 
> We find it now sitting as a directory the / root
> partition!
> In Michael's case it would be sitting on the old
> /usr
> partition.  Definitely not what we wanted.
> 
> So what has happened is that the mv * command with
> Michael's
> usr directory actually overwrote the current /usr
> directory
> with the contents of the tar archive.  Seems like a
> no-op but
> there could be symbolic link issues, i.e. /usr/home
> -> /home.
> 
> I hope that is semi-coherent.
> 
> What you probably want to do to replace a /usr
> partition is
> something like this:
> 
> cd /
> mkdir user
> mount -t ufs /dev/da2s1d /user
> cd /usr
> pax -rw -pe . /user
> 
> pax is like tar. -rw means to read (r) from the
> source (.)
> and write (w) to the destination (/user).  -pe means
> to
> preserve everything (permissions, ownership etc).
> 
> Having done that, you now have a duplicate usr
> directory
> structure "under" /user i.e. /user/bin /user/lib and
> so on.
> 
> Now you can switch the fstab entries like you
> planned,
> reboot, and you should have replaced /usr with the
> new drive.
> 
> Hope this helps, although you may have some issues
> in the future due to any unintended consequences
> of the tar/mv command combination.
> 
> Vinny
> 
> 
> 
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
>
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
> "freebsd-questions-unsubscribe@freebsd.org"
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?228964.87960.qm>