* Odd mkbtrfs behavior inside of chroot
@ 2011-01-02 19:52 J G
2011-01-02 21:06 ` Jérôme Poulin
2011-01-02 23:14 ` Goffredo Baroncelli
0 siblings, 2 replies; 6+ messages in thread
From: J G @ 2011-01-02 19:52 UTC (permalink / raw)
To: linux-btrfs
I just encountered some odd behavior from mkbtrfs.
The end goal is to restore a backup to newly created BTRFS partitions while using the latest btrfs-tools.
Here's the steps to what I did:
* Booted SystemRescueCD
* Partitioned the drives (two 750GB drives with 12 partitions each)
* Created an extra partition on sda as a temporary holding place for the backed up files and so I can update btrfs-tools
* Formatted/mounted/restored backup files to the temporary partition which I mounted on /mnt/backup
* mount -t proc none /mnt/backup/proc; mount -o bind /dev /mnt/backup/dev
* chroot /mnt/backup /bin/bash
* Updated btrfs-tools to the latest git pull from today (v0.19-35-g1b444cd-dirty).
* mkbtrfs /dev/sda5 /dev/sdb5 -L root
mkbtrfs returned with:
error checking /dev/sda5 mount status
So I used strace to find out how it was checking for the mount status. Now, I'm no expert here, but I'm confused as to just why it failed. The last thing of note:
lstat("/boot", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/boot/sysrcd.dat", 0x7fffb29681e0) = -1 ENOENT (No such file or directory)
close(3) = 0
munmap(0x7f11df372000, 4096) = 0
write(2, "error checking /dev/sda5 mount s"..., 38error checking /dev/sda5 mount status
) = 38
doesn't explain much. I see that it's checking /proc/mounts to see what's mounted, and then it fails on stating /boot/sysrcd.dat (which doesn't exist in the non-chrooted FS, btw).
To make this even weirder, if I format sda5/sdb5 using the SysRescCD version of mkbtrfs (v0.19) and then format sda5/sdb5 using the chroot version, it works fine.
Any ideas here? I would expect that mkbtrfs would work inside of a chroot without any assistance from the original root.
I have the full strace from the chrooted mkbtrfs failing and from it succeeding, if that's helpful.
.:Justin:.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Odd mkbtrfs behavior inside of chroot
2011-01-02 19:52 Odd mkbtrfs behavior inside of chroot J G
@ 2011-01-02 21:06 ` Jérôme Poulin
2011-01-04 23:12 ` J G
2011-01-02 23:14 ` Goffredo Baroncelli
1 sibling, 1 reply; 6+ messages in thread
From: Jérôme Poulin @ 2011-01-02 21:06 UTC (permalink / raw)
To: J G; +Cc: linux-btrfs@vger.kernel.org
Did you try using -o bind on /proc and /sys as well? Just in case mkfs
uses /sys too, I'm not sure if /proc reacts differently to multiple
mounts or bind neither?
Envoy=E9 de mon appareil mobile.
J=E9r=F4me Poulin
Solutions G.A.
On 2011-01-02, at 14:53, J G <yoosty_cmn@yahoo.com> wrote:
> I just encountered some odd behavior from mkbtrfs.
> The end goal is to restore a backup to newly created BTRFS partitions=
while using the latest btrfs-tools.
> Here's the steps to what I did:
> * Booted SystemRescueCD
> * Partitioned the drives (two 750GB drives with 12 partitions each)
> * Created an extra partition on sda as a temporary holding place for =
the backed up files and so I can update btrfs-tools
> * Formatted/mounted/restored backup files to the temporary partition =
which I mounted on /mnt/backup
> * mount -t proc none /mnt/backup/proc; mount -o bind /dev /mnt/backup=
/dev
> * chroot /mnt/backup /bin/bash
> * Updated btrfs-tools to the latest git pull from today (v0.19-35-g1b=
444cd-dirty).
> * mkbtrfs /dev/sda5 /dev/sdb5 -L root
>
> mkbtrfs returned with:
>
> error checking /dev/sda5 mount status
>
> So I used strace to find out how it was checking for the mount status=
=2E Now, I'm no expert here, but I'm confused as to just why it failed.=
The last thing of note:
>
> lstat("/boot", {st_mode=3DS_IFDIR|0755, st_size=3D4096, ...}) =3D 0
> lstat("/boot/sysrcd.dat", 0x7fffb29681e0) =3D -1 ENOENT (No such file=
or directory)
> close(3) =3D 0
> munmap(0x7f11df372000, 4096) =3D 0
> write(2, "error checking /dev/sda5 mount s"..., 38error checking /dev=
/sda5 mount status
> ) =3D 38
>
>
> doesn't explain much. I see that it's checking /proc/mounts to see wh=
at's mounted, and then it fails on stating /boot/sysrcd.dat (which does=
n't exist in the non-chrooted FS, btw).
>
> To make this even weirder, if I format sda5/sdb5 using the SysRescCD =
version of mkbtrfs (v0.19) and then format sda5/sdb5 using the chroot v=
ersion, it works fine.
>
> Any ideas here? I would expect that mkbtrfs would work inside of a ch=
root without any assistance from the original root.
>
> I have the full strace from the chrooted mkbtrfs failing and from it =
succeeding, if that's helpful.
>
>
> .:Justin:.
>
>
>
> --
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Odd mkbtrfs behavior inside of chroot
2011-01-02 19:52 Odd mkbtrfs behavior inside of chroot J G
2011-01-02 21:06 ` Jérôme Poulin
@ 2011-01-02 23:14 ` Goffredo Baroncelli
2011-01-03 19:05 ` [PATCH] add a --force option to mkfs.btrf [was Re: Odd mkbtrfs behavior inside of chroot] Goffredo Baroncelli
2011-01-04 23:16 ` Odd mkbtrfs behavior inside of chroot J G
1 sibling, 2 replies; 6+ messages in thread
From: Goffredo Baroncelli @ 2011-01-02 23:14 UTC (permalink / raw)
To: J G; +Cc: linux-btrfs
On 01/02/2011 08:52 PM, J G wrote:
> I just encountered some odd behavior from mkbtrfs.
> The end goal is to restore a backup to newly created BTRFS partitions while using the latest btrfs-tools.
> Here's the steps to what I did:
> * Booted SystemRescueCD
> * Partitioned the drives (two 750GB drives with 12 partitions each)
> * Created an extra partition on sda as a temporary holding place for the backed up files and so I can update btrfs-tools
> * Formatted/mounted/restored backup files to the temporary partition which I mounted on /mnt/backup
> * mount -t proc none /mnt/backup/proc; mount -o bind /dev /mnt/backup/dev
> * chroot /mnt/backup /bin/bash
> * Updated btrfs-tools to the latest git pull from today (v0.19-35-g1b444cd-dirty).
> * mkbtrfs /dev/sda5 /dev/sdb5 -L root
>
> mkbtrfs returned with:
>
> error checking /dev/sda5 mount status
>
> So I used strace to find out how it was checking for the mount status. Now, I'm no expert here, but I'm confused as to just why it failed. The last thing of note:
>
> lstat("/boot", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
> lstat("/boot/sysrcd.dat", 0x7fffb29681e0) = -1 ENOENT (No such file or directory)
> close(3) = 0
> munmap(0x7f11df372000, 4096) = 0
> write(2, "error checking /dev/sda5 mount s"..., 38error checking /dev/sda5 mount status
> ) = 38
>
>
> doesn't explain much. I see that it's checking /proc/mounts to see what's mounted, and then it fails on stating /boot/sysrcd.dat (which doesn't exist in the non-chrooted FS, btw).
>
> To make this even weirder, if I format sda5/sdb5 using the SysRescCD version of mkbtrfs (v0.19) and then format sda5/sdb5 using the chroot version, it works fine.
>
> Any ideas here? I would expect that mkbtrfs would work inside of a chroot without any assistance from the original root.
>
> I have the full strace from the chrooted mkbtrfs failing and from it succeeding, if that's helpful.
On the basis of the provided information, and on the code it seems that
mkfs.btrfs tries hard to check that the user is not formatting a mounted
disk (or loop). So mkfs.btrfs scan the /proc/mount file and checks every
devices. To do the check it needs to access the original file if this is
a "loop backend". This is reasonable.
In this case in a chroot-ed environment the loop file is not accessible.
If you need a [dirty] "quick hack" to by-pass the problem (not tested):
- unmount the proc filesystem
- create an empty file /proc/mounts
- run btrfs.fsck
- mount the proc filesystem (removing the fake mounts file)
- perform a "btrfs device scan"
- mount the filesystem
Of course the "right" solution is to add a "--force" switch which
permits to by-pass these checks. Other mkfs.* tools have this switch.
>From the mkfs.ext4 man page:
[...]
-F Force mke2fs to create a filesystem,
even if the specified device is not
a partition on a block special
device, or if other parameters do
not make sense. In order to force
mke2fs to create a filesystem even
if the filesystem appears to be in
use or is mounted (a truly dangerous
thing to do), this option must be
specified twice.
[...]
>
> .:Justin:.
>
>
>
> --
> 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] 6+ messages in thread
* [PATCH] add a --force option to mkfs.btrf [was Re: Odd mkbtrfs behavior inside of chroot]
2011-01-02 23:14 ` Goffredo Baroncelli
@ 2011-01-03 19:05 ` Goffredo Baroncelli
2011-01-04 23:16 ` Odd mkbtrfs behavior inside of chroot J G
1 sibling, 0 replies; 6+ messages in thread
From: Goffredo Baroncelli @ 2011-01-03 19:05 UTC (permalink / raw)
To: linux-btrfs; +Cc: J G
[-- Attachment #1: Type: text/plain, Size: 4900 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all and happy new year.
this is my first patch of the new year. Hooping that this is a good
sign. :-)
The enclosed patch try to address the problem raised by Justin: how
circumvent the check performed by mkfs.btrfs ?
I add a "-f|--force" switch which permits to bypass the check if a
device is already mounted. I update the man page too.
You can pull the change from
http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git
branch
force-mkfs
commit (2900a150cde604f82f1437c931792bfa59c4780b)
Comments are welcome
Regards
G.Baroncelli
- --
gpg key: Goffredo Baroncelli (ghigo) <kreijack@inwind.it>
Key fingerprint = 4769 7E51 5293 D36C 814E C054 BF04 F161 3DC5 0512
On 01/03/2011 12:14 AM, Goffredo Baroncelli wrote:
> On 01/02/2011 08:52 PM, J G wrote:
>> I just encountered some odd behavior from mkbtrfs.
>> The end goal is to restore a backup to newly created BTRFS partitions while using the latest btrfs-tools.
>> Here's the steps to what I did:
>> * Booted SystemRescueCD
>> * Partitioned the drives (two 750GB drives with 12 partitions each)
>> * Created an extra partition on sda as a temporary holding place for the backed up files and so I can update btrfs-tools
>> * Formatted/mounted/restored backup files to the temporary partition which I mounted on /mnt/backup
>> * mount -t proc none /mnt/backup/proc; mount -o bind /dev /mnt/backup/dev
>> * chroot /mnt/backup /bin/bash
>> * Updated btrfs-tools to the latest git pull from today (v0.19-35-g1b444cd-dirty).
>> * mkbtrfs /dev/sda5 /dev/sdb5 -L root
>>
>> mkbtrfs returned with:
>>
>> error checking /dev/sda5 mount status
>>
>> So I used strace to find out how it was checking for the mount status. Now, I'm no expert here, but I'm confused as to just why it failed. The last thing of note:
>>
>> lstat("/boot", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
>> lstat("/boot/sysrcd.dat", 0x7fffb29681e0) = -1 ENOENT (No such file or directory)
>> close(3) = 0
>> munmap(0x7f11df372000, 4096) = 0
>> write(2, "error checking /dev/sda5 mount s"..., 38error checking /dev/sda5 mount status
>> ) = 38
>>
>>
>> doesn't explain much. I see that it's checking /proc/mounts to see what's mounted, and then it fails on stating /boot/sysrcd.dat (which doesn't exist in the non-chrooted FS, btw).
>>
>> To make this even weirder, if I format sda5/sdb5 using the SysRescCD version of mkbtrfs (v0.19) and then format sda5/sdb5 using the chroot version, it works fine.
>>
>> Any ideas here? I would expect that mkbtrfs would work inside of a chroot without any assistance from the original root.
>>
>> I have the full strace from the chrooted mkbtrfs failing and from it succeeding, if that's helpful.
>
> On the basis of the provided information, and on the code it seems that
> mkfs.btrfs tries hard to check that the user is not formatting a mounted
> disk (or loop). So mkfs.btrfs scan the /proc/mount file and checks every
> devices. To do the check it needs to access the original file if this is
> a "loop backend". This is reasonable.
>
> In this case in a chroot-ed environment the loop file is not accessible.
>
> If you need a [dirty] "quick hack" to by-pass the problem (not tested):
> - unmount the proc filesystem
> - create an empty file /proc/mounts
> - run btrfs.fsck
> - mount the proc filesystem (removing the fake mounts file)
> - perform a "btrfs device scan"
> - mount the filesystem
>
> Of course the "right" solution is to add a "--force" switch which
> permits to by-pass these checks. Other mkfs.* tools have this switch.
>
>>From the mkfs.ext4 man page:
> [...]
> -F Force mke2fs to create a filesystem,
> even if the specified device is not
> a partition on a block special
> device, or if other parameters do
> not make sense. In order to force
> mke2fs to create a filesystem even
> if the filesystem appears to be in
> use or is mounted (a truly dangerous
> thing to do), this option must be
> specified twice.
>
> [...]
>
>
>>
>> .:Justin:.
>>
>>
>>
>> --
>> 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
> .
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFNIh34vwTxYT3FBRIRAl1tAJ9k1LVUfahdlvLvK7b4gct55fom3QCfd1Ab
0JfVbWgKf7DXd0Gg1YzaPdU=
=Jt+e
-----END PGP SIGNATURE-----
[-- Attachment #2: mkfs.btrfs-force.diff --]
[-- Type: text/x-patch, Size: 3788 bytes --]
diff --git a/man/mkfs.btrfs.8.in b/man/mkfs.btrfs.8.in
index 1e14c6c..f51291c 100644
--- a/man/mkfs.btrfs.8.in
+++ b/man/mkfs.btrfs.8.in
@@ -5,14 +5,14 @@ mkfs.btrfs \- create an btrfs filesystem
.B mkfs.btrfs
[ \fB\-A\fP\fI alloc-start\fP ]
[ \fB\-b\fP\fI byte-count\fP ]
-[ \fB \-d\fP\fI data-profile\fP ]
-[ \fB \-l\fP\fI leafsize\fP ]
-[ \fB \-L\fP\fI label\fP ]
-[ \fB \-m\fP\fI metadata profile\fP ]
-[ \fB \-n\fP\fI nodesize\fP ]
-[ \fB \-s\fP\fI sectorsize\fP ]
-[ \fB \-h\fP ]
-[ \fB \-V\fP ] \fI device\fP [ \fI device ...\fP ]
+[ \fB\-d\fP\fI data-profile\fP ]
+[ \fB\-f\fP ]
+[ \fB\-l\fP\fI leafsize\fP ]
+[ \fB\-L\fP\fI label\fP ]
+[ \fB\-m\fP\fI metadata profile\fP ]
+[ \fB\-n\fP\fI nodesize\fP ]
+[ \fB\-s\fP\fI sectorsize\fP ]
+[ \fB\-V\fP ] \fIdevice\fP [ \fIdevice ...\fP ]
.SH DESCRIPTION
.B mkfs.btrfs
is used to create an btrfs filesystem (usually in a disk partition, or an array
@@ -34,6 +34,9 @@ mkfs.btrfs uses all the available storage for the filesystem.
Specify how the data must be spanned across the devices specified. Valid
values are raid0, raid1, raid10 or single.
.TP
+\fB\-f\fR, \fB\-\-force \fR
+Don't check if the device is already mounted.
+.TP
\fB\-l\fR, \fB\-\-leafsize \fIsize\fR
Specify the leaf size, the least data item in which btrfs stores data. The
default value is the page size.
diff --git a/mkfs.c b/mkfs.c
index 2e99b95..21bcc7a 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -271,6 +271,7 @@ static void print_usage(void)
fprintf(stderr, "\t -A --alloc-start the offset to start the FS\n");
fprintf(stderr, "\t -b --byte-count total number of bytes in the FS\n");
fprintf(stderr, "\t -d --data data profile, raid0, raid1, raid10 or single\n");
+ fprintf(stderr, "\t -f --force don't check if a device is already mounted\n");
fprintf(stderr, "\t -l --leafsize size of btree leaves\n");
fprintf(stderr, "\t -L --label set a label\n");
fprintf(stderr, "\t -m --metadata metadata profile, values like data profile\n");
@@ -332,6 +333,7 @@ static struct option long_options[] = {
{ "sectorsize", 1, NULL, 's' },
{ "data", 1, NULL, 'd' },
{ "version", 0, NULL, 'V' },
+ { "force", 0, NULL, 'f' },
{ 0, 0, 0, 0}
};
@@ -358,10 +360,11 @@ int main(int ac, char **av)
int first_fd;
int ret;
int i;
+ int force=0;
while(1) {
int c;
- c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:V", long_options,
+ c = getopt_long(ac, av, "A:b:l:n:s:m:d:L:Vf", long_options,
&option_index);
if (c < 0)
break;
@@ -401,6 +404,9 @@ int main(int ac, char **av)
case 'V':
print_version();
break;
+ case 'f':
+ force=1;
+ break;
default:
print_usage();
}
@@ -423,13 +429,16 @@ int main(int ac, char **av)
file = av[optind++];
ret = check_mounted(file);
- if (ret < 0) {
- fprintf(stderr, "error checking %s mount status\n", file);
- exit(1);
- }
- if (ret == 1) {
- fprintf(stderr, "%s is mounted\n", file);
- exit(1);
+ if(!force){
+ if (ret < 0) {
+ fprintf(stderr, "error checking %s mount status\n",
+ file);
+ exit(1);
+ }
+ if (ret == 1) {
+ fprintf(stderr, "%s is mounted\n", file);
+ exit(1);
+ }
}
ac--;
fd = open(file, O_RDWR);
@@ -479,15 +488,17 @@ int main(int ac, char **av)
zero_end = 1;
while(ac-- > 0) {
file = av[optind++];
- ret = check_mounted(file);
- if (ret < 0) {
- fprintf(stderr, "error checking %s mount status\n",
- file);
- exit(1);
- }
- if (ret == 1) {
- fprintf(stderr, "%s is mounted\n", file);
- exit(1);
+ if(!force){
+ ret = check_mounted(file);
+ if (ret < 0) {
+ fprintf(stderr, "error checking %s"
+ " mount status\n",file);
+ exit(1);
+ }
+ if (ret == 1) {
+ fprintf(stderr, "%s is mounted\n", file);
+ exit(1);
+ }
}
fd = open(file, O_RDWR);
if (fd < 0) {
[-- Attachment #3: mkfs.btrfs-force.diff.sig --]
[-- Type: application/pgp-signature, Size: 65 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: Odd mkbtrfs behavior inside of chroot
2011-01-02 21:06 ` Jérôme Poulin
@ 2011-01-04 23:12 ` J G
0 siblings, 0 replies; 6+ messages in thread
From: J G @ 2011-01-04 23:12 UTC (permalink / raw)
To: Jérôme Poulin; +Cc: linux-btrfs@vger.kernel.org
Binding /sys proved futile.
=2E:Justin:.
--- On Sun, 1/2/11, J=E9r=F4me Poulin <jeromepoulin@gmail.com> wrote:
> From: J=E9r=F4me Poulin <jeromepoulin@gmail.com>
> Subject: Re: Odd mkbtrfs behavior inside of chroot
> To: "J G" <yoosty_cmn@yahoo.com>
> Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
> Date: Sunday, January 2, 2011, 1:06 PM
> Did you try using -o bind on /proc
> and /sys as well? Just in case mkfs
> uses /sys too, I'm not sure if /proc reacts differently to
> multiple
> mounts or bind neither?
>=20
> Envoy=E9 de mon appareil mobile.
>=20
> J=E9r=F4me Poulin
> Solutions G.A.
>=20
> On 2011-01-02, at 14:53, J G <yoosty_cmn@yahoo.com>
> wrote:
>=20
> > I just encountered some odd behavior from mkbtrfs.
> > The end goal is to restore a backup to newly created
> BTRFS partitions while using the latest btrfs-tools.
> > Here's the steps to what I did:
> > * Booted SystemRescueCD
> > * Partitioned the drives (two 750GB drives with 12
> partitions each)
> > * Created an extra partition on sda as a temporary
> holding place for the backed up files and so I can update
> btrfs-tools
> > * Formatted/mounted/restored backup files to the
> temporary partition which I mounted on /mnt/backup
> > * mount -t proc none /mnt/backup/proc; mount -o bind
> /dev /mnt/backup/dev
> > * chroot /mnt/backup /bin/bash
> > * Updated btrfs-tools to the latest git pull from
> today (v0.19-35-g1b444cd-dirty).
> > * mkbtrfs /dev/sda5 /dev/sdb5 -L root
> >
> > mkbtrfs returned with:
> >
> > error checking /dev/sda5 mount status
> >
> > So I used strace to find out how it was checking for
> the mount status. Now, I'm no expert here, but I'm confused
> as to just why it failed. The last thing of note:
> >
> > lstat("/boot", {st_mode=3DS_IFDIR|0755, st_size=3D4096,
> ...}) =3D 0
> > lstat("/boot/sysrcd.dat", 0x7fffb29681e0) =3D -1 ENOENT
> (No such file or directory)
> > close(3)=A0 =A0 =A0 =A0 =A0 =A0
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
> =A0 =A0 =3D 0
> > munmap(0x7f11df372000, 4096)=A0 =A0 =A0
> =A0 =A0 =A0 =3D 0
> > write(2, "error checking /dev/sda5 mount s"...,
> 38error checking /dev/sda5 mount status
> > ) =3D 38
> >
> >
> > doesn't explain much. I see that it's checking
> /proc/mounts to see what's mounted, and then it fails on
> stating /boot/sysrcd.dat (which doesn't exist in the
> non-chrooted FS, btw).
> >
> > To make this even weirder, if I format sda5/sdb5 using
> the SysRescCD version of mkbtrfs (v0.19) and then format
> sda5/sdb5 using the chroot version, it works fine.
> >
> > Any ideas here? I would expect that mkbtrfs would work
> inside of a chroot without any assistance from the original
> root.
> >
> > I have the full strace from the chrooted mkbtrfs
> failing and from it succeeding, if that's helpful.
> >
> >
> > .:Justin:.
> >
> >
> >
> > --
> > 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=A0 http://vger.kernel.org/majordomo-info.htm=
l
>=20
=20
--
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] 6+ messages in thread
* Re: Odd mkbtrfs behavior inside of chroot
2011-01-02 23:14 ` Goffredo Baroncelli
2011-01-03 19:05 ` [PATCH] add a --force option to mkfs.btrf [was Re: Odd mkbtrfs behavior inside of chroot] Goffredo Baroncelli
@ 2011-01-04 23:16 ` J G
1 sibling, 0 replies; 6+ messages in thread
From: J G @ 2011-01-04 23:16 UTC (permalink / raw)
To: kreijack; +Cc: linux-btrfs
You're little trick with touching a blank /proc/mounts works, FWIW.
You're "--force" patch works even better however ;)
Thanks!
=2E:Justin:.
--- On Sun, 1/2/11, Goffredo Baroncelli <kreijack@libero.it> wrote:
> From: Goffredo Baroncelli <kreijack@libero.it>
> Subject: Re: Odd mkbtrfs behavior inside of chroot
> To: "J G" <yoosty_cmn@yahoo.com>
> Cc: linux-btrfs@vger.kernel.org
> Date: Sunday, January 2, 2011, 3:14 PM
> On 01/02/2011 08:52 PM, J G wrote:
> > I just encountered some odd behavior from mkbtrfs.
> > The end goal is to restore a backup to newly created
> BTRFS partitions while using the latest btrfs-tools.=20
> > Here's the steps to what I did:
> > * Booted SystemRescueCD
> > * Partitioned the drives (two 750GB drives with 12
> partitions each)
> > * Created an extra partition on sda as a temporary
> holding place for the backed up files and so I can update
> btrfs-tools
> > * Formatted/mounted/restored backup files to the
> temporary partition which I mounted on /mnt/backup
> > * mount -t proc none /mnt/backup/proc; mount -o bind
> /dev /mnt/backup/dev
> > * chroot /mnt/backup /bin/bash
> > * Updated btrfs-tools to the latest git pull from
> today (v0.19-35-g1b444cd-dirty).
> > * mkbtrfs /dev/sda5 /dev/sdb5 -L root
> >=20
> > mkbtrfs returned with:
> >=20
> > error checking /dev/sda5 mount status
> >=20
> > So I used strace to find out how it was checking for
> the mount status. Now, I'm no expert here, but I'm confused
> as to just why it failed. The last thing of note:
> >=20
> > lstat("/boot", {st_mode=3DS_IFDIR|0755, st_size=3D4096,
> ...}) =3D 0
> > lstat("/boot/sysrcd.dat", 0x7fffb29681e0) =3D -1 ENOENT
> (No such file or directory)
> > close(3)=A0 =A0 =A0 =A0 =A0 =A0
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
> =A0 =A0 =3D 0
> > munmap(0x7f11df372000, 4096)=A0 =A0 =A0
> =A0 =A0 =A0 =3D 0
> > write(2, "error checking /dev/sda5 mount s"...,
> 38error checking /dev/sda5 mount status
> > ) =3D 38
> >=20
> >=20
> > doesn't explain much. I see that it's checking
> /proc/mounts to see what's mounted, and then it fails on
> stating /boot/sysrcd.dat (which doesn't exist in the
> non-chrooted FS, btw).
> >=20
> > To make this even weirder, if I format sda5/sdb5 using
> the SysRescCD version of mkbtrfs (v0.19) and then format
> sda5/sdb5 using the chroot version, it works fine.
> >=20
> > Any ideas here? I would expect that mkbtrfs would work
> inside of a chroot without any assistance from the original
> root.
> >=20
> > I have the full strace from the chrooted mkbtrfs
> failing and from it succeeding, if that's helpful.
>=20
> On the basis of the provided information, and on the code
> it seems that
> mkfs.btrfs tries hard to check that the user is not
> formatting a mounted
> disk (or loop). So mkfs.btrfs scan the /proc/mount file and
> checks every
> devices. To do the check it needs to access the original
> file if this is
> a "loop backend". This is reasonable.
>=20
> In this case in a chroot-ed environment the loop file is
> not accessible.
>=20
> If you need a [dirty] "quick hack" to by-pass the problem
> (not tested):
> - unmount the proc filesystem
> - create an empty file /proc/mounts
> - run btrfs.fsck
> - mount the proc filesystem (removing the fake mounts
> file)
> - perform a "btrfs device scan"
> - mount the filesystem
>=20
> Of course the "right" solution is to add a "--force" switch
> which
> permits to by-pass these checks. Other mkfs.* tools have
> this switch.
>=20
> From the mkfs.ext4 man page:
> [...]
> =A0 =A0 =A0=A0=A0-F=A0
> =A0=A0=A0Force mke2fs to create a filesystem,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 even if
> the specified device is=A0 not
> =A0 =A0 =A0 =A0 =A0 =A0 =A0
> a=A0=A0=A0partition=A0 on=A0 a=A0
> block=A0 special
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 device, or
> if=A0 other=A0 parameters=A0 do
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 not=A0
> make=A0 sense.=A0 In order to force
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 mke2fs to
> create a=A0 filesystem=A0 even
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 if=A0
> the=A0 filesystem appears to be in
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 use or is
> mounted (a truly dangerous
> =A0 =A0 =A0 =A0 =A0 =A0 =A0
> thing=A0 to=A0 do),=A0 this option must be
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 specified
> twice.
>=20
> [...]
>=20
>=20
> >=20
> > .:Justin:.
> >=20
> >=20
> >=A0 =A0 =A0=A0=A0
> > --
> > 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=A0 http://vger.kernel.org/majordomo-info.htm=
l
> > .
> >=20
>=20
>=20
--
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] 6+ messages in thread
end of thread, other threads:[~2011-01-04 23:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-02 19:52 Odd mkbtrfs behavior inside of chroot J G
2011-01-02 21:06 ` Jérôme Poulin
2011-01-04 23:12 ` J G
2011-01-02 23:14 ` Goffredo Baroncelli
2011-01-03 19:05 ` [PATCH] add a --force option to mkfs.btrf [was Re: Odd mkbtrfs behavior inside of chroot] Goffredo Baroncelli
2011-01-04 23:16 ` Odd mkbtrfs behavior inside of chroot J G
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox