* Howto take a snapshot from an image as ordinary user?
@ 2020-03-07 21:21 Ferry Toth
2020-03-08 15:39 ` Ferry Toth
0 siblings, 1 reply; 5+ messages in thread
From: Ferry Toth @ 2020-03-07 21:21 UTC (permalink / raw)
To: linux-btrfs
I am generating a btrfs system image using Yocto.
I want to take a snapshot from the image preferably inside a Yocto
recipe. The snapshot I can send 'over the air' to the remote (IoT) device.
Now I am able to loop mount the image file using udisksctl as an
ordinary user, which mounts the image under /media/ferry.
However, the owner of the mount point is root, and it appears I am not
allowed to take a snapshot as an ordinary user.
I think it is obvious that I don't want to run bitbake as root.
So what is the recommended way to generate a snapshot without becoming root?
Thanks,
Ferry
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Howto take a snapshot from an image as ordinary user?
2020-03-07 21:21 Howto take a snapshot from an image as ordinary user? Ferry Toth
@ 2020-03-08 15:39 ` Ferry Toth
2020-03-15 15:48 ` Ferry Toth
0 siblings, 1 reply; 5+ messages in thread
From: Ferry Toth @ 2020-03-08 15:39 UTC (permalink / raw)
To: linux-btrfs
Hi
Op 07-03-2020 om 22:21 schreef Ferry Toth:
> I am generating a btrfs system image using Yocto.
>
> I want to take a snapshot from the image preferably inside a Yocto
> recipe. The snapshot I can send 'over the air' to the remote (IoT) device.
>
> Now I am able to loop mount the image file using udisksctl as an
> ordinary user, which mounts the image under /media/ferry.
>
> However, the owner of the mount point is root, and it appears I am not
> allowed to take a snapshot as an ordinary user.
To clarify, I know that I can chown the mount point after mounting.
But to do that I need to sudo it.
> I think it is obvious that I don't want to run bitbake as root.
>
> So what is the recommended way to generate a snapshot without becoming
> root?
>
> Thanks,
>
> Ferry
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Howto take a snapshot from an image as ordinary user?
2020-03-08 15:39 ` Ferry Toth
@ 2020-03-15 15:48 ` Ferry Toth
2020-03-15 15:48 ` Ferry Toth
0 siblings, 1 reply; 5+ messages in thread
From: Ferry Toth @ 2020-03-15 15:48 UTC (permalink / raw)
To: linux-btrfs
Op 08-03-2020 om 16:39 schreef Ferry Toth:
> Hi
>
> Op 07-03-2020 om 22:21 schreef Ferry Toth:
>> I am generating a btrfs system image using Yocto.
>>
>> I want to take a snapshot from the image preferably inside a Yocto
>> recipe. The snapshot I can send 'over the air' to the remote (IoT)
>> device.
>>
>> Now I am able to loop mount the image file using udisksctl as an
>> ordinary user, which mounts the image under /media/ferry.
>>
>> However, the owner of the mount point is root, and it appears I am not
>> allowed to take a snapshot as an ordinary user.
>
> To clarify, I know that I can chown the mount point after mounting.
> But to do that I need to sudo it.
I found a way to own the mount point. The procedure is:
1) create an ext34 file system with
EXTRA_IMAGECMD_ext3 += " -E root_owner=`/bin/ps -o user= -p $$`:`/bin/ps
-o group= -p $$`"
Yocto runs the image generation under pseudo (alternative fakeroot). The
above allows to create an ext3 file system with the root owned by the
real current user.
2) btrfs-convert the ext3 image to btrfs
3) take the snapshot
The final step (btrfs send) fails with:
ERROR: check if we support uuid tree fails - Operation not permitted
ERROR: failed to initialize subvol search: Operation not permitted
It appears it just can't be done currently as I could have from:
https://webcache.googleusercontent.com/search?q=cache:oZR58gPBVRkJ:https://www.spinics.net/lists/linux-btrfs/msg31188.html+&cd=1&hl=en&ct=clnk&gl=nl&client=ubuntu
HOSTTOOLS += " /usr/bin/udisksctl /bin/btrfs /bin/btrfs-convert /bin/ps"
# we are running as pseudo but we need ownership of the root as the real
user
EXTRA_IMAGECMD_ext3 += " -E root_owner=`/bin/ps -o user= -p $$`:`/bin/ps
-o group= -p $$`"
IMAGE_FSTYPES += " ext3"
python do_btrfs_snapshot() {
import subprocess
# convert the ext3 image
cmd_mkimg = 'btrfs-convert ' +
d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.ext3")
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
# mount the converted ext3 image
cmd_mkimg = '/usr/bin/udisksctl loop-setup --no-user-interaction -f
' + d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.ext3")
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
loop = ret.stdout.split(' ').pop().split('.')[0]
# find the mounted partition
cmd_mkimg = 'lsblk -o MOUNTPOINT -n ' + loop
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
mount_point = ret.stdout.rstrip()
# take a snapshot of the partition
cmd_mkimg = '/bin/btrfs su snap -r ' + mount_point + ' ' +
mount_point + '/@new'
print(cmd_mkimg)
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
# btrfs send the partition
cmd_mkimg = '/bin/btrfs send ' + mount_point + '/@new/ > ' +
d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.snapshot")
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
print(ret.stdout)
print(ret.stderr)
# unmount the btrfs image
cmd_mkimg = '/usr/bin/udisksctl unmount -b ' + loop
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
# delete the loop device
cmd_mkimg = '/usr/bin/udisksctl loop-delete -b ' + loop
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
return 0
}
addtask btrfs_snapshot after image_ext3 before do_bootimg
>> I think it is obvious that I don't want to run bitbake as root.
>>
>> So what is the recommended way to generate a snapshot without becoming
>> root?
>>
>> Thanks,
>>
>> Ferry
>>
>>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Howto take a snapshot from an image as ordinary user?
2020-03-15 15:48 ` Ferry Toth
@ 2020-03-15 15:48 ` Ferry Toth
0 siblings, 0 replies; 5+ messages in thread
From: Ferry Toth @ 2020-03-15 15:48 UTC (permalink / raw)
To: Ferry Toth, linux-btrfs
Op 08-03-2020 om 16:39 schreef Ferry Toth:
> Hi
>
> Op 07-03-2020 om 22:21 schreef Ferry Toth:
>> I am generating a btrfs system image using Yocto.
>>
>> I want to take a snapshot from the image preferably inside a Yocto
>> recipe. The snapshot I can send 'over the air' to the remote (IoT)
>> device.
>>
>> Now I am able to loop mount the image file using udisksctl as an
>> ordinary user, which mounts the image under /media/ferry.
>>
>> However, the owner of the mount point is root, and it appears I am not
>> allowed to take a snapshot as an ordinary user.
>
> To clarify, I know that I can chown the mount point after mounting.
> But to do that I need to sudo it.
I found a way to own the mount point. The procedure is:
1) create an ext34 file system with
EXTRA_IMAGECMD_ext3 += " -E root_owner=`/bin/ps -o user= -p $$`:`/bin/ps
-o group= -p $$`"
Yocto runs the image generation under pseudo (alternative fakeroot). The
above allows to create an ext3 file system with the root owned by the
real current user.
2) btrfs-convert the ext3 image to btrfs
3) take the snapshot
The final step (btrfs send) fails with:
ERROR: check if we support uuid tree fails - Operation not permitted
ERROR: failed to initialize subvol search: Operation not permitted
It appears it just can't be done currently as I could have from:
https://webcache.googleusercontent.com/search?q=cache:oZR58gPBVRkJ:https://www.spinics.net/lists/linux-btrfs/msg31188.html+&cd=1&hl=en&ct=clnk&gl=nl&client=ubuntu
HOSTTOOLS += " /usr/bin/udisksctl /bin/btrfs /bin/btrfs-convert /bin/ps"
# we are running as pseudo but we need ownership of the root as the real
user
EXTRA_IMAGECMD_ext3 += " -E root_owner=`/bin/ps -o user= -p $$`:`/bin/ps
-o group= -p $$`"
IMAGE_FSTYPES += " ext3"
python do_btrfs_snapshot() {
import subprocess
# convert the ext3 image
cmd_mkimg = 'btrfs-convert ' +
d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.ext3")
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
# mount the converted ext3 image
cmd_mkimg = '/usr/bin/udisksctl loop-setup --no-user-interaction -f
' + d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.ext3")
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
loop = ret.stdout.split(' ').pop().split('.')[0]
# find the mounted partition
cmd_mkimg = 'lsblk -o MOUNTPOINT -n ' + loop
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
mount_point = ret.stdout.rstrip()
# take a snapshot of the partition
cmd_mkimg = '/bin/btrfs su snap -r ' + mount_point + ' ' +
mount_point + '/@new'
print(cmd_mkimg)
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
# btrfs send the partition
cmd_mkimg = '/bin/btrfs send ' + mount_point + '/@new/ > ' +
d.expand("${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.snapshot")
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
print(ret.stdout)
print(ret.stderr)
# unmount the btrfs image
cmd_mkimg = '/usr/bin/udisksctl unmount -b ' + loop
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
# delete the loop device
cmd_mkimg = '/usr/bin/udisksctl loop-delete -b ' + loop
ret = subprocess.run(cmd_mkimg, shell=True, capture_output=True,
text=True)
return 0
}
addtask btrfs_snapshot after image_ext3 before do_bootimg
>> I think it is obvious that I don't want to run bitbake as root.
>>
>> So what is the recommended way to generate a snapshot without becoming
>> root?
>>
>> Thanks,
>>
>> Ferry
>>
>>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Howto take a snapshot from an image as ordinary user?
@ 2020-03-07 21:11 Ferry Toth
0 siblings, 0 replies; 5+ messages in thread
From: Ferry Toth @ 2020-03-07 21:11 UTC (permalink / raw)
To: linux-btrfs
I am generating a btrfs system image using Yocto.
I want to take a snapshot from the image preferably inside a Yocto
recipe. The snapshot I can send 'over the air' to the remote (IoT) device.
Now I am able to loop mount the image file using udisksctl as an
ordinary user, which mounts the image under /media/ferry.
However, the owner of the mount point is root, and it appears I am not
allowed to take a snapshot as an ordinary user.
I think it is obvious that I don't want to run bitbake as root.
So what is the recommended way to generate a snapshot without becoming root?
Thanks,
Ferry
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-15 15:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-07 21:21 Howto take a snapshot from an image as ordinary user? Ferry Toth
2020-03-08 15:39 ` Ferry Toth
2020-03-15 15:48 ` Ferry Toth
2020-03-15 15:48 ` Ferry Toth
-- strict thread matches above, loose matches on Subject: below --
2020-03-07 21:11 Ferry Toth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).