ZFS mounting failed with error 2

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

ZFS mounting failed with error 2

David DEMELIER
Hello

I have tried to create a GPT partition scheme on my machine. I've
created some dataset like that :

tank/usr
tank/usr/ports
tank/usr/src
tank/var/
tank/var/log

(Please note that is a test on a virtual machine before applying to a
real machine).

I've tried to generate the zpool.cache like that:

zpool import -o cachefile=/tmp/zpool.cache -o altroot=/mnt -f
cp /tmp/zpool.cache /mnt/boot/zfs/

And then tried to set mount point to legacy and bootfs with :

zfs set bootfs=tank tank
zfs set mountpoint=legacy tank

The following commands made a lot of warnings :

zfs set mountpoint=/usr tank/usr
zfs set mountpoint=/var tank/var
...

After, the import on the livecd shell generated the error :

cannot mount '/mnt/var': failed to create mountpoint.

I must say that it is very hard to make a ZFS working machine, there
are a lot of pages on the Wiki and most of them are a little bit
outdated..

--
Demelier David
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: ZFS mounting failed with error 2

Trond Endrestøl
On Wed, 10 Apr 2013 10:16+0200, David Demelier wrote:

> Hello
>
> I have tried to create a GPT partition scheme on my machine. I've
> created some dataset like that :
>
> tank/usr
> tank/usr/ports
> tank/usr/src
> tank/var/
> tank/var/log
>
> (Please note that is a test on a virtual machine before applying to a
> real machine).
>
> I've tried to generate the zpool.cache like that:
>
> zpool import -o cachefile=/tmp/zpool.cache -o altroot=/mnt -f
> cp /tmp/zpool.cache /mnt/boot/zfs/
>
> And then tried to set mount point to legacy and bootfs with :
>
> zfs set bootfs=tank tank
> zfs set mountpoint=legacy tank
>
> The following commands made a lot of warnings :
>
> zfs set mountpoint=/usr tank/usr
> zfs set mountpoint=/var tank/var
> ...
>
> After, the import on the livecd shell generated the error :
>
> cannot mount '/mnt/var': failed to create mountpoint.
>
> I must say that it is very hard to make a ZFS working machine, there
> are a lot of pages on the Wiki and most of them are a little bit
> outdated..
Try to use /tmp/mnt as a temporary altroot. /tmp should be writeable.
Not sure about / within the livecd env.

When you set mountpoints using the above commands, the filesystems are
actually being mounted at their specified mountpoint.

Unless the filesystems contain some actual files, more to the point,
critical files, i.e. libraries and executables, then you are out of
luck.

My own blog entry is a bit (out)dated, but maybe it's worth a look:

http://ximalas.info/2011/10/17/zfs-root-fs-on-freebsd-9-0/

--
+-------------------------------+------------------------------------+
| Vennlig hilsen,               | Best regards,                      |
| Trond Endrestøl,              | Trond Endrestøl,                   |
| IT-ansvarlig,                 | System administrator,              |
| Fagskolen Innlandet,          | Gjøvik Technical College, Norway,  |
| tlf. mob.   952 62 567,       | Cellular...: +47 952 62 567,       |
| sentralbord 61 14 54 00.      | Switchboard: +47 61 14 54 00.      |
+-------------------------------+------------------------------------+
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: ZFS mounting failed with error 2

David DEMELIER
2013/4/10 Trond Endrestøl <[hidden email]>:

> On Wed, 10 Apr 2013 10:16+0200, David Demelier wrote:
>
>> Hello
>>
>> I have tried to create a GPT partition scheme on my machine. I've
>> created some dataset like that :
>>
>> tank/usr
>> tank/usr/ports
>> tank/usr/src
>> tank/var/
>> tank/var/log
>>
>> (Please note that is a test on a virtual machine before applying to a
>> real machine).
>>
>> I've tried to generate the zpool.cache like that:
>>
>> zpool import -o cachefile=/tmp/zpool.cache -o altroot=/mnt -f
>> cp /tmp/zpool.cache /mnt/boot/zfs/
>>
>> And then tried to set mount point to legacy and bootfs with :
>>
>> zfs set bootfs=tank tank
>> zfs set mountpoint=legacy tank
>>
>> The following commands made a lot of warnings :
>>
>> zfs set mountpoint=/usr tank/usr
>> zfs set mountpoint=/var tank/var
>> ...
>>
>> After, the import on the livecd shell generated the error :
>>
>> cannot mount '/mnt/var': failed to create mountpoint.
>>
>> I must say that it is very hard to make a ZFS working machine, there
>> are a lot of pages on the Wiki and most of them are a little bit
>> outdated..
>
> Try to use /tmp/mnt as a temporary altroot. /tmp should be writeable.
> Not sure about / within the livecd env.
>

But the FreeBSD installer says to mount over /mnt before exiting the shell.

> When you set mountpoints using the above commands, the filesystems are
> actually being mounted at their specified mountpoint.
>

Yes that was a probable issue, I will unmount everything before trying
a new install.

> Unless the filesystems contain some actual files, more to the point,
> critical files, i.e. libraries and executables, then you are out of
> luck.
>
> My own blog entry is a bit (out)dated, but maybe it's worth a look:
>
> http://ximalas.info/2011/10/17/zfs-root-fs-on-freebsd-9-0/
>

Now I currently have 504 Gateway Timeout going to your website, I will
try at home maybe my corporate firewall is blocking this.

Regards,

--
Demelier David
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: ZFS mounting failed with error 2

Trond Endrestøl
On Wed, 10 Apr 2013 11:05+0200, David Demelier wrote:

> > My own blog entry is a bit (out)dated, but maybe it's worth a look:
> >
> > http://ximalas.info/2011/10/17/zfs-root-fs-on-freebsd-9-0/
>
> Now I currently have 504 Gateway Timeout going to your website, I will
> try at home maybe my corporate firewall is blocking this.

The blog is up & running, I assure you. Perhaps my choice of the .info
TLD is unacceptable for some reason. It could even be the count of
four letters, rather than 2 or 3, or all sorts of other crazy.

Anyway, best of luck. ZFS is still a manual install, just pick the
shell option in the FreeBSD Installer, and type away.

--
+-------------------------------+------------------------------------+
| Vennlig hilsen,               | Best regards,                      |
| Trond Endrestøl,              | Trond Endrestøl,                   |
| IT-ansvarlig,                 | System administrator,              |
| Fagskolen Innlandet,          | Gjøvik Technical College, Norway,  |
| tlf. mob.   952 62 567,       | Cellular...: +47 952 62 567,       |
| sentralbord 61 14 54 00.      | Switchboard: +47 61 14 54 00.      |
+-------------------------------+------------------------------------+
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: ZFS mounting failed with error 2

David DEMELIER
I've successfully made booting one virtual machine, I tried again and
it failed again. There's one thing I'm not sure about is that some
people create a dataset root but that actually mounts at / (and not
/root) and some just create others mount points directly on the zpool

I've tested the second one so I did the following :

zpool create -o altroot=/mnt tank /dev/gpt/disk0
zfs create tank/usr
...

And then I've done all the other and I'm still unable to boot, this is
the exact list (and order) I've used :

gpart create -s GPT ada0
gpart add -t freebsd-boot -s 64k -l boot0 ada0
gpart add -t freebsd-swap -s 4G -l swap0 ada0
gpart add -t freebsd-zfs -l disk0 ada0

gpart bootcode -b /boot/pmbr ada0
gpart bootcode -p /boot/gptzfsboot -i 1 ada0

zpool create -o altroot=/mnt tank /dev/gpt/zfs0
zpool set bootfs=tank tank
zfs set checksum=fletcher4 tank

zfs create -o setuid=off                    tank/home
zfs create -o setuid=off                    tank/tmp

# /usr
zfs create                            tank/usr
zfs create                            tank/usr/local
zfs create -o setuid=off -o compression=lzjb            tank/usr/src
zfs create -o setuid=off -o compression=lzjb            tank/usr/ports

# /var
zfs create                            tank/var
zfs create -o setuid=off -o compression=lzjb -o exec=off    tank/var/crash
zfs create -o setuid=off -o compression=lzjb -o exec=off    tank/var/log
zfs create -o setuid=off -o exec=off                tank/var/run
zfs create -o setuid=off                    tank/var/tmp

chmod 1777 /mnt/tmp /mnt/var/tmp

### TYPE EXIT TO INSTALL THE SETS
### THEN CHOOSE LIVECD

echo "/dev/label/swap0 none swap sw 0 0"    >> /mnt/etc/fstab
echo "zfs_enable=YES"                >> /mnt/etc/rc.conf
echo "zfs_load=YES"                >> /mnt/boot/loader.conf
echo "vfs.root.mountfrom=zfs:tank"        >> /mnt/boot/loader.conf

# zpool.cache (unable to boot without)
zpool export tank
zpool import -o cachefile=/tmp/zpool.cache -o altroot=/mnt tank
cp /tmp/zpool.cache /mnt/boot/zfs
zpool export tank

# Finished
shutdown -r now

Regards,

--
Demelier David
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

ZFS mounting failed with error 2

Beeblebrox
>> one thing I'm not sure about is that some people create a dataset root but that actually mounts at / (and not /root) and some just create others mount points directly on the zpool

You can do this either way. A ZFS dataset is created at the same time and with the same name as the zpool. You can use the zpool-named-dataset as root without any problem. As I recall, the separate root dataset was a work-around for some old problem, so it is not necessary any longer. That said, you can place and name the zfs root dataset anywhere you want, as long as you have the 'vfs.root.mountfrom=' path set correctly. In your example, it is set correctly.

Now as to why you cannot boot - from my experience, the problem is your last command:
'# zpool export tank' will leave the pool in an exported state, and when the system tries to boot, it will not be able to locate the zpool because the pool is in exportland. The solution is different. After you are finished with all your settings you should
# zfs umount -a (unmount all tank & child datasets in /mnt)
# zfs set mountpoint=/ tank
# reboot

At step 2, dataset tank should not try to re-mount its self and remain un-mounted. The older versions of ZFS did not behave this way and would immediately mount the zpool on root. If this happens, you have to hard-reset and such because the system will freeze up. If all goes well, before reboot you can also check (zfs get all tank) and make sure that canmount=on is set for tank.

The best zfs guide is FreeBSD's own docs: https://wiki.freebsd.org/RootOnZFS
FreeBSD-11-current_amd64_root-on-zfs_RadeonKMS
Reply | Threaded
Open this post in threaded view
|

Re: ZFS mounting failed with error 2

David DEMELIER
2013/4/16 Beeblebrox <[hidden email]>:

>>> one thing I'm not sure about is that some people create a dataset root but
> that actually mounts at / (and not /root) and some just create others mount
> points directly on the zpool
>
> You can do this either way. A ZFS dataset is created at the same time and
> with the same name as the zpool. You can use the zpool-named-dataset as root
> without any problem. As I recall, the separate root dataset was a
> work-around for some old problem, so it is not necessary any longer. That
> said, you can place and name the zfs root dataset anywhere you want, as long
> as you have the 'vfs.root.mountfrom=' path set correctly. In your example,
> it is set correctly.
>
> Now as to why you cannot boot - from my experience, the problem is your last
> command:
> '# zpool export tank' will leave the pool in an exported state, and when the
> system tries to boot, it will not be able to locate the zpool because the
> pool is in exportland. The solution is different. After you are finished
> with all your settings you should
> # zfs umount -a (unmount all tank & child datasets in /mnt)
> # zfs set mountpoint=/ tank
> # reboot

Thank you so much, you made my day :-) For me I thought that export
was a kind of unmounting so I should have never found if you didn't
helped me on that case :p.

>
> At step 2, dataset tank should not try to re-mount its self and remain
> un-mounted. The older versions of ZFS did not behave this way and would
> immediately mount the zpool on root. If this happens, you have to hard-reset
> and such because the system will freeze up. If all goes well, before reboot
> you can also check (zfs get all tank) and make sure that canmount=on is set
> for tank.
>
> The best zfs guide is FreeBSD's own docs: https://wiki.freebsd.org/RootOnZFS
>


--
Demelier David
_______________________________________________
[hidden email] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"