All of lore.kernel.org
 help / color / mirror / Atom feed
* how to extend a btrfs disk image?
@ 2020-12-17 12:30 Ulli Horlacher
  2020-12-17 14:12 ` Roman Mamedov
  0 siblings, 1 reply; 5+ messages in thread
From: Ulli Horlacher @ 2020-12-17 12:30 UTC (permalink / raw)
  To: linux-btrfs


How can I add a second disk-image to an existing btrfs filesystem?

I have to use btrfs via a disk image on a nfs Netapp storage system with a
16 TB file size limit. One cannot use bigger files.

I have set up sucessfully:

root@fextest:/nfs/rusnas/fex# touch disk1.btrfs
root@fextest:/nfs/rusnas/fex# truncate -s 16TB disk1.btrfs
root@fextest:/nfs/rusnas/fex# ll disk1.btrfs
-rw-r--r-- root root 16,000,000,000,000 2020-12-17 13:18:59 disk1.btrfs
root@fextest:/nfs/rusnas/fex# mkfs.btrfs disk1.btrfs
btrfs-progs v5.4.1
See http://btrfs.wiki.kernel.org for more information.

Label:              (null)
UUID:               4f7befb1-c892-497f-a40c-c6ac1a18368d
Node size:          16384
Sector size:        4096
Filesystem size:    14.55TiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         DUP               1.00GiB
  System:           DUP               8.00MiB
SSD detected:       no
Incompat features:  extref, skinny-metadata
Checksum:           crc32c
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1    14.55TiB  disk1.btrfs

root@fextest:/nfs/rusnas/fex# mount disk1.btrfs /mnt/tmp
root@fextest:/nfs/rusnas/fex# df -TH /mnt/tmp
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/loop2     btrfs   16T  3.7M   16T   1% /mnt/tmp


No problem so far, everything is easy ;-)

Now I want to extend this filesystem, but this approach fails:

root@fextest:/nfs/rusnas/fex# touch disk2.btrfs
root@fextest:/nfs/rusnas/fex# truncate -s 16TB disk2.btrfs
root@fextest:/nfs/rusnas/fex# btrfs device add /nfs/rusnas/fex/disk2.btrfs /mnt/tmp
ERROR: /nfs/rusnas/fex/disk2.btrfs is not a block device


root@fextest:/nfs/rusnas/fex# sysinfo 
System:        Linux fextest 5.4.0-58-generic x86_64
Distribution:  Ubuntu 20.04.1 LTS
Hardware:      VMware, Inc. VMware Virtual Platform None (VMware)
CPU:           Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz, 4 x 2394 MHz
RAM:           4095 MB

-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<20201217123008.GA22831@tik.uni-stuttgart.de>

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

* Re: how to extend a btrfs disk image?
  2020-12-17 12:30 how to extend a btrfs disk image? Ulli Horlacher
@ 2020-12-17 14:12 ` Roman Mamedov
  2020-12-19 22:59   ` Ulli Horlacher
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Mamedov @ 2020-12-17 14:12 UTC (permalink / raw)
  To: Ulli Horlacher; +Cc: linux-btrfs

On Thu, 17 Dec 2020 13:30:08 +0100
Ulli Horlacher <framstag@rus.uni-stuttgart.de> wrote:

> root@fextest:/nfs/rusnas/fex# mount disk1.btrfs /mnt/tmp
> root@fextest:/nfs/rusnas/fex# df -TH /mnt/tmp
> Filesystem     Type   Size  Used Avail Use% Mounted on
> /dev/loop2     btrfs   16T  3.7M   16T   1% /mnt/tmp

You see here 'mount' has transparently created a 'loop device' for you in order
to mount the FS.

> Now I want to extend this filesystem, but this approach fails:
> 
> root@fextest:/nfs/rusnas/fex# touch disk2.btrfs
> root@fextest:/nfs/rusnas/fex# truncate -s 16TB disk2.btrfs
> root@fextest:/nfs/rusnas/fex# btrfs device add /nfs/rusnas/fex/disk2.btrfs /mnt/tmp
> ERROR: /nfs/rusnas/fex/disk2.btrfs is not a block device

Since file is not a block device, here you have to do the same manually. See
documentation for 'losetup'.

-- 
With respect,
Roman

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

* Re: how to extend a btrfs disk image?
  2020-12-17 14:12 ` Roman Mamedov
@ 2020-12-19 22:59   ` Ulli Horlacher
  2020-12-20  9:22     ` Roman Mamedov
  0 siblings, 1 reply; 5+ messages in thread
From: Ulli Horlacher @ 2020-12-19 22:59 UTC (permalink / raw)
  To: linux-btrfs

On Thu 2020-12-17 (19:12), Roman Mamedov wrote:

> > root@fextest:/nfs/rusnas/fex# touch disk2.btrfs
> > root@fextest:/nfs/rusnas/fex# truncate -s 16TB disk2.btrfs
> > root@fextest:/nfs/rusnas/fex# btrfs device add /nfs/rusnas/fex/disk2.btrfs /mnt/tmp
> > ERROR: /nfs/rusnas/fex/disk2.btrfs is not a block device
> 
> Since file is not a block device, here you have to do the same manually. See
> documentation for 'losetup'.

Ok, I was able to extend the btrfs filesystem via a loopback devive.

What is the suggested way to do this at boot time?

For now I have in /etc/rc.local:

cd /nfs/rusnas/fex
for d in spool_[1-9].btrfs; do
  echo -n "$d ==> "
  losetup -fP --show $d
done
sync
sleep 2 # without this sleep the mount will fail!
mount -v spool_1.btrfs /mnt/spool

This works, but is there a more elegant way?
Using /etc/fstab seems not to be possible?


-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<20201217191207.17243c40@natsu>

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

* Re: how to extend a btrfs disk image?
  2020-12-19 22:59   ` Ulli Horlacher
@ 2020-12-20  9:22     ` Roman Mamedov
  2020-12-20 10:35       ` Ulli Horlacher
  0 siblings, 1 reply; 5+ messages in thread
From: Roman Mamedov @ 2020-12-20  9:22 UTC (permalink / raw)
  To: Ulli Horlacher; +Cc: linux-btrfs

On Sat, 19 Dec 2020 23:59:45 +0100
Ulli Horlacher <framstag@rus.uni-stuttgart.de> wrote:

> Ok, I was able to extend the btrfs filesystem via a loopback devive.
> 
> What is the suggested way to do this at boot time?
> 
> For now I have in /etc/rc.local:
> 
> cd /nfs/rusnas/fex
> for d in spool_[1-9].btrfs; do
>   echo -n "$d ==> "
>   losetup -fP --show $d
> done
> sync
> sleep 2 # without this sleep the mount will fail!

You could try replacing the sleep with "btrfs device scan", certainly more
elegant (assuming it helps). Maybe even narrow it down to
"btrfs device scan /dev/loop*", or even scan each added device.

> mount -v spool_1.btrfs /mnt/spool

Better mount one of the loop devices, not the file, lest mount will probably
make one more, a dupe of one that your script has already added, and who knows
what side effects this could have.

> This works, but is there a more elegant way?
> Using /etc/fstab seems not to be possible?

There doesn't seem to be "/etc/looptab" or such, that would set these up on
boot. So your approach seems fine to me.

-- 
With respect,
Roman

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

* Re: how to extend a btrfs disk image?
  2020-12-20  9:22     ` Roman Mamedov
@ 2020-12-20 10:35       ` Ulli Horlacher
  0 siblings, 0 replies; 5+ messages in thread
From: Ulli Horlacher @ 2020-12-20 10:35 UTC (permalink / raw)
  To: linux-btrfs

On Sun 2020-12-20 (14:22), Roman Mamedov wrote:

> > For now I have in /etc/rc.local:
> > 
> > cd /nfs/rusnas/fex
> > for d in spool_[1-9].btrfs; do
> >   echo -n "$d ==> "
> >   losetup -fP --show $d
> > done
> > sync
> > sleep 2 # without this sleep the mount will fail!
> 
> You could try replacing the sleep with "btrfs device scan", certainly more
> elegant (assuming it helps). Maybe even narrow it down to
> "btrfs device scan /dev/loop*", or even scan each added device.

Indeed better!


> > mount -v spool_1.btrfs /mnt/spool
> 
> Better mount one of the loop devices, not the file, lest mount will probably
> make one more, a dupe of one that your script has already added, and who knows
> what side effects this could have.

Ok, now I use:

ldev=$(losetup -l | awk '/spool_1.btrfs/{print $1;exit}')
mount -v $ldev /mnt/spool

This is all necessary because our Netapp storage system has an annoying 
16 TB file size limit. This was ok for the last century, but for today it
is an anachronism.


-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<20201220142252.01cf4140@natsu>

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

end of thread, other threads:[~2020-12-20 10:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-17 12:30 how to extend a btrfs disk image? Ulli Horlacher
2020-12-17 14:12 ` Roman Mamedov
2020-12-19 22:59   ` Ulli Horlacher
2020-12-20  9:22     ` Roman Mamedov
2020-12-20 10:35       ` Ulli Horlacher

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.