Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to mount a snapshot of a ZFS zvol. The zvol should have a ext2 partition on it (as evidenced by the CentOS VM to which the zvol is currently shared by iSCSI):

[root@test-vm ~]# file - < /dev/sdb
/dev/stdin: x86 boot sector; partition 1: ID=0x83, starthead 4, startsector 256, 6291200 sectors, code offset 0xb8
[root@test-vm ~]# file - < /dev/sdb1
/dev/stdin: Linux rev 1.0 ext2 filesystem data (mounted or unclean) (large files)

However, mount always returns Invalid argument:

[root@freenas] /dev/zvol/vol01# ls
./                        zvol01                    zvol01@backups1           zvol01@manual-20140521s1  zvol01@manual-20140522s1
../                       zvol01@backup             zvol01@manual-20140521    zvol01@manual-20140522
[root@freenas] /dev/zvol/vol01# file - < zvol01
/dev/stdin: x86 boot sector; partition 1: ID=0x83, starthead 4, startsector 256, 6291200 sectors, code offset 0xb8
[root@freenas] /dev/zvol/vol01# file - < zvol01@backup
/dev/stdin: x86 boot sector; partition 1: ID=0x83, starthead 4, startsector 256, 6291200 sectors, code offset 0xb8
[root@freenas] /dev/zvol/vol01# file - < zvol01@backups1
/dev/stdin: data
[root@freenas] /dev/zvol/vol01# mkdir /tmp/zvol01
[root@freenas] /dev/zvol/vol01# mount -t ext2fs -r /dev/zvol/vol01/zvol01@backup /tmp/zvol01
mount: /dev/zvol/vol01/zvol01@backup: Invalid argument
[root@freenas] /dev/zvol/vol01# mount -t ext2fs -r /dev/zvol/vol01/zvol01@backups1 /tmp/zvol01
mount: /dev/zvol/vol01/zvol01@backups1: Invalid argument

I presume that zvol01@backups1 is the correct target (i.e. the first partition under on the block device, zvol01@backup) -- both return Invalid argument, regardless.

What am I missing here?

Edit

As requested, the output of zfs list and zfs get all...

[root@freenas] ~# zfs list
NAME                   USED  AVAIL  REFER  MOUNTPOINT
vol01                 25.6G   358G   232K  /mnt/vol01
vol01/.system         1.44M   358G   244K  /mnt/vol01/.system
vol01/.system/cores    209K   358G   209K  /mnt/vol01/.system/cores
vol01/.system/samba4   506K   358G   506K  /mnt/vol01/.system/samba4
vol01/.system/syslog   517K   358G   517K  /mnt/vol01/.system/syslog
vol01/ds01             784M   358G   784M  /mnt/vol01/ds01
vol01/zvol01          24.9G   382G   113M  -

[root@freenas] ~# zfs get all vol01/zvol01
NAME          PROPERTY              VALUE                  SOURCE
vol01/zvol01  type                  volume                 -
vol01/zvol01  creation              Wed May 21 20:29 2014  -
vol01/zvol01  used                  24.9G                  -
vol01/zvol01  available             382G                   -
vol01/zvol01  referenced            113M                   -
vol01/zvol01  compressratio         1.00x                  -
vol01/zvol01  reservation           none                   default
vol01/zvol01  volsize               24G                    local
vol01/zvol01  volblocksize          4K                     -
vol01/zvol01  checksum              on                     default
vol01/zvol01  compression           lz4                    inherited from vol01
vol01/zvol01  readonly              off                    default
vol01/zvol01  copies                1                      default
vol01/zvol01  refreservation        24.8G                  local
vol01/zvol01  primarycache          all                    default
vol01/zvol01  secondarycache        all                    default
vol01/zvol01  usedbysnapshots       215K                   -
vol01/zvol01  usedbydataset         113M                   -
vol01/zvol01  usedbychildren        0                      -
vol01/zvol01  usedbyrefreservation  24.8G                  -
vol01/zvol01  logbias               latency                default
vol01/zvol01  dedup                 off                    inherited from vol01
vol01/zvol01  mlslabel                                     -
vol01/zvol01  sync                  standard               default
vol01/zvol01  refcompressratio      1.00x                  -
vol01/zvol01  written               221K                   -
vol01/zvol01  logicalused           74.4M                  -
vol01/zvol01  logicalreferenced     74.3M                  -

[root@freenas] ~# zfs get all vol01/zvol01@backup
NAME                 PROPERTY              VALUE                  SOURCE
vol01/zvol01@backup  type                  snapshot               -
vol01/zvol01@backup  creation              Thu May 22  1:48 2014  -
vol01/zvol01@backup  used                  215K                   -
vol01/zvol01@backup  referenced            113M                   -
vol01/zvol01@backup  compressratio         1.00x                  -
vol01/zvol01@backup  devices               on                     default
vol01/zvol01@backup  exec                  on                     default
vol01/zvol01@backup  setuid                on                     default
vol01/zvol01@backup  xattr                 on                     default
vol01/zvol01@backup  nbmand                off                    default
vol01/zvol01@backup  primarycache          all                    default
vol01/zvol01@backup  secondarycache        all                    default
vol01/zvol01@backup  defer_destroy         off                    -
vol01/zvol01@backup  userrefs              0                      -
vol01/zvol01@backup  mlslabel                                     -
vol01/zvol01@backup  refcompressratio      1.00x                  -
vol01/zvol01@backup  written               113M                   -
vol01/zvol01@backup  clones                                       -
vol01/zvol01@backup  logicalused           0                      -
vol01/zvol01@backup  logicalreferenced     74.3M                  -

[root@freenas] /dev/zvol/vol01# gpart show
=>      63  16777153  da0  MBR  (8.0G)
        63   1930257    1  freebsd  [active]  (942M)
   1930320        63       - free -  (31k)
   1930383   1930257    2  freebsd  (942M)
   3860640      3024    3  freebsd  (1.5M)
   3863664     41328    4  freebsd  (20M)
   3904992  12872224       - free -  (6.1G)

=>      0  1930257  da0s1  BSD  (942M)
        0       16         - free -  (8.0k)
       16  1930241      1  !0  (942M)

=>       34  286749421  da1  GPT  (136G)
         34         94       - free -  (47k)
        128    4194304    1  freebsd-swap  (2.0G)
    4194432  282555023    2  freebsd-zfs  (134G)

=>       34  286749421  da2  GPT  (136G)
         34         94       - free -  (47k)
        128    4194304    1  freebsd-swap  (2.0G)
    4194432  282555023    2  freebsd-zfs  (134G)

=>       34  286749421  da3  GPT  (136G)
         34         94       - free -  (47k)
        128    4194304    1  freebsd-swap  (2.0G)
    4194432  282555023    2  freebsd-zfs  (134G)

=>       34  286749421  da4  GPT  (136G)
         34         94       - free -  (47k)
        128    4194304    1  freebsd-swap  (2.0G)
    4194432  282555023    2  freebsd-zfs  (134G)

=>      63  50331585  zvol/vol01/zvol01@backup  MBR  (24G)
        63       193                            - free -  (96k)
       256   6291200                         1  linux-data  (3G)
   6291456  44040192                            - free -  (21G)

=>      63  50331585  zvol/vol01/zvol01-clone-backup  MBR  (24G)
        63       193                                  - free -  (96k)
       256   6291200                               1  linux-data  (3G)
   6291456  44040192                                  - free -  (21G)

Edit #2

Found these in dmesg:

ext2fs: zvol/vol01/zvol01@backup: wrong magic number 0 (expected 0xef53)
ext2fs: zvol/vol01/zvol01@backups1: wrong magic number 0 (expected 0xef53)
ext2fs: zvol/vol01/zvol01-clone-backup: wrong magic number 0 (expected 0xef53)
ext2fs: zvol/vol01/zvol01-clone-backups1: wrong magic number 0 (expected 0xef53)

Is there something else I have to do to the block device before it will mount?

share|improve this question
    
In regard to your Edit #2 - See: forums.freebsd.org/viewtopic.php?&t=14063 –  ewwhite May 23 at 14:52
    
@ewwhite -- I've seen that post before. I've checked the inode size on the CentOS VM, and it is 128, not 256. I even re-formatted the partition with mkfs.ext2 -I 128 /dev/sdb1 to be sure... –  jimbobmcgee May 23 at 14:57
    
I think the inode thing was fixed in v8, back in 2010 -- freebsd.org/cgi/query-pr.cgi?pr=kern/124621 –  jimbobmcgee May 23 at 20:07

2 Answers 2

Are you trying to mount a zvol that was exported to a Linux VM to your FreeBSD-based FreeNAS?!?

If so, you need to check a few things. Please post the output of zfs list and zfs get all poolname/filesystem.

For one, the visibility of the zvol's snapshot may not set properly. This is done via the snapdev ZFS property. But that's an all-or-nothing solution. If you have lots of snapshots of zvols, it's best to leave this disabled.

The other approach to use a zvol snapshot is to clone the filesystem. Something like:

zfs clone vol01/zvol01@backups1 vol01/temporaryname 

This will make a new zvol based off of the snapshot. A corresponding block device will be created that you'll be able to mount using ext2fs mount command. Something like fdisk -l will show you the real device names.


Edit:

I do this in Linux with ZFS often.

zfs clone vol0/pprovol@april vol0/april # clone the zvol snapshot to new filesystem
# fdisk -l shows a new block device at /dev/zd16p1
mount -t xfs -o nouuid /dev/zd16p1 /restore # Mount filesystem using new block device
share|improve this answer
    
Wrong approach for what? I haven't said what I'm approaching, yet! ;-) Yes, I am trying to mount a zvol that was once exported to a Linux VM. Not because of any long-term need; just because everything I've read suggests I should be able to. I've tried with a clone, too -- same outcome: Invalid argument. I'll add the zfs list and zfs get all output shortly... –  jimbobmcgee May 23 at 13:44
    
It's the wrong approach to doing what I think you're trying to do. You'll need to use the actual block device from your OS, not the path to the zvol. I'd expect that fdisk -l will show you what you want. –  ewwhite May 23 at 13:46
    
Is /dev/zvol/the-pool/the-zvol not the actual block device, then? (zfs list|get all output added...) –  jimbobmcgee May 23 at 13:51
    
Please show the output of fdisk -l. –  ewwhite May 23 at 13:53
    
fdisk: illegal option -- l. I'm new to FreeBSD, but I think the closest equivalent is gpart show, which I've added... –  jimbobmcgee May 23 at 13:59

You should listen to the error.

You're trying to mount a disk with a partition table as an ext2 volume. That isn't going to work.

You need to create a geom device that consumes zvol01 with an offset of 256 sectors into the device and mount that.

Exactly how you do that… is left as an exercise to the reader :)

share|improve this answer
    
Can you please elaborate on this a bit (I'm new to FreeBSD) -- I get that /dev/zvol/vol01/zvol01@backup would be the 'disk with partition table', but is /dev/zvol/vol01/zvol01@backups1 not the slice/partition in that disk? I've tried with both... –  jimbobmcgee May 23 at 15:15
    
I'm not sure if those get autocreated - but it does look like it. I'd confirm by hand that the contents of /dev/sdb1 and ...s1 are exactly the same. Then I'd try mounting with -o ro to ensure FreeBSD understands it should be readonly. Maybe even clone it to a new volume first. –  MikeyB May 23 at 15:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.