Re: Trying to move /usr



On Mon, Aug 20, 2007 at 10:50:09PM -0400, Vinny 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

Try using the 'F' flag on ls. It will make it clear when
you are looking at a directory name and when it is a regular file
and when it is a link.

It makes thing easier to follow.
Actually, I normally alias 'ls' to 'ls -F' in my .cshrc to
make it that way all the time.

////jerry


/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@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"
_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • IDE HDD fail?
    ... This caused after this command: ... Device contains neither a valid DOS partition table, nor Sun, SGI or OSF ... Offline data collection status: ... Self-test execution status: ...
    (Linux-Kernel)
  • Re: Help with a little dd damage!
    ... Partition 3 has different physical/logical beginnings: ... Feb 28 20:20:57 morgansmachine kernel: EXT3-fs: write access will be enabled during recovery. ... So, fingers firmly crossed, have I managed to copy enough of my hard drive with the first two commands to be able to patch back the catastrophic damage I seem to have done with the last command. ... "By choosing not to ship any proprietary or binary drivers, Fedora does ...
    (Fedora)
  • Re: Trying to move /usr - Fixed
    ... After thinking about that mv command, ... Note /dev/ad8s1e is an empty partition (a new disk, ... I'll use user and usrdemo as the names of the ... the root of the file system. ...
    (freebsd-questions)
  • Re: HD-DOS+ Notes
    ... The F-P command expects high byte first and low byte last. ... No, if there are more than 16 characters in the filename, the normal ... the system partition and is arranged just like a directory on a disk ...
    (comp.sys.cbm)
  • add disk/partition to softRaid5
    ... I am trying to add a partition to a 3 disk RAID5 device by using ... Command: Partition number: ... Old raid-disk 0 has 2132 chunks, ...
    (comp.os.linux.misc)