Setting a ZFS mountpoint in my /tank results in an empty directory!

General questions about the FreeBSD operating system. Ask here if your question does not fit elsewhere.

Setting a ZFS mountpoint in my /tank results in an empty directory!

Postby Agi93 » 17 Jan 2010, 03:17

I'm exploring the wonderful world of ZFS, but I have yet to get it working. My current setup is a Sony VAIO VGN-SZ430N laptop with four slices: A 6.37G Windows recovery slice (ad4s1), a 27.7G Windows Vista slice (ad4s2), a 20G FreeBSD slice with all of my UFS partitions (ad4s3), and a 94G unformatted slice (but I did set the type as "165: freebsd" in cfdisk during install) (ad4s4). I ran the following command to create a zpool:

[CMD="#"]zpool create tank ad4s4[/CMD]

This left me with a /tank, hopefully being my fourth slice formatted as zfs. I then created some datasets:

[CMD="#"]zfs create tank/usr[/CMD]
[CMD="#"]zfs create tank/usr/home[/CMD]

At this point I wanted to try zfs out by sticking my home directory on it (I just installed and got my system up to date, so I don't have personal information to lose)

[CMD="#"]zfs set mountpoint=/usr/home tank/usr/home[/CMD]

That seemed to be successful, but then I tried to cd into /usr/home, only to find there was nothing there. I have one normal user "agi", and that directory was missing. Fortunately, all I had to do was run:

[CMD="#"]zfs set mountpoint=none tank/usr/home[/CMD]

and my home directory was safe and sound on my UFS partition (I could successfully cd to /home/agi or /usr/home/agi and find the contents).

But what happened? Why was there nothing there even after setting the mountpoint?

One thing I found from the zfs man page was to try running

[CMD="#"]zfs mount -a[/CMD]

after setting all the mountpoints, but that did nothing :( . I've tried this with /usr/ports and /usr/ports/distfiles as well, and neither of those worked.

Just recently, I saw a reference in the ZFS Administration Guide and an online guide to setting the mountpoint to /export/home instead of /home. What exactly would that do? I'm not on my FreeBSD laptop right now, so I can't test it. Is this the solution I'm looking for‽


Thanks in advance. I hope I didn't screw this up from the start with my slicing (I used the advice I got from this thread: http://forums.freebsd.org/showthread.php?t=10237 )
Agi93
Junior Member
 
Posts: 43
Joined: 03 Jan 2010, 21:00

Postby dennylin93 » 17 Jan 2010, 03:42

The datasets are empty by default, so you'll have to copy your existing data over. [port]net/rsync[/port] might be useful for this.
dennylin93
Member
 
Posts: 784
Joined: 11 Dec 2008, 13:13

Postby Agi93 » 17 Jan 2010, 03:54

Honestly? That was the problem? Lol it's so obvious no wonder I didn't see it in any documentation!

Alright, now I need to find the best options for the rsync command to copy my data. rsync -rv looks pretty good from the man page, but are there more options I should pass to get the file attributes or anything else right?
Agi93
Junior Member
 
Posts: 43
Joined: 03 Jan 2010, 21:00

Postby wonslung » 17 Jan 2010, 13:19

yah, the best way to do this would be to create them, leave them mounted on /tank/ then use piped tar's to copy eveyrthing over (or cpio)

once you have it all copied over, then change the mount points to what they need to be.
wonslung
Member
 
Posts: 850
Joined: 07 May 2009, 00:15

Postby Agi93 » 17 Jan 2010, 15:52

It looks like the best command for the job is
[CMD="#"]rsync -av <source> <destination>[/CMD]
I'm doing that right now and it's working. Let's see if it all mounts and works correctly in the end.
Agi93
Junior Member
 
Posts: 43
Joined: 03 Jan 2010, 21:00

Postby jalla » 17 Jan 2010, 16:05

Agi93 wrote:It looks like the best command for the job is
[CMD="#"]rsync -av <source> <destination>[/CMD]
I'm doing that right now and it's working. Let's see if it all mounts and works correctly in the end.


Installing extra sw for this is overkill. In your case it should be as simple as
Code: Select all
cp -pR /src /dst
User avatar
jalla
Member
 
Posts: 369
Joined: 06 Aug 2009, 12:41
Location: Bergen, Norway

Postby Agi93 » 17 Jan 2010, 16:08

:) that works too
Agi93
Junior Member
 
Posts: 43
Joined: 03 Jan 2010, 21:00

Postby knarf » 17 Jan 2010, 17:31

I'd recommend [CMD="%"]rsync -aHxv[/CMD].
knarf
Junior Member
 
Posts: 88
Joined: 11 Oct 2009, 12:05

Postby Agi93 » 17 Jan 2010, 17:50

I already ran rsync -av and zfs won't let me unmount var or tmp because they're apparently in use, even when I take off noauto from the ufs partitions. Is it harmful that I didn't include the H and x options for rsync? Also, according to the rsync man page, the x option does not allow the data to transcend filesystems, and I wanted to transfer my data from ufs to zfs.
Agi93
Junior Member
 
Posts: 43
Joined: 03 Jan 2010, 21:00

Postby knarf » 18 Jan 2010, 13:16

Use [FILE]sysutils/lsof[/FILE] or fstat(8) to find out who is still sitting in the partition you're trying to umount. If you know what you are doing, use [CMD="#"]umount -f[/CMD]. Moving "system" partitions like /usr and /var should be done in single user mode or better using fixit.

[CMD="#"]rsync -H[/CMD] preserves hard links. If you do not preserve them you'll waste space on the destination and maybe break integrity (depending on the actual use of hardlinks). This is also the reason why [CMD="#"]cp -pR[/CMD] is a no go (there are some other reasons, too).

[CMD="#"]rsync -x[/CMD] (--one-file-system) does not mean source and destination have to be on the same filesystem. It means the recursive search does never leave the filesystem where it started.

There's a huge difference between these two:

[CMD="#"]rsync -aHxv / /usr /backup/root[/CMD]
[CMD="#"]rsync -aHv / /usr /backup/root[/CMD]

The second command will fail so hard. :)
knarf
Junior Member
 
Posts: 88
Joined: 11 Oct 2009, 12:05

Postby Agi93 » 18 Jan 2010, 14:54

Yes! I was able to properly unmount my zfs datasets, destroy the pool, recreate it and all of my datasets, and I just ran this long rsync -aHxv command to copy my data from each desired ufs directory to its corresponding one in /tank. It's still running now, so hopefully this will work correctly. I'll post back if I have any problems or just want to let you know it worked.

Thank you!
Agi93
Junior Member
 
Posts: 43
Joined: 03 Jan 2010, 21:00

Postby Agi93 » 18 Jan 2010, 16:59

Everything worked perfectly. Hooray!
Agi93
Junior Member
 
Posts: 43
Joined: 03 Jan 2010, 21:00

Postby phoenix » 18 Jan 2010, 17:37

Agi93 wrote:Honestly? That was the problem? Lol it's so obvious no wonder I didn't see it in any documentation!

Alright, now I need to find the best options for the rsync command to copy my data. rsync -rv looks pretty good from the man page, but are there more options I should pass to get the file attributes or anything else right?


[cmd=#]rsync --verbose --stats --archive --hard-links --numeric-ids --inplace /path/to/source/ /path/to/dest/[/cmd]

--verbose shows all the files being copied

--stats shows you stats at the end on what was copied

--archive copies ownership and permissions correctly

--hard-links copies hard/soft links correctly, instead of making multiple copies of things (*VERY* important on FreeBSD systems if copying any bin directories)

--numeric-ids copies ownership using UID/GID instead of doing name lookups in /etc/passwd and /etc/group all the time (not really needed on local copies, but when copying between systems, it's very important)

--inplace isn't needed on an initial copy into a blank ZFS filesystem, but it will make future copies into ZFS much faster, as it plays better with the Copy-on-Write semantics of ZFS
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
User avatar
phoenix
MFC'd
 
Posts: 3349
Joined: 17 Nov 2008, 05:43
Location: Kamloops, BC, Canada


Return to General

Who is online

Users browsing this forum: cuq, trh411 and 1 guest