From owner-freebsd-questions@FreeBSD.ORG Tue Aug 21 03:19:24 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA07F16A418 for ; Tue, 21 Aug 2007 03:19:24 +0000 (UTC) (envelope-from vinny-mail-01+20070820usrmv@palaceofretention.ca) Received: from www.giovannetti.ca (www.giovannetti.ca [206.248.136.48]) by mx1.freebsd.org (Postfix) with ESMTP id 7714913C474 for ; Tue, 21 Aug 2007 03:19:24 +0000 (UTC) (envelope-from vinny-mail-01+20070820usrmv@palaceofretention.ca) Received: from t.palaceofretention.ca (intgateway.palaceofretention.ca [10.10.10.42]) by www.giovannetti.ca (Postfix) with ESMTP id B7C3A11460; Mon, 20 Aug 2007 23:04:29 -0400 (EDT) Message-ID: <46CA52E1.1080102@palaceofretention.ca> Date: Mon, 20 Aug 2007 22:50:09 -0400 From: Vinny User-Agent: Thunderbird 2.0.0.6 (X11/20070811) MIME-Version: 1.0 To: Michael S References: <508113.84269.qm@web88303.mail.re4.yahoo.com> In-Reply-To: <508113.84269.qm@web88303.mail.re4.yahoo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: FreeBSD Mailing List Subject: Re: Trying to move /usr X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2007 03:19:25 -0000 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