Re: Trying to move /usr



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



Relevant Pages

  • 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: Writing File System Driver & Creating Virtual Disk Drive in Windows XP [Question by a Novice
    ... strange partition it should be safe, but having a backup of it would be a ... virtual disk, but this is quite dodgy - if you make a mistake here (and ... He needs a file system. ... ***How to show partitions in windows explorer? ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Reconfiguring a second partition for data storage in SuSE 9.0
    ... What to you mean by your "empty partition?" ... you are not actually looking at the "real" root file system on hdb4? ... Command: quit ...
    (comp.os.linux)
  • Re: Trying to move /usr
    ... Note /dev/ad8s1e is an empty partition (a new disk, ... to overwrite my own usr directory needlessly. ... Check our partition after the df command, ...
    (freebsd-questions)
  • (no subject)
    ... FAT32 XP partition is OK and I can boot XP, ... Cannot find file system superblock ... /dev/ad0s2e: CAN'T CHECK FILE SYSTEM. ... GEOM: new disk ad0 ...
    (freebsd-current)