Hello guys, I''m just using btrfs for the first time. I tried to create subvolumes before installing Ubuntu but the installer doesn''t give the opportunity to configure as we want. So it creates by default 2 subvolumes : @ for the root and @home for the home directories. So now, I wanted to delete the old subvolumes I created. I ran into problems: the Ubuntu installer set the default subvolume to @ (id=5). So when I try to delete my previous subvolumes it tells me it doesn''t find it ... Here are some output to be more concrete: root@my-tour:~# btrfs subv get-default / ID 5 (FS_TREE) root@my-tour:~# btrfs subv list / ID 258 gen 6 top level 5 path home ID 259 gen 7 top level 5 path tmp ID 260 gen 8 top level 5 path home-root ID 261 gen 9 top level 5 path logs ID 262 gen 138 top level 5 path @ ID 263 gen 139 top level 5 path @home root@my-tour:~# btrfs subv del tmp ERROR: error accessing ''tmp'' The only way I found to circumvent the problem was to mount the root volume (id=0) on /mnt with "-o subvolid=0" and then from there I''m able to delete anything. My questions are : - can I directly delete a subvolume with its ID? (so I don''t have to mount the id 0 to do it) - or is there a way to specify the path starting not from the default volume but forcing to start from id 0? Something like "btrfs subv del 0/tmp" (I tried, it doesn''t work ;) Thank you, -- Nicolas MICHEL -- 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
On Dec 16, 2013, at 4:20 PM, Nicolas Michel <be.nicolas.michel@gmail.com> wrote:> > So now, I wanted to delete the old subvolumes I created. I ran into > problems: the Ubuntu installer set the default subvolume to @ (id=5).This is normal. id=0 maps to id=5> So when I try to delete my previous subvolumes it tells me it doesn''t > find it ... Here are some output to be more concrete: > > root@my-tour:~# btrfs subv get-default / > ID 5 (FS_TREE) > root@my-tour:~# btrfs subv list / > ID 258 gen 6 top level 5 path home > ID 259 gen 7 top level 5 path tmp > ID 260 gen 8 top level 5 path home-root > ID 261 gen 9 top level 5 path logs > ID 262 gen 138 top level 5 path @ > ID 263 gen 139 top level 5 path @home > root@my-tour:~# btrfs subv del tmp > ERROR: error accessing ''tmp''This is because / is subvol=@, so your delete request is in effect asking to delete subvolume /@/tmp which doesn''t exist. To access tmp, the top level default subvolume needs to be mounted.> > The only way I found to circumvent the problem was to mount the root > volume (id=0) on /mnt with "-o subvolid=0" and then from there I''m > able to delete anything.So long as nothing has used set-default to change it from the default of 0/5, you don''t need to specify the subvol or subvolid mount option. You can just mount /dev/sdXY /mnt and that will mount the default subvolume.> My questions are : > - can I directly delete a subvolume with its ID? (so I don''t have to > mount the id 0 to do it)> - or is there a way to specify the path starting not from the default > volume but forcing to start from id 0? Something like "btrfs subv del > 0/tmp" (I tried, it doesn''t work ;)They are separate fs trees, so you can see them as separate fs''s and ones above aren''t accessible from below. So a subvol above the subvol you want to delete needs to be mounted. Chris Murphy-- 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
OK. thanks for your pretty fast answer :) Now my last question is: in this case it was "easy" as I know that I created all these subvolumes as parts of volume 0. But in the btrfs subv list / I don''t see any information that tells me they belongs to id 0. If I have to debug a server/desktop and I don''t know the hierarchy that has been made, how can I know that my tmp subvolume is indeed a child of id 0 ? 2013/12/17 Chris Murphy <lists@colorremedies.com>:> > On Dec 16, 2013, at 4:20 PM, Nicolas Michel <be.nicolas.michel@gmail.com> wrote: > >> >> So now, I wanted to delete the old subvolumes I created. I ran into >> problems: the Ubuntu installer set the default subvolume to @ (id=5). > > This is normal. id=0 maps to id=5 > > > >> So when I try to delete my previous subvolumes it tells me it doesn''t >> find it ... Here are some output to be more concrete: >> >> root@my-tour:~# btrfs subv get-default / >> ID 5 (FS_TREE) >> root@my-tour:~# btrfs subv list / >> ID 258 gen 6 top level 5 path home >> ID 259 gen 7 top level 5 path tmp >> ID 260 gen 8 top level 5 path home-root >> ID 261 gen 9 top level 5 path logs >> ID 262 gen 138 top level 5 path @ >> ID 263 gen 139 top level 5 path @home >> root@my-tour:~# btrfs subv del tmp >> ERROR: error accessing ''tmp'' > > This is because / is subvol=@, so your delete request is in effect asking to delete subvolume /@/tmp which doesn''t exist. To access tmp, the top level default subvolume needs to be mounted. > >> >> The only way I found to circumvent the problem was to mount the root >> volume (id=0) on /mnt with "-o subvolid=0" and then from there I''m >> able to delete anything. > > So long as nothing has used set-default to change it from the default of 0/5, you don''t need to specify the subvol or subvolid mount option. You can just mount /dev/sdXY /mnt and that will mount the default subvolume. > > >> My questions are : >> - can I directly delete a subvolume with its ID? (so I don''t have to >> mount the id 0 to do it) > >> - or is there a way to specify the path starting not from the default >> volume but forcing to start from id 0? Something like "btrfs subv del >> 0/tmp" (I tried, it doesn''t work ;) > > They are separate fs trees, so you can see them as separate fs''s and ones above aren''t accessible from below. So a subvol above the subvol you want to delete needs to be mounted. > > Chris Murphy-- Nicolas MICHEL -- 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
On Dec 16, 2013, at 4:54 PM, Nicolas Michel <be.nicolas.michel@gmail.com> wrote:> OK. thanks for your pretty fast answer :) > > Now my last question is: in this case it was "easy" as I know that I > created all these subvolumes as parts of volume 0. But in the btrfs > subv list / I don''t see any information that tells me they belongs to > id 0. If I have to debug a server/desktop and I don''t know the > hierarchy that has been made, how can I know that my tmp subvolume is > indeed a child of id 0 ?When you do a subvol list it shows you what its top level is. Example: # btrfs subvol list / ID 256 gen 1047 top level 5 path root ID 258 gen 983 top level 5 path home ID 259 gen 983 top level 5 path data ID 276 gen 1012 top level 5 path root_ro root is mounted at / home is mounted at /hoome data is mounted at /data root_ro is not mounted at all #cd /data # btrfs subvol create data2 Create subvolume ''./data2'' # btrfs subvol list / ID 256 gen 1047 top level 5 path root ID 258 gen 983 top level 5 path home ID 259 gen 1048 top level 5 path data ID 276 gen 1012 top level 5 path root_ro ID 277 gen 1048 top level 5 path data/data2 # btrfs subvol list /data ID 256 gen 1047 top level 5 path root ID 258 gen 983 top level 5 path home ID 259 gen 1048 top level 5 path data ID 276 gen 1012 top level 5 path root_ro ID 277 gen 1048 top level 259 path data2 So notice that "top level 5 data/data2" means the same as "top level 259 data2" because top level 259 implies data. You can also use btrfs subvol show <subvol> and it will give you more information including whether it''s a snapshot, what the parent is; and if it''s a parent that has snapshots it''ll list the snapshots. # btrfs subvol show /data /data Name: data uuid: bc45f4be-51c9-2848-bb68-d6e922b8e2bd Parent uuid: - Creation time: 2013-12-12 16:18:13 Object ID: 259 Generation (Gen): 1048 Gen at creation: 11 Parent: 5 Top Level: 5 Flags: - Snapshot(s): # btrfs subvol show /data/data2 /data/data2 Name: data2 uuid: a66eddf9-107f-0448-a021-da417a982827 Parent uuid: - Creation time: 2013-12-16 17:11:36 Object ID: 277 Generation (Gen): 1048 Gen at creation: 1048 Parent: 259 Top Level: 259 Flags: - Snapshot(s): Chris Murphy -- 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
Mhmm. Thanks. I''m begining to understand ;) Still : how can I see/know that id 5 is mapped to id 0 ? And why doing this? For what purpose? (is it a default btrfs behavior or is it set by the Ubuntu installer?) 2013/12/17 Chris Murphy <lists@colorremedies.com>:> > On Dec 16, 2013, at 4:54 PM, Nicolas Michel <be.nicolas.michel@gmail.com> wrote: > >> OK. thanks for your pretty fast answer :) >> >> Now my last question is: in this case it was "easy" as I know that I >> created all these subvolumes as parts of volume 0. But in the btrfs >> subv list / I don''t see any information that tells me they belongs to >> id 0. If I have to debug a server/desktop and I don''t know the >> hierarchy that has been made, how can I know that my tmp subvolume is >> indeed a child of id 0 ? > > When you do a subvol list it shows you what its top level is. Example: > > > > # btrfs subvol list / > ID 256 gen 1047 top level 5 path root > ID 258 gen 983 top level 5 path home > ID 259 gen 983 top level 5 path data > ID 276 gen 1012 top level 5 path root_ro > > > root is mounted at / > home is mounted at /hoome > data is mounted at /data > root_ro is not mounted at all > > > #cd /data > # btrfs subvol create data2 > Create subvolume ''./data2'' > # btrfs subvol list / > ID 256 gen 1047 top level 5 path root > ID 258 gen 983 top level 5 path home > ID 259 gen 1048 top level 5 path data > ID 276 gen 1012 top level 5 path root_ro > ID 277 gen 1048 top level 5 path data/data2 > > # btrfs subvol list /data > ID 256 gen 1047 top level 5 path root > ID 258 gen 983 top level 5 path home > ID 259 gen 1048 top level 5 path data > ID 276 gen 1012 top level 5 path root_ro > ID 277 gen 1048 top level 259 path data2 > > > So notice that "top level 5 data/data2" means the same as "top level 259 data2" because top level 259 implies data. > > You can also use btrfs subvol show <subvol> and it will give you more information including whether it''s a snapshot, what the parent is; and if it''s a parent that has snapshots it''ll list the snapshots. > > # btrfs subvol show /data > /data > Name: data > uuid: bc45f4be-51c9-2848-bb68-d6e922b8e2bd > Parent uuid: - > Creation time: 2013-12-12 16:18:13 > Object ID: 259 > Generation (Gen): 1048 > Gen at creation: 11 > Parent: 5 > Top Level: 5 > Flags: - > Snapshot(s): > # btrfs subvol show /data/data2 > /data/data2 > Name: data2 > uuid: a66eddf9-107f-0448-a021-da417a982827 > Parent uuid: - > Creation time: 2013-12-16 17:11:36 > Object ID: 277 > Generation (Gen): 1048 > Gen at creation: 1048 > Parent: 259 > Top Level: 259 > Flags: - > Snapshot(s): > > > > Chris Murphy >-- Nicolas MICHEL -- 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
On Tue, Dec 17, 2013 at 09:30:11AM +0100, Nicolas Michel wrote:> Mhmm. Thanks. I''m begining to understand ;) > Still : how can I see/know that id 5 is mapped to id 0 ? And why doing > this? For what purpose? (is it a default btrfs behavior or is it set > by the Ubuntu installer?)It''s always mapped. Internally, every tree is identified by a number. FS trees (e.g. subvolumes) start with numbers allocated dynamically from 256 upwards. Other trees (chunk tree, extent tree, and all the others) have fixed "well-known" numbers between 1 and 255, and the top-level FS tree is given the number 5. To make things marginally simpler for the user to remember, there''s special-case code which looks at subvolume IDs passed from userspace, and converts 0 to 5. This is all btrfs behaviour -- nothing to do with Ubuntu. Hugo.> 2013/12/17 Chris Murphy <lists@colorremedies.com>: > > > > On Dec 16, 2013, at 4:54 PM, Nicolas Michel <be.nicolas.michel@gmail.com> wrote: > > > >> OK. thanks for your pretty fast answer :) > >> > >> Now my last question is: in this case it was "easy" as I know that I > >> created all these subvolumes as parts of volume 0. But in the btrfs > >> subv list / I don''t see any information that tells me they belongs to > >> id 0. If I have to debug a server/desktop and I don''t know the > >> hierarchy that has been made, how can I know that my tmp subvolume is > >> indeed a child of id 0 ? > > > > When you do a subvol list it shows you what its top level is. Example: > > > > > > > > # btrfs subvol list / > > ID 256 gen 1047 top level 5 path root > > ID 258 gen 983 top level 5 path home > > ID 259 gen 983 top level 5 path data > > ID 276 gen 1012 top level 5 path root_ro > > > > > > root is mounted at / > > home is mounted at /hoome > > data is mounted at /data > > root_ro is not mounted at all > > > > > > #cd /data > > # btrfs subvol create data2 > > Create subvolume ''./data2'' > > # btrfs subvol list / > > ID 256 gen 1047 top level 5 path root > > ID 258 gen 983 top level 5 path home > > ID 259 gen 1048 top level 5 path data > > ID 276 gen 1012 top level 5 path root_ro > > ID 277 gen 1048 top level 5 path data/data2 > > > > # btrfs subvol list /data > > ID 256 gen 1047 top level 5 path root > > ID 258 gen 983 top level 5 path home > > ID 259 gen 1048 top level 5 path data > > ID 276 gen 1012 top level 5 path root_ro > > ID 277 gen 1048 top level 259 path data2 > > > > > > So notice that "top level 5 data/data2" means the same as "top level 259 data2" because top level 259 implies data. > > > > You can also use btrfs subvol show <subvol> and it will give you more information including whether it''s a snapshot, what the parent is; and if it''s a parent that has snapshots it''ll list the snapshots. > > > > # btrfs subvol show /data > > /data > > Name: data > > uuid: bc45f4be-51c9-2848-bb68-d6e922b8e2bd > > Parent uuid: - > > Creation time: 2013-12-12 16:18:13 > > Object ID: 259 > > Generation (Gen): 1048 > > Gen at creation: 11 > > Parent: 5 > > Top Level: 5 > > Flags: - > > Snapshot(s): > > # btrfs subvol show /data/data2 > > /data/data2 > > Name: data2 > > uuid: a66eddf9-107f-0448-a021-da417a982827 > > Parent uuid: - > > Creation time: 2013-12-16 17:11:36 > > Object ID: 277 > > Generation (Gen): 1048 > > Gen at creation: 1048 > > Parent: 259 > > Top Level: 259 > > Flags: - > > Snapshot(s): > > > > > > > > Chris Murphy > > > > >-- === Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk == PGP key: 65E74AC0 from wwwkeys.eu.pgp.net or http://www.carfax.org.uk --- You can''t expect a boy to be depraved until he''s gone to --- a good school.