move /home to subvolume
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
Signature · 1 line
Those who fail to understand recursion are doomed to repeat it
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
Quoted 24 lines · Neal Becker
I have everything under /:
sudo btrfs subvolume list /
ID 257 gen 65795 top level 5 path rootI 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
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
Quoted 35 lines · Vytautas D
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.
-
VytasQuoted 17 lines · Neal Becker
I have everything under /:
sudo btrfs subvolume list /
ID 257 gen 65795 top level 5 path rootI 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' existsQuoted 7 lines
--
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 [email protected]
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Those who fail to understand recursion are doomed to repeat it
Quoted 20 lines · Neal Becker
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/fstabto mount new /homeI 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
Quoted 26 lines
Quoted 24 lines · Vytautas D
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.
-
VytasQuoted 17 lines · Neal Becker
I have everything under /:
sudo btrfs subvolume list /
ID 257 gen 65795 top level 5 path rootI 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
begin:vcard
fn:Justus Seifert
n:Seifert;Justus
adr:;;;Dresden;Saxony;;Germany
email;internet:[email protected]
x-mozilla-html:FALSE
version:2.1
end:vcard
Quoted 3 lines · Neal Becker
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).
Quoted 5 lines
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'.
Quoted 9 lines
6. edit
/mnt/sysimage/etc/fstabto mount new /homeI 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
Quoted 4 lines · Neal Becker
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.
Quoted 3 lines
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).
Quoted 9 lines
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.
Signature · 1 line
Chris Murphy
Quoted 2 lines · Neal Becker
Let me just make sure I'm clear on this. So I already have
/dev/sdaXmounted as /.
Actually your fstab will show you have subvol=root mounted at /, not the top level.
Quoted 2 lines
You're saying I should mount it again as /mnt, and this procedure is OK while the filesystem is in use, correct?
Yes.
Quoted 6 lines
Quoted 3 lines
btrfs sub create
/mnt/homeWell 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.
Quoted 4 lines
Well, /home is not mounted. There is right now just a single mount of /
Quoted 2 lines
umount /home
OK so you can skip the umount part.
Signature · 1 line
Chris Murphy
Quoted 30 lines · Chris Murphy
Quoted 4 lines · Neal Becker
I have everything under /:
sudo btrfs subvolume list /
ID 257 gen 65795 top level 5 path rootroot is a subvolume, but is not the top level (default) subvolume.
Quoted 3 lines
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 /homeAnd 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
Quoted 4 lines
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/homeas 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).