Skip to contentSkip to conversation

How to mount a subvolume?

DISCUSSION Dipl.-Ing. Michael Niederle 4 participants 5 messages Jan 9, 2010 Btrfs file system

lore
Share & tools
lore
#0 lore raw

First thanks alot to Kay and Goffredo!

But I have another question.

I read that the current tools cannot display subvolumes, but one should still be able to mount them. If I try I get an error message:

Quoted 1 line

mount -t btrfs -o subvol=root.2010-01-07 /dev/sda3 /save

mount: /dev/sda3 is not a valid block device

root.2010-01-07 is a snapshot of the /root-directory

/save is an empty directory used for mounting backups

taken (successfully) with the following command:

Quoted 1 line

btrfsctl -s root.2010-01-07 /root

What am I doing wrong? Isn't it possible to mount the whole filesystem and a subvolume at the same time?

Greetings, Michael

#1 lore raw
Quoted 11 lines · On Saturday 09 January 2010 14:07:57 Dipl.-Ing. Michael Niederle wrote:

First thanks alot to Kay and Goffredo!

But I have another question.

I read that the current tools cannot display subvolumes, but one should
still

be able to mount them. If I try I get an error message:

Quoted 1 line

mount -t btrfs -o subvol=root.2010-01-07 /dev/sda3 /save

mount: /dev/sda3 is not a valid block device

Does /dev/sda3 actually exist?

Is this a USB device which may have changed its name (now sdb3, or even sdc3) after plugging it out and back in again?

Bye...

Dirk

#2 lore raw

Hi, Dirk!

Quoted 1 line

Does /dev/sda3 actually exist?

/dev/sda3 does exist; it is an btrfs formatted partition containing my root file system:

Quoted 1 line

mount

...
/dev/sda3 on / type btrfs (rw,relatime,noacl)
...

Greetings, Michael

@Johannes: I will recreate the /dev/brtfs-control device node in the startup scripts using the information from /sys/class/misc/btrfs-control/dev - thanks!

#3 lore raw
In reply to Dipl.-Ing. Michael Niederle
Quoted 9 lines · Dipl.-Ing. Michael Niederle

I read that the current tools cannot display subvolumes, but one should still be able to mount them. If I try I get an error message:

Quoted 1 line

mount -t btrfs -o subvol=root.2010-01-07 /dev/sda3 /save

mount: /dev/sda3 is not a valid block device

root.2010-01-07 is a snapshot of the /root-directory taken (successfully) with the following command:

Quoted 1 line

btrfsctl -s root.2010-01-07 /root

Snapshots aren't subvolumes. You create mountable subvolumes with
btrfsctl -S

Signature · 2 lines
Tomasz Torcz               RIP is irrevelant. Spoofing is futile.
xmpp: [email protected]     Your routes will be aggreggated. -- Alex Yuriev
#4 lore raw
In reply to Dipl.-Ing. Michael Niederle
Quoted 5 lines · Dipl.-Ing. Michael Niederle

First thanks alot to Kay and Goffredo!

But I have another question.

I read that the current tools cannot display subvolumes, but one should

still

Quoted 7 lines

be able to mount them. If I try I get an error message:

Quoted 1 line

mount -t btrfs -o subvol=root.2010-01-07 /dev/sda3 /save

mount: /dev/sda3 is not a valid block device

root.2010-01-07 is a snapshot of the /root-directory

Quoted 8 lines

/save is an empty directory used for mounting backups

taken (successfully) with the following command:

Quoted 1 line

btrfsctl -s root.2010-01-07 /root

What am I doing wrong? Isn't it possible to mount the whole filesystem and a subvolume at the same time?

It is possible. I do that on my machine. The magic part is that the subvolume/snapshot (are the same thing) has to be under the / of the filesystem.

  ghigo@arakne:/tmp$ mkdir test 
  ghigo@arakne:/tmp$ mkdir test-snap
  ghigo@arakne:/tmp$ sudo mount -o /dev/sdc test
  ghigo@arakne:/tmp$ mount | grep btrfs                  
  /dev/sdc on /tmp/test type btrfs (rw)
  ghigo@arakne:/tmp$ cd test                    
  ghigo@arakne:/tmp/test$ sudo mkdir a
  ghigo@arakne:/tmp/test$ sudo btrfsctl -s a/snap-on-subdir .
  operation complete
  Btrfs Btrfs v0.19
  ghigo@arakne:/tmp/test$ sudo btrfsctl -s snap-of-root .
  operation complete
  Btrfs Btrfs v0.19
  ghigo@arakne:/tmp/test$ cd ..
  ghigo@arakne:/tmp$ sudo mount -o subvol=snap-on-subdir  /dev/sdc test-snap/
  mount: /dev/sdc is not a valid block device
  ghigo@arakne:/tmp$ sudo mount -o subvol=snap-of-root  /dev/sdc test-snap/
  ghigo@arakne:/tmp$ mount | grep btrfs
  /dev/sdc on /tmp/test type btrfs (rw)
  /dev/sdc on /tmp/test-snap type btrfs (rw,subvol=snap-of-root)

Note:
- both the root of the btrfs filesystem and its snapshot are mounted at the same time
- if a subvolume/snapshot not placed in the root is mounted an error is returned (/dev/sdX is not a valid block device)

Quoted 1 line

Greetings, Michael

Goffredo

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
gpg key@ keyserver.linux.it: Goffredo Baroncelli (ghigo) <kreijackATinwind.it>
Key fingerprint = 4769 7E51 5293 D36C 814E  C054 BF04 F161 3DC5 0512