All of lore.kernel.org
 help / color / mirror / Atom feed
* [newb] move /home to subvolume
@ 2015-06-01 12:36 Neal Becker
  2015-06-01 12:57 ` Vytautas D
  2015-06-01 18:18 ` Chris Murphy
  0 siblings, 2 replies; 8+ messages in thread
From: Neal Becker @ 2015-06-01 12:36 UTC (permalink / raw)
  To: linux-btrfs

I have everything under /:

sudo btrfs subvolume list /
ID 257 gen 65795 top level 5 path root

I want to move /home onto it's own subvolume.  I hope I can do this while 
the root device is mounted.

What is the procedure?

I tried first to create a subvolume for /home at the top-level, but couldn't 
figure out the syntax:

[nbecker@nbecker2 ~]$ sudo btrfs subvolume create /home
[sudo] password for nbecker: 
ERROR: '/home' exists

-- 
Those who fail to understand recursion are doomed to repeat it


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

* Re: [newb] move /home to subvolume
  2015-06-01 12:36 [newb] move /home to subvolume Neal Becker
@ 2015-06-01 12:57 ` Vytautas D
  2015-06-01 13:03   ` Neal Becker
  2015-06-01 18:18 ` Chris Murphy
  1 sibling, 1 reply; 8+ messages in thread
From: Vytautas D @ 2015-06-01 12:57 UTC (permalink / raw)
  To: Neal Becker; +Cc: linux-btrfs

as far as I know, you can't do this, you need to temporary move /home
somewhere else, create /home subvolume and copy everything back.

-
Vytas

On Mon, Jun 1, 2015 at 1:36 PM, Neal Becker <ndbecker2@gmail.com> wrote:
> I have everything under /:
>
> sudo btrfs subvolume list /
> ID 257 gen 65795 top level 5 path root
>
> I want to move /home onto it's own subvolume.  I hope I can do this while
> the root device is mounted.
>
> What is the procedure?
>
> I tried first to create a subvolume for /home at the top-level, but couldn't
> figure out the syntax:
>
> [nbecker@nbecker2 ~]$ sudo btrfs subvolume create /home
> [sudo] password for nbecker:
> ERROR: '/home' exists
>
> --
> Those who fail to understand recursion are doomed to repeat it
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [newb] move /home to subvolume
  2015-06-01 12:57 ` Vytautas D
@ 2015-06-01 13:03   ` Neal Becker
  2015-06-01 13:57     ` Justus Seifert
  2015-06-01 14:09     ` Austin S Hemmelgarn
  0 siblings, 2 replies; 8+ messages in thread
From: Neal Becker @ 2015-06-01 13:03 UTC (permalink / raw)
  To: linux-btrfs

So I think what I need to do is:

1. boot off some rescue media
2. mount the target btrfs volume (e.g., /mnt/sysimage/root)
3. mv exising home (mv /mnt/sysimage/home /mnt/sysimage/oldhome)
4. create new subvolume (btrfs subvolume create /mnt/sysimage/home)
5. move all the files from /mnt/sysimage/oldhome /mnt/sysimage/home - not 
sure easiest way to do this step
6. edit /mnt/sysimage/etc/fstab to mount new /home

I have another machine, setup more or less this way:
UUID=7246327b-1905-4fe2-9b6b-b9376017264f /                       btrfs   
subvolid=5,subvol=root00 0 0
UUID=2c04be93-34c1-4016-ba41-60fd9fd90616 /boot                   ext4    
defaults        1 2
UUID=7246327b-1905-4fe2-9b6b-b9376017264f /home                   btrfs   
subvol=home     0 0



Vytautas D wrote:

> as far as I know, you can't do this, you need to temporary move /home
> somewhere else, create /home subvolume and copy everything back.
> 
> -
> Vytas
> 
> On Mon, Jun 1, 2015 at 1:36 PM, Neal Becker <ndbecker2@gmail.com> wrote:
>> I have everything under /:
>>
>> sudo btrfs subvolume list /
>> ID 257 gen 65795 top level 5 path root
>>
>> I want to move /home onto it's own subvolume.  I hope I can do this while
>> the root device is mounted.
>>
>> What is the procedure?
>>
>> I tried first to create a subvolume for /home at the top-level, but
>> couldn't figure out the syntax:
>>
>> [nbecker@nbecker2 ~]$ sudo btrfs subvolume create /home
>> [sudo] password for nbecker:
>> ERROR: '/home' exists
>>
>> --
>> Those who fail to understand recursion are doomed to repeat it
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Those who fail to understand recursion are doomed to repeat it


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

* Re: [newb] move /home to subvolume
  2015-06-01 13:03   ` Neal Becker
@ 2015-06-01 13:57     ` Justus Seifert
  2015-06-01 14:09     ` Austin S Hemmelgarn
  1 sibling, 0 replies; 8+ messages in thread
From: Justus Seifert @ 2015-06-01 13:57 UTC (permalink / raw)
  To: Neal Becker, linux-btrfs


[-- Attachment #1.1: Type: text/plain, Size: 1827 bytes --]

On 01.06.2015 15:03, Neal Becker wrote:
> So I think what I need to do is:
> 
> 1. boot off some rescue media
> 2. mount the target btrfs volume (e.g., /mnt/sysimage/root)
> 3. mv exising home (mv /mnt/sysimage/home /mnt/sysimage/oldhome)
> 4. create new subvolume (btrfs subvolume create /mnt/sysimage/home)
> 5. move all the files from /mnt/sysimage/oldhome /mnt/sysimage/home - not 
> sure easiest way to do this step
> 6. edit /mnt/sysimage/etc/fstab to mount new /home
> 
> I have another machine, setup more or less this way:
> UUID=7246327b-1905-4fe2-9b6b-b9376017264f /                       btrfs   
> subvolid=5,subvol=root00 0 0
> UUID=2c04be93-34c1-4016-ba41-60fd9fd90616 /boot                   ext4    
> defaults        1 2
> UUID=7246327b-1905-4fe2-9b6b-b9376017264f /home                   btrfs   
> subvol=home     0 0
> 
> 
> 
> Vytautas D wrote:
> 
>> as far as I know, you can't do this, you need to temporary move /home
>> somewhere else, create /home subvolume and copy everything back.
>>
>> -
>> Vytas
>>
>> On Mon, Jun 1, 2015 at 1:36 PM, Neal Becker <ndbecker2@gmail.com> wrote:
>>> I have everything under /:
>>>
>>> sudo btrfs subvolume list /
>>> ID 257 gen 65795 top level 5 path root
>>>
>>> I want to move /home onto it's own subvolume.  I hope I can do this while
>>> the root device is mounted.
>>>
>>> What is the procedure?
>>>
>>> I tried first to create a subvolume for /home at the top-level, but
>>> couldn't figure out the syntax:
>>>
>>> [nbecker@nbecker2 ~]$ sudo btrfs subvolume create /home
>>> [sudo] password for nbecker:
>>> ERROR: '/home' exists
>>>


i think you can speed up step 5 there by not using mv but cp
--reflink=auto and deleting the old copy once you are done.  reflinks
are shared between subvolumes.

justus

[-- Attachment #1.2: justus_seifert.vcf --]
[-- Type: text/x-vcard, Size: 181 bytes --]

begin:vcard
fn:Justus Seifert
n:Seifert;Justus
adr:;;;Dresden;Saxony;;Germany
email;internet:justus.seifert@dergleichrichter.de
x-mozilla-html:FALSE
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [newb] move /home to subvolume
  2015-06-01 13:03   ` Neal Becker
  2015-06-01 13:57     ` Justus Seifert
@ 2015-06-01 14:09     ` Austin S Hemmelgarn
  1 sibling, 0 replies; 8+ messages in thread
From: Austin S Hemmelgarn @ 2015-06-01 14:09 UTC (permalink / raw)
  To: Neal Becker, linux-btrfs

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

On 2015-06-01 09:03, Neal Becker wrote:
> So I think what I need to do is:
>
> 1. boot off some rescue media
In theory, you may be able to boot do the equivalent of this from single 
user mode or by logging in as root, although it may be safer to do it 
from rescue media (just make sure the rescue media is relatively up to 
date).
> 2. mount the target btrfs volume (e.g., /mnt/sysimage/root)
> 3. mv exising home (mv /mnt/sysimage/home /mnt/sysimage/oldhome)
> 4. create new subvolume (btrfs subvolume create /mnt/sysimage/home)
> 5. move all the files from /mnt/sysimage/oldhome /mnt/sysimage/home - not
> sure easiest way to do this step
I would use either rsync (if you have a lot of free space available on 
the volume) or 'cp -va --reflink=always'.
> 6. edit /mnt/sysimage/etc/fstab to mount new /home
>
> I have another machine, setup more or less this way:
> UUID=7246327b-1905-4fe2-9b6b-b9376017264f /                       btrfs
> subvolid=5,subvol=root00 0 0
> UUID=2c04be93-34c1-4016-ba41-60fd9fd90616 /boot                   ext4
> defaults        1 2
> UUID=7246327b-1905-4fe2-9b6b-b9376017264f /home                   btrfs
> subvol=home     0 0



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 2967 bytes --]

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

* Re: [newb] move /home to subvolume
  2015-06-01 12:36 [newb] move /home to subvolume Neal Becker
  2015-06-01 12:57 ` Vytautas D
@ 2015-06-01 18:18 ` Chris Murphy
       [not found]   ` <CAG3t+pEHqATjGFUQrLn__O5-ByW4oX6MWjQiYh9GpgfqdKKiyg@mail.gmail.com>
  2015-06-01 23:03   ` Neal Becker
  1 sibling, 2 replies; 8+ messages in thread
From: Chris Murphy @ 2015-06-01 18:18 UTC (permalink / raw)
  To: Neal Becker; +Cc: Btrfs BTRFS

On Mon, Jun 1, 2015 at 6:36 AM, Neal Becker <ndbecker2@gmail.com> wrote:
> I have everything under /:
>
> sudo btrfs subvolume list /
> ID 257 gen 65795 top level 5 path root

root is a subvolume, but is not the top level (default) subvolume.
>
> I want to move /home onto it's own subvolume.  I hope I can do this while
> the root device is mounted.

Yes.

You need to mount the top level and create a new subvolume. Assuming
you haven't changed the default subvolume, just mount the device
normally:

mount /dev/sdaX /mnt
btrfs sub create /mnt/home
cp -a --reflink /mnt/root/home /mnt/
vi /etc/fstab ## to add an entry to mount subvol=home at /home
umount /home
mount /home

And then at your leisure you can blow away the contents of the copied
and no longer used /home directory still in the root subvolume. Just
be certain you're deleting the correct home. You could:
cd /mnt/root/home
rm -rf *     ## egads be certain

This is not a mount point, but the old home directory which is no
longer in use. The path to the in use one is /mnt/home as well as
/home (in the above example).



>
> What is the procedure?
>
> I tried first to create a subvolume for /home at the top-level, but couldn't
> figure out the syntax:
>
> [nbecker@nbecker2 ~]$ sudo btrfs subvolume create /home
> [sudo] password for nbecker:
> ERROR: '/home' exists


That doesn't work because you're trying to create a home subvolume
where a home directory exists. You need to mount the top level
subvolume to create a subvolume in it.


-- 
Chris Murphy

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

* Re: [newb] move /home to subvolume
       [not found]   ` <CAG3t+pEHqATjGFUQrLn__O5-ByW4oX6MWjQiYh9GpgfqdKKiyg@mail.gmail.com>
@ 2015-06-01 19:13     ` Chris Murphy
  0 siblings, 0 replies; 8+ messages in thread
From: Chris Murphy @ 2015-06-01 19:13 UTC (permalink / raw)
  To: Neal Becker; +Cc: Chris Murphy, Btrfs BTRFS

On Mon, Jun 1, 2015 at 12:52 PM, Neal Becker <ndbecker2@gmail.com> wrote:

> Let me just make sure I'm clear on this.  So I already have /dev/sdaX
> mounted as /.

Actually your fstab will show you have subvol=root mounted at /, not
the top level.

>You're saying I should mount it again as /mnt, and this
> procedure is OK while the filesystem is in use, correct?

Yes.

>
>>
>> btrfs sub create /mnt/home
>
>
> Well there is already a directory called /home, under / on this filesystem.

/ is a mount point. And the subvolume named root is what's mounted
there. If you mount the top level subvolume at /mnt then you will see
the root subvolume in /mnt/. And you will see your current home
directory in /mnt/root/home.


> Well, /home is not mounted.  There is right now just a single mount of /
>
>>
>> umount /home

OK so you can skip the umount part.


-- 
Chris Murphy

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

* Re: [newb] move /home to subvolume
  2015-06-01 18:18 ` Chris Murphy
       [not found]   ` <CAG3t+pEHqATjGFUQrLn__O5-ByW4oX6MWjQiYh9GpgfqdKKiyg@mail.gmail.com>
@ 2015-06-01 23:03   ` Neal Becker
  1 sibling, 0 replies; 8+ messages in thread
From: Neal Becker @ 2015-06-01 23:03 UTC (permalink / raw)
  To: linux-btrfs

Chris Murphy wrote:

> On Mon, Jun 1, 2015 at 6:36 AM, Neal Becker <ndbecker2@gmail.com> wrote:
>> I have everything under /:
>>
>> sudo btrfs subvolume list /
>> ID 257 gen 65795 top level 5 path root
> 
> root is a subvolume, but is not the top level (default) subvolume.
>>
>> I want to move /home onto it's own subvolume.  I hope I can do this while
>> the root device is mounted.
> 
> Yes.
> 
> You need to mount the top level and create a new subvolume. Assuming
> you haven't changed the default subvolume, just mount the device
> normally:
> 
> mount /dev/sdaX /mnt
> btrfs sub create /mnt/home
> cp -a --reflink /mnt/root/home /mnt/
> vi /etc/fstab ## to add an entry to mount subvol=home at /home
> umount /home
> mount /home
> 
> And then at your leisure you can blow away the contents of the copied
> and no longer used /home directory still in the root subvolume. Just
> be certain you're deleting the correct home. You could:
> cd /mnt/root/home
> rm -rf *     ## egads be certain
> 
> This is not a mount point, but the old home directory which is no
> longer in use. The path to the in use one is /mnt/home as well as
> /home (in the above example).
> 

Thanks, this all worked just fine.  Only thing I did differently, I needed 
to rename the old /home to /oldhome and mkdir /home for the new subvol 
mount, so that I now have /home and /oldhome and can, at my leisure, rm -rf 
oldhome (otherwise, mounting /home would have hidden the old /home and made 
it impossible to rm).


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

end of thread, other threads:[~2015-06-01 23:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01 12:36 [newb] move /home to subvolume Neal Becker
2015-06-01 12:57 ` Vytautas D
2015-06-01 13:03   ` Neal Becker
2015-06-01 13:57     ` Justus Seifert
2015-06-01 14:09     ` Austin S Hemmelgarn
2015-06-01 18:18 ` Chris Murphy
     [not found]   ` <CAG3t+pEHqATjGFUQrLn__O5-ByW4oX6MWjQiYh9GpgfqdKKiyg@mail.gmail.com>
2015-06-01 19:13     ` Chris Murphy
2015-06-01 23:03   ` Neal Becker

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.