All of lore.kernel.org
 help / color / mirror / Atom feed
* btrfs subvolume & default subvolume
@ 2015-04-07  9:57 arnaud gaboury
  2015-04-07 10:58 ` arnaud gaboury
  0 siblings, 1 reply; 16+ messages in thread
From: arnaud gaboury @ 2015-04-07  9:57 UTC (permalink / raw)
  To: linux-btrfs

I plan to install my OS on a btrfs partition, with some subvolumes.
Once the partition has been btrfs formated, I mounted it somewhere, cd
and then run <btrfs subvolume create>.

I did these two subvolumes for now:
# btrfs subvolume list .
ID 256 gen 6 top level 5 path var
ID 257 gen 7 top level 5 path home

Now I am wondering if I need to create the root filesystem partition
(/)? If yes, is this correct:
# btrfs subvolume create root

Thank you for hints
-- 

google.com/+arnaudgabourygabx

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07  9:57 btrfs subvolume & default subvolume arnaud gaboury
@ 2015-04-07 10:58 ` arnaud gaboury
  2015-04-07 11:03   ` Hugo Mills
                     ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: arnaud gaboury @ 2015-04-07 10:58 UTC (permalink / raw)
  To: linux-btrfs

On Tue, Apr 7, 2015 at 11:57 AM, arnaud gaboury
<arnaud.gaboury@gmail.com> wrote:
>
> I plan to install my OS on a btrfs partition, with some subvolumes.
> Once the partition has been btrfs formated, I mounted it somewhere, cd
> and then run <btrfs subvolume create>.
>
> I did these two subvolumes for now:
> # btrfs subvolume list .
> ID 256 gen 6 top level 5 path var
> ID 257 gen 7 top level 5 path home
>
> Now I am wondering if I need to create the root filesystem partition
> (/)? If yes, is this correct:
> # btrfs subvolume create root


After more reading, it seems to me creating a top root subvolume is
the right thing to do:
# btrfs subvolume create root
# btrfs subvolume create root/var
# btrfs subvolume create root/home

Am I right?

>
> Thank you for hints
> --
>
> google.com/+arnaudgabourygabx

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 10:58 ` arnaud gaboury
@ 2015-04-07 11:03   ` Hugo Mills
  2015-04-07 11:08     ` arnaud gaboury
  2015-04-07 13:58   ` Russell Coker
  2015-04-07 15:00   ` Chris Murphy
  2 siblings, 1 reply; 16+ messages in thread
From: Hugo Mills @ 2015-04-07 11:03 UTC (permalink / raw)
  To: arnaud gaboury; +Cc: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 1454 bytes --]

On Tue, Apr 07, 2015 at 12:58:28PM +0200, arnaud gaboury wrote:
> On Tue, Apr 7, 2015 at 11:57 AM, arnaud gaboury
> <arnaud.gaboury@gmail.com> wrote:
> >
> > I plan to install my OS on a btrfs partition, with some subvolumes.
> > Once the partition has been btrfs formated, I mounted it somewhere, cd
> > and then run <btrfs subvolume create>.
> >
> > I did these two subvolumes for now:
> > # btrfs subvolume list .
> > ID 256 gen 6 top level 5 path var
> > ID 257 gen 7 top level 5 path home
> >
> > Now I am wondering if I need to create the root filesystem partition
> > (/)? If yes, is this correct:
> > # btrfs subvolume create root
> 
> 
> After more reading, it seems to me creating a top root subvolume is
> the right thing to do:
> # btrfs subvolume create root
> # btrfs subvolume create root/var
> # btrfs subvolume create root/home
> 
> Am I right?

   Not how I'd recommend doing it. I'd say:

# btrfs sub crea root
# btrfs sub crea var
# btrfs sub crea home

   Then fstab:

LABEL=myfs    /      btrfs    subvol=root         0 0
LABEL=myfs    /var   btrfs    subvol=var          0 0
LABEL=myfs    /home  btrfs    subvol=home         0 0

   And finally, add this to your kernel command line in the bootloader
to specify how to mount root:

rootflags=subvol=root

   Hugo.

-- 
Hugo Mills             | The trouble with you, Ibid, is you think you know
hugo@... carfax.org.uk | everything.
http://carfax.org.uk/  |
PGP: E2AB1DE4          |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 11:03   ` Hugo Mills
@ 2015-04-07 11:08     ` arnaud gaboury
  2015-04-07 14:20       ` Hugo Mills
  2015-04-07 15:07       ` Chris Murphy
  0 siblings, 2 replies; 16+ messages in thread
From: arnaud gaboury @ 2015-04-07 11:08 UTC (permalink / raw)
  To: Hugo Mills, arnaud gaboury, linux-btrfs

On Tue, Apr 7, 2015 at 1:03 PM, Hugo Mills <hugo@carfax.org.uk> wrote:
> On Tue, Apr 07, 2015 at 12:58:28PM +0200, arnaud gaboury wrote:
>> On Tue, Apr 7, 2015 at 11:57 AM, arnaud gaboury
>> <arnaud.gaboury@gmail.com> wrote:
>> >
>> > I plan to install my OS on a btrfs partition, with some subvolumes.
>> > Once the partition has been btrfs formated, I mounted it somewhere, cd
>> > and then run <btrfs subvolume create>.
>> >
>> > I did these two subvolumes for now:
>> > # btrfs subvolume list .
>> > ID 256 gen 6 top level 5 path var
>> > ID 257 gen 7 top level 5 path home
>> >
>> > Now I am wondering if I need to create the root filesystem partition
>> > (/)? If yes, is this correct:
>> > # btrfs subvolume create root
>>
>>
>> After more reading, it seems to me creating a top root subvolume is
>> the right thing to do:
>> # btrfs subvolume create root
>> # btrfs subvolume create root/var
>> # btrfs subvolume create root/home
>>
>> Am I right?
>
>    Not how I'd recommend doing it. I'd say:
>
> # btrfs sub crea root
> # btrfs sub crea var
> # btrfs sub crea home
>
>    Then fstab:
>
> LABEL=myfs    /      btrfs    subvol=root         0 0
> LABEL=myfs    /var   btrfs    subvol=var          0 0
> LABEL=myfs    /home  btrfs    subvol=home         0 0
>
>    And finally, add this to your kernel command line in the bootloader
> to specify how to mount root:
>
> rootflags=subvol=root
>
>    Hugo.

Thank you Hugo. May you please tell why your recommendation is better
than my settings, if I thereafter make root as the default sub-volume?
I changed the root name to active and avoid any confusion:

# btrfs subvolume list .
ID 260 gen 17 top level 5 path active
ID 261 gen 15 top level 260 path active/home
ID 262 gen 16 top level 260 path active/var
ID 263 gen 17 top level 260 path active/etc

# btrfs subvolume set-default 260 .

In this way, I will not need any kernel command line.

>
> --
> Hugo Mills             | The trouble with you, Ibid, is you think you know
> hugo@... carfax.org.uk | everything.
> http://carfax.org.uk/  |
> PGP: E2AB1DE4          |



-- 

google.com/+arnaudgabourygabx

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 10:58 ` arnaud gaboury
  2015-04-07 11:03   ` Hugo Mills
@ 2015-04-07 13:58   ` Russell Coker
  2015-04-07 14:03     ` arnaud gaboury
  2015-04-07 15:00   ` Chris Murphy
  2 siblings, 1 reply; 16+ messages in thread
From: Russell Coker @ 2015-04-07 13:58 UTC (permalink / raw)
  To: arnaud gaboury; +Cc: linux-btrfs

On Tue, 7 Apr 2015 10:58:28 AM arnaud gaboury wrote:
> After more reading, it seems to me creating a top root subvolume is
> the right thing to do:
> # btrfs subvolume create root
> # btrfs subvolume create root/var
> # btrfs subvolume create root/home
> 
> Am I right?

A filesystem is designed to support arbitrary names for files, directories, and 
in the case of BTRFS subvolumes.

You might ask whether /var/log is a good place for log files, it's generally 
regarded that "yes" is the correct answer to that question, but it's not a 
question for filesystem developers.

I like to have / in the root subvolume so all subvolumes are available by 
default.  I have /var etc in the same subvolume so I can make an atomic 
snapshot of all such data.  It's not the one true answer, but it works for me 
and will work for other people.

The main thing is to have all data that needs to be atomically snapshotted on 
the same subvolume.

-- 
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 13:58   ` Russell Coker
@ 2015-04-07 14:03     ` arnaud gaboury
  2015-04-07 14:37       ` Russell Coker
  0 siblings, 1 reply; 16+ messages in thread
From: arnaud gaboury @ 2015-04-07 14:03 UTC (permalink / raw)
  To: Russell Coker; +Cc: linux-btrfs

On Tue, Apr 7, 2015 at 3:58 PM, Russell Coker <russell@coker.com.au> wrote:
> On Tue, 7 Apr 2015 10:58:28 AM arnaud gaboury wrote:
>> After more reading, it seems to me creating a top root subvolume is
>> the right thing to do:
>> # btrfs subvolume create root
>> # btrfs subvolume create root/var
>> # btrfs subvolume create root/home
>>
>> Am I right?
>
> A filesystem is designed to support arbitrary names for files, directories, and
> in the case of BTRFS subvolumes.
>
> You might ask whether /var/log is a good place for log files, it's generally
> regarded that "yes" is the correct answer to that question, but it's not a
> question for filesystem developers.
>
> I like to have / in the root subvolume so all subvolumes are available by
> default.  I have /var etc in the same subvolume so I can make an atomic
> snapshot of all such data.  It's not the one true answer, but it works for me
> and will work for other people.
>
> The main thing is to have all data that needs to be atomically snapshotted on
> the same subvolume.

Would you mind give the return of # btrfs subvolume list and $ cat /etc/fstab ?
It would help me. TY

>
> --
> My Main Blog         http://etbe.coker.com.au/
> My Documents Blog    http://doc.coker.com.au/



-- 

google.com/+arnaudgabourygabx

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 11:08     ` arnaud gaboury
@ 2015-04-07 14:20       ` Hugo Mills
  2015-04-07 16:31         ` arnaud gaboury
  2015-04-07 15:07       ` Chris Murphy
  1 sibling, 1 reply; 16+ messages in thread
From: Hugo Mills @ 2015-04-07 14:20 UTC (permalink / raw)
  To: arnaud gaboury; +Cc: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 3364 bytes --]

On Tue, Apr 07, 2015 at 01:08:59PM +0200, arnaud gaboury wrote:
> On Tue, Apr 7, 2015 at 1:03 PM, Hugo Mills <hugo@carfax.org.uk> wrote:
> > On Tue, Apr 07, 2015 at 12:58:28PM +0200, arnaud gaboury wrote:
[snip]
> >> After more reading, it seems to me creating a top root subvolume is
> >> the right thing to do:
> >> # btrfs subvolume create root
> >> # btrfs subvolume create root/var
> >> # btrfs subvolume create root/home
> >>
> >> Am I right?
> >
> >    Not how I'd recommend doing it. I'd say:
> >
> > # btrfs sub crea root
> > # btrfs sub crea var
> > # btrfs sub crea home
> >
> >    Then fstab:
> >
> > LABEL=myfs    /      btrfs    subvol=root         0 0
> > LABEL=myfs    /var   btrfs    subvol=var          0 0
> > LABEL=myfs    /home  btrfs    subvol=home         0 0
> >
> >    And finally, add this to your kernel command line in the bootloader
> > to specify how to mount root:
> >
> > rootflags=subvol=root
> >
> >    Hugo.
> 
> Thank you Hugo. May you please tell why your recommendation is better
> than my settings, if I thereafter make root as the default sub-volume?
> I changed the root name to active and avoid any confusion:

   Well, keeping the subvolumes separate from each other, rather than
nested, makes it a bit easier to do things like replace one subvolume
with an earlier snapshot. If you nest them, then your recovery process
from (say) a screwed-up / looks a bit like this:

# mount -o subvolid=0 /dev/sda1 /media/btrfs
# mv /media/btrfs/root /media/btrfs/old-root
# btrfs sub snap /media/btrfs/old-root/snapshots/last-root /media/btrfs/root
# btrfs sub snap /media/btrfs/old-root/var /media/btrfs/root/var
# btrfs sub snap /media/btrfs/old-root/home /media/btrfs/root/home
# btrfs sub set-default $n /media/btrfs
# umount /media/btrfs

   If you don't nest them, and don't use set-default, then the same
recovery process would look like this:

# mount -o subvolid=0 /dev/sda1 /media/btrfs
# mv /media/btrfs/root /media/btrfs/old-root
# mv /media/btrfs/snapshots/last-root /media/btrfs/root
# umount /media/btrfs

   (This also explains why I wouldn't use set-default, but instead
mount / using a subvol=<path> option).

   Now, for making the snapshots in the first place, with nested
subvolumes, your snapshot script looks a bit like this:

# btrfs sub snap / /snapshots/last-root

and with the approach I'd recommend, it looks like this:

# mount -o subvolid=0 /dev/sda1 /media/btrfs
# btrfs sub snap /media/btrfs/root /media/btrfs/snapshots/last-root
# umount /media/btrfs

which is a little more complex, but the approach is precisely similar
to the recovery process: mount the top level of the FS on
/media/btrfs, manipulate the subvolumes, and then unmount. This keeps
the management of subvolumes a completely separate concern from the
structure of the filesystem tree.

   Hugo.

> # btrfs subvolume list .
> ID 260 gen 17 top level 5 path active
> ID 261 gen 15 top level 260 path active/home
> ID 262 gen 16 top level 260 path active/var
> ID 263 gen 17 top level 260 path active/etc
> 
> # btrfs subvolume set-default 260 .
> 
> In this way, I will not need any kernel command line.
> 
> >

-- 
Hugo Mills             | Vote early, vote often
hugo@... carfax.org.uk |
http://carfax.org.uk/  |
PGP: E2AB1DE4          |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 14:03     ` arnaud gaboury
@ 2015-04-07 14:37       ` Russell Coker
  0 siblings, 0 replies; 16+ messages in thread
From: Russell Coker @ 2015-04-07 14:37 UTC (permalink / raw)
  To: arnaud gaboury; +Cc: linux-btrfs

On Tue, 7 Apr 2015 02:03:04 PM arnaud gaboury wrote:
> Would you mind give the return of # btrfs subvolume list and $ cat
> /etc/fstab ? It would help me. TY

ID 262 gen 1579103 top level 5 path mysql                                                                                                                                                                               
ID 263 gen 1179578 top level 5 path var/spool/squid                                                                                                                                                                     
ID 264 gen 1579262 top level 5 path xenstore                                                                                                                                                                            
ID 265 gen 1579262 top level 5 path mailstore                                                                                                                                                                           
ID 269 gen 1578978 top level 5 path xenswap                                                                                                                                                                             
ID 318 gen 1569545 top level 5 path webstore                                                                                                                                                                            
ID 328 gen 1574457 top level 262 path mysql/backup                                                                                                                                                                      
ID 329 gen 1569555 top level 264 path xenstore/backup                                                                                                                                                                   
ID 330 gen 1574457 top level 265 path mailstore/backup                                                                                                                                                                  
ID 331 gen 1569555 top level 318 path webstore/backup                                                                                                                                                                   
ID 618 gen 1569546 top level 5 path webdata                                                                                                                                                                             
ID 657 gen 1569555 top level 618 path webdata/backup                                                                                                                                                                    
ID 1456 gen 1569541 top level 5 path backup                                                                                                                                                                             
ID 1621 gen 1556937 top level 330 path mailstore/backup/2015-04-01                                                                                                                                                      
ID 1622 gen 1556938 top level 328 path mysql/backup/2015-04-01                                                                                                                                                          
ID 1623 gen 1559462 top level 330 path mailstore/backup/2015-04-02                                                                                                                                                      
ID 1624 gen 1559463 top level 328 path mysql/backup/2015-04-02                                                                                                                                                          
ID 1625 gen 1564402 top level 330 path mailstore/backup/2015-04-03                                                                                                                                                      
ID 1626 gen 1564403 top level 328 path mysql/backup/2015-04-03                                                                                                                                                          
ID 1627 gen 1566974 top level 330 path mailstore/backup/2015-04-04                                                                                                                                                      
ID 1628 gen 1566975 top level 328 path mysql/backup/2015-04-04                                                                                                                                                          
ID 1629 gen 1569540 top level 330 path mailstore/backup/2015-04-05                                                                                                                                                      
ID 1630 gen 1569543 top level 1456 path backup/2015-04-05                                                                                                                                                               
ID 1631 gen 1569542 top level 328 path mysql/backup/2015-04-05                                                                                                                                                          
ID 1632 gen 1569544 top level 329 path xenstore/backup/2015-04-05                                                                                                                                                       
ID 1633 gen 1569545 top level 331 path webstore/backup/2015-04-05                                                                                                                                                       
ID 1634 gen 1569546 top level 657 path webdata/backup/2015-04-05                                                                                                                                                        
ID 1635 gen 1571975 top level 330 path mailstore/backup/2015-04-06                                                                                                                                                      
ID 1636 gen 1571976 top level 328 path mysql/backup/2015-04-06                                                                                                                                                          
ID 1638 gen 1574447 top level 330 path mailstore/backup/2015-04-07                                                                                                                                                      
ID 1639 gen 1574448 top level 328 path mysql/backup/2015-04-07

Above is from one of my servers.  I've recently changed my backup naming 
scheme from $SUBVOL/backup to backup-$SUBVOL but haven't done it to that 
server yet.

ID 259 gen 394029 top level 5 path home                                                                                                                                                                            
ID 542 gen 389407 top level 5 path backup                                                                                                                                                                               
ID 2143 gen 393962 top level 5 path backup-home                                                                                                                                                                         
ID 4946 gen 394029 top level 5 path chroot                                                                                                                                                                              
ID 5609 gen 391938 top level 2143 path backup-home/2015-04-01                                                                                                                                                           
ID 5610 gen 391939 top level 2143 path backup-home/2015-04-01:00:00                                                                                                                                                     
ID 5611 gen 391984 top level 2143 path backup-home/2015-04-01:04:00                                                                                                                                                     
ID 5612 gen 392151 top level 2143 path backup-home/2015-04-03:02:00                                                                                                                                                     
ID 5613 gen 392252 top level 2143 path backup-home/2015-04-03:15:00                                                                                                                                                     
ID 5614 gen 392408 top level 2143 path backup-home/2015-04-04:04:00                                                                                                                                                     
ID 5615 gen 392543 top level 2143 path backup-home/2015-04-05                                                                                                                                                           
ID 5616 gen 392544 top level 2143 path backup-home/2015-04-05:00:00                                                                                                                                                     
ID 5617 gen 392620 top level 2143 path backup-home/2015-04-05:02:00                                                                                                                                                     
ID 5618 gen 392700 top level 2143 path backup-home/2015-04-05:14:00                                                                                                                                                     
ID 5619 gen 392779 top level 2143 path backup-home/2015-04-05:15:00                                                                                                                                                     
ID 5620 gen 392859 top level 2143 path backup-home/2015-04-05:20:00                                                                                                                                                     
ID 5621 gen 392966 top level 2143 path backup-home/2015-04-05:21:00                                                                                                                                                     
ID 5622 gen 393086 top level 2143 path backup-home/2015-04-06:15:00                                                                                                                                                     
ID 5623 gen 393191 top level 2143 path backup-home/2015-04-06:19:00                                                                                                                                                     
ID 5624 gen 393315 top level 2143 path backup-home/2015-04-07:13:00                                                                                                                                                     
ID 5625 gen 393419 top level 2143 path backup-home/2015-04-07:14:00                                                                                                                                                     
ID 5626 gen 393526 top level 2143 path backup-home/2015-04-07:15:00                                                                                                                                                     
ID 5627 gen 393645 top level 2143 path backup-home/2015-04-07:16:00                                                                                                                                                     
ID 5628 gen 393756 top level 2143 path backup-home/2015-04-07:17:00                                                                                                                                                     
ID 5629 gen 393847 top level 2143 path backup-home/2015-04-07:23:00                                                                                                                                                     
ID 5630 gen 393960 top level 2143 path backup-home/2015-04-08:00:00                                                                                                                                                     
ID 5631 gen 393961 top level 2143 path backup-home/2015-04-08

Above is from one of my workstations.

In both cases the BTRFS filesystem in question was mounted as root.

In both cases I grepped out the backups prior to this month, hundreds of extra 
lines would have made things less clear.

-- 
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 10:58 ` arnaud gaboury
  2015-04-07 11:03   ` Hugo Mills
  2015-04-07 13:58   ` Russell Coker
@ 2015-04-07 15:00   ` Chris Murphy
  2 siblings, 0 replies; 16+ messages in thread
From: Chris Murphy @ 2015-04-07 15:00 UTC (permalink / raw)
  To: arnaud gaboury; +Cc: Btrfs BTRFS

On Tue, Apr 7, 2015 at 4:58 AM, arnaud gaboury <arnaud.gaboury@gmail.com> wrote:
> On Tue, Apr 7, 2015 at 11:57 AM, arnaud gaboury
> <arnaud.gaboury@gmail.com> wrote:
>>
>> I plan to install my OS on a btrfs partition, with some subvolumes.
>> Once the partition has been btrfs formated, I mounted it somewhere, cd
>> and then run <btrfs subvolume create>.
>>
>> I did these two subvolumes for now:
>> # btrfs subvolume list .
>> ID 256 gen 6 top level 5 path var
>> ID 257 gen 7 top level 5 path home
>>
>> Now I am wondering if I need to create the root filesystem partition
>> (/)? If yes, is this correct:
>> # btrfs subvolume create root
>
>
> After more reading, it seems to me creating a top root subvolume is
> the right thing to do:
> # btrfs subvolume create root
> # btrfs subvolume create root/var
> # btrfs subvolume create root/home
>
> Am I right?

It will work. It's not a matter of right or wrong though. If you
intend to snapshot or rollback, I think it's easier to put all
subvolumes at the top level, and then use fstab with the subvol= or
subvolid= mount option to assemble them in the locations you want.
That way it's easier to keep all the snapshots in the top level, and
selectively do rollbacks. If you nest the subvolumes, it gets tricky.
But if you don't plan to do much snapshotting or rollbacks, it's fine
to nest.


-- 
Chris Murphy

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 11:08     ` arnaud gaboury
  2015-04-07 14:20       ` Hugo Mills
@ 2015-04-07 15:07       ` Chris Murphy
  1 sibling, 0 replies; 16+ messages in thread
From: Chris Murphy @ 2015-04-07 15:07 UTC (permalink / raw)
  To: arnaud gaboury; +Cc: Btrfs BTRFS

On Tue, Apr 7, 2015 at 5:08 AM, arnaud gaboury <arnaud.gaboury@gmail.com> wrote:
> May you please tell why your recommendation is better
> than my settings, if I thereafter make root as the default sub-volume?

For what it's worth, the bootloader ignores the default subvolume and
so does the mount command anytime you use subvol= or subvol=id mount
options. I don't recommend relying on changing default subvolume to
something else on any volume used as root, it just gets confusing.

It makes sense for data drives, where you have a main subvolume that
you pretty much always want to mount by default, and then every so
often you can mount subvolid=5 to make a snapshot of that subvolume.
Yet a normal mount would always mount that main subvolume, not the top
level.

-- 
Chris Murphy

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 14:20       ` Hugo Mills
@ 2015-04-07 16:31         ` arnaud gaboury
  2015-04-07 16:40           ` Hugo Mills
  0 siblings, 1 reply; 16+ messages in thread
From: arnaud gaboury @ 2015-04-07 16:31 UTC (permalink / raw)
  To: Hugo Mills, arnaud gaboury, linux-btrfs

On Tue, Apr 7, 2015 at 4:20 PM, Hugo Mills <hugo@carfax.org.uk> wrote:
> On Tue, Apr 07, 2015 at 01:08:59PM +0200, arnaud gaboury wrote:
>> On Tue, Apr 7, 2015 at 1:03 PM, Hugo Mills <hugo@carfax.org.uk> wrote:
>> > On Tue, Apr 07, 2015 at 12:58:28PM +0200, arnaud gaboury wrote:
> [snip]
>> >> After more reading, it seems to me creating a top root subvolume is
>> >> the right thing to do:
>> >> # btrfs subvolume create root
>> >> # btrfs subvolume create root/var
>> >> # btrfs subvolume create root/home
>> >>
>> >> Am I right?
>> >
>> >    Not how I'd recommend doing it. I'd say:
>> >
>> > # btrfs sub crea root
>> > # btrfs sub crea var
>> > # btrfs sub crea home
>> >
>> >    Then fstab:
>> >
>> > LABEL=myfs    /      btrfs    subvol=root         0 0
>> > LABEL=myfs    /var   btrfs    subvol=var          0 0
>> > LABEL=myfs    /home  btrfs    subvol=home         0 0
>> >
>> >    And finally, add this to your kernel command line in the bootloader
>> > to specify how to mount root:
>> >
>> > rootflags=subvol=root
>> >
>> >    Hugo.
>>
>> Thank you Hugo. May you please tell why your recommendation is better
>> than my settings, if I thereafter make root as the default sub-volume?
>> I changed the root name to active and avoid any confusion:
>
>    Well, keeping the subvolumes separate from each other, rather than
> nested, makes it a bit easier to do things like replace one subvolume
> with an earlier snapshot. If you nest them, then your recovery process
> from (say) a screwed-up / looks a bit like this:
>
> # mount -o subvolid=0 /dev/sda1 /media/btrfs
> # mv /media/btrfs/root /media/btrfs/old-root
> # btrfs sub snap /media/btrfs/old-root/snapshots/last-root /media/btrfs/root
> # btrfs sub snap /media/btrfs/old-root/var /media/btrfs/root/var
> # btrfs sub snap /media/btrfs/old-root/home /media/btrfs/root/home
> # btrfs sub set-default $n /media/btrfs
> # umount /media/btrfs
>
>    If you don't nest them, and don't use set-default, then the same
> recovery process would look like this:
>
> # mount -o subvolid=0 /dev/sda1 /media/btrfs
> # mv /media/btrfs/root /media/btrfs/old-root
> # mv /media/btrfs/snapshots/last-root /media/btrfs/root
> # umount /media/btrfs
>
>    (This also explains why I wouldn't use set-default, but instead
> mount / using a subvol=<path> option).
>
>    Now, for making the snapshots in the first place, with nested
> subvolumes, your snapshot script looks a bit like this:
>
> # btrfs sub snap / /snapshots/last-root
>
> and with the approach I'd recommend, it looks like this:
>
> # mount -o subvolid=0 /dev/sda1 /media/btrfs
> # btrfs sub snap /media/btrfs/root /media/btrfs/snapshots/last-root
> # umount /media/btrfs
>
> which is a little more complex, but the approach is precisely similar
> to the recovery process: mount the top level of the FS on
> /media/btrfs, manipulate the subvolumes, and then unmount. This keeps
> the management of subvolumes a completely separate concern from the
> structure of the filesystem tree.
>
>    Hugo.

Thank you for all these info.
Here is my setup now. I hope I fully understand all the hints.

$ cd /mnt/btrfs
# btrfs subvolume create active  ---> Just in case I want to add
another subvolumes
# btrfs subvolume create active/rootvol
# btrfs subvolume create active/home
# btrfs subvolume create active/var
# btrfs subvolume create active/etc


$ cd /
# umount /mnt/mountpoint
# mkdir /mnt/active_btrfs
# mount -o subvol=active/rootvol /dev/partition /mnt/active_btrfs
# mkdir -p /mnt/active_btrfs/{home,var,etc}
# mount -o subvol=active/home /dev/partition /mnt/active_btrfs/home
# mount -o subvol=active/var /dev/partition /mnt/active_btrfs/var
# mount -o subvol=active/etc /dev/partition /mnt/active_btrfs/etc

Then install OS (not yet done, so everything can be changed).
The OS will be on a SSD, and is aimed to be a server with regular
snapshots. Snapshots will be in a Btrfs partition on a HD

>
>> # btrfs subvolume list .
>> ID 260 gen 17 top level 5 path active
>> ID 261 gen 15 top level 260 path active/home
>> ID 262 gen 16 top level 260 path active/var
>> ID 263 gen 17 top level 260 path active/etc
>>
>> # btrfs subvolume set-default 260 .
>>
>> In this way, I will not need any kernel command line.
>>
>> >
>
> --
> Hugo Mills             | Vote early, vote often
> hugo@... carfax.org.uk |
> http://carfax.org.uk/  |
> PGP: E2AB1DE4          |



-- 

google.com/+arnaudgabourygabx

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 16:31         ` arnaud gaboury
@ 2015-04-07 16:40           ` Hugo Mills
  2015-04-07 17:06             ` arnaud gaboury
  2015-04-07 17:09             ` Chris Murphy
  0 siblings, 2 replies; 16+ messages in thread
From: Hugo Mills @ 2015-04-07 16:40 UTC (permalink / raw)
  To: arnaud gaboury; +Cc: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 4074 bytes --]

On Tue, Apr 07, 2015 at 06:31:36PM +0200, arnaud gaboury wrote:
> On Tue, Apr 7, 2015 at 4:20 PM, Hugo Mills <hugo@carfax.org.uk> wrote:
> > On Tue, Apr 07, 2015 at 01:08:59PM +0200, arnaud gaboury wrote:
> >> On Tue, Apr 7, 2015 at 1:03 PM, Hugo Mills <hugo@carfax.org.uk> wrote:
> >> > On Tue, Apr 07, 2015 at 12:58:28PM +0200, arnaud gaboury wrote:
> > [snip]
> >> >> After more reading, it seems to me creating a top root subvolume is
> >> >> the right thing to do:
> >> >> # btrfs subvolume create root
> >> >> # btrfs subvolume create root/var
> >> >> # btrfs subvolume create root/home
> >> >>
> >> >> Am I right?
> >> >
> >> >    Not how I'd recommend doing it. I'd say:
> >> >
> >> > # btrfs sub crea root
> >> > # btrfs sub crea var
> >> > # btrfs sub crea home
> >> >
> >> >    Then fstab:
> >> >
> >> > LABEL=myfs    /      btrfs    subvol=root         0 0
> >> > LABEL=myfs    /var   btrfs    subvol=var          0 0
> >> > LABEL=myfs    /home  btrfs    subvol=home         0 0
> >> >
> >> >    And finally, add this to your kernel command line in the bootloader
> >> > to specify how to mount root:
> >> >
> >> > rootflags=subvol=root
> >> >
> >> >    Hugo.
> >>
> >> Thank you Hugo. May you please tell why your recommendation is better
> >> than my settings, if I thereafter make root as the default sub-volume?
> >> I changed the root name to active and avoid any confusion:
> >
> >    Well, keeping the subvolumes separate from each other, rather than
> > nested, makes it a bit easier to do things like replace one subvolume
> > with an earlier snapshot. If you nest them, then your recovery process
> > from (say) a screwed-up / looks a bit like this:
> >
> > # mount -o subvolid=0 /dev/sda1 /media/btrfs
> > # mv /media/btrfs/root /media/btrfs/old-root
> > # btrfs sub snap /media/btrfs/old-root/snapshots/last-root /media/btrfs/root
> > # btrfs sub snap /media/btrfs/old-root/var /media/btrfs/root/var
> > # btrfs sub snap /media/btrfs/old-root/home /media/btrfs/root/home
> > # btrfs sub set-default $n /media/btrfs
> > # umount /media/btrfs
> >
> >    If you don't nest them, and don't use set-default, then the same
> > recovery process would look like this:
> >
> > # mount -o subvolid=0 /dev/sda1 /media/btrfs
> > # mv /media/btrfs/root /media/btrfs/old-root
> > # mv /media/btrfs/snapshots/last-root /media/btrfs/root
> > # umount /media/btrfs
> >
> >    (This also explains why I wouldn't use set-default, but instead
> > mount / using a subvol=<path> option).
> >
> >    Now, for making the snapshots in the first place, with nested
> > subvolumes, your snapshot script looks a bit like this:
> >
> > # btrfs sub snap / /snapshots/last-root
> >
> > and with the approach I'd recommend, it looks like this:
> >
> > # mount -o subvolid=0 /dev/sda1 /media/btrfs
> > # btrfs sub snap /media/btrfs/root /media/btrfs/snapshots/last-root
> > # umount /media/btrfs
> >
> > which is a little more complex, but the approach is precisely similar
> > to the recovery process: mount the top level of the FS on
> > /media/btrfs, manipulate the subvolumes, and then unmount. This keeps
> > the management of subvolumes a completely separate concern from the
> > structure of the filesystem tree.
> >
> >    Hugo.
> 
> Thank you for all these info.
> Here is my setup now. I hope I fully understand all the hints.
> 
> $ cd /mnt/btrfs
> # btrfs subvolume create active  ---> Just in case I want to add
> another subvolumes
> # btrfs subvolume create active/rootvol
> # btrfs subvolume create active/home
> # btrfs subvolume create active/var
> # btrfs subvolume create active/etc

   One minor thing -- you've still got nested subvolumes here. You can
still run into the same kinds of management problems (not being able
to use mv efficiently to move subvolumes around). "active" doesn't
need to be a subvolume, it can (and, I'd argue, should) be an ordinary
directory.

   Hugo.

-- 
Hugo Mills             | What do you give the man who has everything?
hugo@... carfax.org.uk | Penicillin is a good start...
http://carfax.org.uk/  |
PGP: E2AB1DE4          |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 16:40           ` Hugo Mills
@ 2015-04-07 17:06             ` arnaud gaboury
  2015-04-07 17:09             ` Chris Murphy
  1 sibling, 0 replies; 16+ messages in thread
From: arnaud gaboury @ 2015-04-07 17:06 UTC (permalink / raw)
  To: Hugo Mills, arnaud gaboury, linux-btrfs

On Tue, Apr 7, 2015 at 6:40 PM, Hugo Mills <hugo@carfax.org.uk> wrote:
> On Tue, Apr 07, 2015 at 06:31:36PM +0200, arnaud gaboury wrote:
>> On Tue, Apr 7, 2015 at 4:20 PM, Hugo Mills <hugo@carfax.org.uk> wrote:
>> > On Tue, Apr 07, 2015 at 01:08:59PM +0200, arnaud gaboury wrote:
>> >> On Tue, Apr 7, 2015 at 1:03 PM, Hugo Mills <hugo@carfax.org.uk> wrote:
>> >> > On Tue, Apr 07, 2015 at 12:58:28PM +0200, arnaud gaboury wrote:
>> > [snip]
>> >> >> After more reading, it seems to me creating a top root subvolume is
>> >> >> the right thing to do:
>> >> >> # btrfs subvolume create root
>> >> >> # btrfs subvolume create root/var
>> >> >> # btrfs subvolume create root/home
>> >> >>
>> >> >> Am I right?
>> >> >
>> >> >    Not how I'd recommend doing it. I'd say:
>> >> >
>> >> > # btrfs sub crea root
>> >> > # btrfs sub crea var
>> >> > # btrfs sub crea home
>> >> >
>> >> >    Then fstab:
>> >> >
>> >> > LABEL=myfs    /      btrfs    subvol=root         0 0
>> >> > LABEL=myfs    /var   btrfs    subvol=var          0 0
>> >> > LABEL=myfs    /home  btrfs    subvol=home         0 0
>> >> >
>> >> >    And finally, add this to your kernel command line in the bootloader
>> >> > to specify how to mount root:
>> >> >
>> >> > rootflags=subvol=root
>> >> >
>> >> >    Hugo.
>> >>
>> >> Thank you Hugo. May you please tell why your recommendation is better
>> >> than my settings, if I thereafter make root as the default sub-volume?
>> >> I changed the root name to active and avoid any confusion:
>> >
>> >    Well, keeping the subvolumes separate from each other, rather than
>> > nested, makes it a bit easier to do things like replace one subvolume
>> > with an earlier snapshot. If you nest them, then your recovery process
>> > from (say) a screwed-up / looks a bit like this:
>> >
>> > # mount -o subvolid=0 /dev/sda1 /media/btrfs
>> > # mv /media/btrfs/root /media/btrfs/old-root
>> > # btrfs sub snap /media/btrfs/old-root/snapshots/last-root /media/btrfs/root
>> > # btrfs sub snap /media/btrfs/old-root/var /media/btrfs/root/var
>> > # btrfs sub snap /media/btrfs/old-root/home /media/btrfs/root/home
>> > # btrfs sub set-default $n /media/btrfs
>> > # umount /media/btrfs
>> >
>> >    If you don't nest them, and don't use set-default, then the same
>> > recovery process would look like this:
>> >
>> > # mount -o subvolid=0 /dev/sda1 /media/btrfs
>> > # mv /media/btrfs/root /media/btrfs/old-root
>> > # mv /media/btrfs/snapshots/last-root /media/btrfs/root
>> > # umount /media/btrfs
>> >
>> >    (This also explains why I wouldn't use set-default, but instead
>> > mount / using a subvol=<path> option).
>> >
>> >    Now, for making the snapshots in the first place, with nested
>> > subvolumes, your snapshot script looks a bit like this:
>> >
>> > # btrfs sub snap / /snapshots/last-root
>> >
>> > and with the approach I'd recommend, it looks like this:
>> >
>> > # mount -o subvolid=0 /dev/sda1 /media/btrfs
>> > # btrfs sub snap /media/btrfs/root /media/btrfs/snapshots/last-root
>> > # umount /media/btrfs
>> >
>> > which is a little more complex, but the approach is precisely similar
>> > to the recovery process: mount the top level of the FS on
>> > /media/btrfs, manipulate the subvolumes, and then unmount. This keeps
>> > the management of subvolumes a completely separate concern from the
>> > structure of the filesystem tree.
>> >
>> >    Hugo.
>>
>> Thank you for all these info.
>> Here is my setup now. I hope I fully understand all the hints.
>>
>> $ cd /mnt/btrfs
>> # btrfs subvolume create active  ---> Just in case I want to add
>> another subvolumes
>> # btrfs subvolume create active/rootvol
>> # btrfs subvolume create active/home
>> # btrfs subvolume create active/var
>> # btrfs subvolume create active/etc
>
>    One minor thing -- you've still got nested subvolumes here. You can
> still run into the same kinds of management problems (not being able
> to use mv efficiently to move subvolumes around). "active" doesn't
> need to be a subvolume, it can (and, I'd argue, should) be an ordinary
> directory.
>
>    Hugo.

So in mnt/btrfs,
# btrfs subvolume delete ...
deleted all subvolumes. Checked list was empty. Then:
$ cd /mnt/btrfs
# btrfs subvolume create rootvol
# btrfs subvolume create home
# btrfs subvolume create var
# btrfs subvolume create etc

Basic and no nested volumes.
No default subvolume.

Is this finally correct?

Thank you

>
> --
> Hugo Mills             | What do you give the man who has everything?
> hugo@... carfax.org.uk | Penicillin is a good start...
> http://carfax.org.uk/  |
> PGP: E2AB1DE4          |



-- 

google.com/+arnaudgabourygabx

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 16:40           ` Hugo Mills
  2015-04-07 17:06             ` arnaud gaboury
@ 2015-04-07 17:09             ` Chris Murphy
  2015-04-07 17:15               ` arnaud gaboury
  1 sibling, 1 reply; 16+ messages in thread
From: Chris Murphy @ 2015-04-07 17:09 UTC (permalink / raw)
  To: Hugo Mills, arnaud gaboury, Btrfs BTRFS

On Tue, Apr 7, 2015 at 10:40 AM, Hugo Mills <hugo@carfax.org.uk> wrote:
>    One minor thing -- you've still got nested subvolumes here. You can
> still run into the same kinds of management problems (not being able
> to use mv efficiently to move subvolumes around). "active" doesn't
> need to be a subvolume, it can (and, I'd argue, should) be an ordinary
> directory.

I agree. Or just incorporate into the naming convention of the
subvolume. I've been following a variation on the naming scheme in the
"What We Propose" here:
http://0pointer.net/blog/revisiting-how-we-put-together-linux-systems.html
which is more intended for stateless systems. I add a field at the end
:current vs :date where :date is yyyymmdd with an optional -X sequence
in case there's more than one snapshot per day.


-- 
Chris Murphy

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 17:09             ` Chris Murphy
@ 2015-04-07 17:15               ` arnaud gaboury
  2015-04-08  2:06                 ` Chris Murphy
  0 siblings, 1 reply; 16+ messages in thread
From: arnaud gaboury @ 2015-04-07 17:15 UTC (permalink / raw)
  To: Chris Murphy; +Cc: Hugo Mills, Btrfs BTRFS

On Tue, Apr 7, 2015 at 7:09 PM, Chris Murphy <lists@colorremedies.com> wrote:
> On Tue, Apr 7, 2015 at 10:40 AM, Hugo Mills <hugo@carfax.org.uk> wrote:
>>    One minor thing -- you've still got nested subvolumes here. You can
>> still run into the same kinds of management problems (not being able
>> to use mv efficiently to move subvolumes around). "active" doesn't
>> need to be a subvolume, it can (and, I'd argue, should) be an ordinary
>> directory.
>
> I agree. Or just incorporate into the naming convention of the
> subvolume. I've been following a variation on the naming scheme in the
> "What We Propose" here:
> http://0pointer.net/blog/revisiting-how-we-put-together-linux-systems.html

The server will indeed be a nspawn container with Fedora

> which is more intended for stateless systems. I add a field at the end
> :current vs :date where :date is yyyymmdd with an optional -X sequence
> in case there's more than one snapshot per day.
>
>
> --
> Chris Murphy



-- 

google.com/+arnaudgabourygabx

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: btrfs subvolume & default subvolume
  2015-04-07 17:15               ` arnaud gaboury
@ 2015-04-08  2:06                 ` Chris Murphy
  0 siblings, 0 replies; 16+ messages in thread
From: Chris Murphy @ 2015-04-08  2:06 UTC (permalink / raw)
  To: arnaud gaboury; +Cc: Chris Murphy, Hugo Mills, Btrfs BTRFS

On Tue, Apr 7, 2015 at 11:15 AM, arnaud gaboury
<arnaud.gaboury@gmail.com> wrote:
> On Tue, Apr 7, 2015 at 7:09 PM, Chris Murphy <lists@colorremedies.com> wrote:
>> On Tue, Apr 7, 2015 at 10:40 AM, Hugo Mills <hugo@carfax.org.uk> wrote:
>>>    One minor thing -- you've still got nested subvolumes here. You can
>>> still run into the same kinds of management problems (not being able
>>> to use mv efficiently to move subvolumes around). "active" doesn't
>>> need to be a subvolume, it can (and, I'd argue, should) be an ordinary
>>> directory.
>>
>> I agree. Or just incorporate into the naming convention of the
>> subvolume. I've been following a variation on the naming scheme in the
>> "What We Propose" here:
>> http://0pointer.net/blog/revisiting-how-we-put-together-linux-systems.html
>
> The server will indeed be a nspawn container with Fedora

There's a recent thread "Recursive subvolume snapshots and deletion?"
about systemd nspawn containers. Those are organized in a nested
fashion, and hence one of the reasons for the recursive snapshot
feature request.

-- 
Chris Murphy

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-04-08  2:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07  9:57 btrfs subvolume & default subvolume arnaud gaboury
2015-04-07 10:58 ` arnaud gaboury
2015-04-07 11:03   ` Hugo Mills
2015-04-07 11:08     ` arnaud gaboury
2015-04-07 14:20       ` Hugo Mills
2015-04-07 16:31         ` arnaud gaboury
2015-04-07 16:40           ` Hugo Mills
2015-04-07 17:06             ` arnaud gaboury
2015-04-07 17:09             ` Chris Murphy
2015-04-07 17:15               ` arnaud gaboury
2015-04-08  2:06                 ` Chris Murphy
2015-04-07 15:07       ` Chris Murphy
2015-04-07 13:58   ` Russell Coker
2015-04-07 14:03     ` arnaud gaboury
2015-04-07 14:37       ` Russell Coker
2015-04-07 15:00   ` Chris Murphy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.