# resize a LUKS loop

## GNUtoo

hello, how do i resize a luks loop...so far i've done that:

 *Quote:*   

> 
> 
> ==Presentation==
> 
> *you may plan to use luks but you want to be shure you can expand the volume...
> ...

 

but it didn't worked...

mabe that's because the loop device need to be expanded with losetup -R but it doesn't work:

```
 # losetup -R /dev/loop0 

/dev/loop0: Invalid argument

```

and my loop file is on /dev/loop0

----------

## Sadako

The losetup man page doesn't list a "-R" option...

Why is it needed anyway?

It should default to the full size of the file.

----------

## GNUtoo

 *Quote:*   

> -R     Resize  existing,  already  set  up  loop device, to new changed
> 
>               underlying device size. This option is for changing mounted live
> 
>               file  system  size  on LVM volume. This functionality may not be
> ...

 

----------

## Sadako

 *GNUtoo wrote:*   

>  *Quote:*   -R     Resize  existing,  already  set  up  loop device, to new changed
> 
>               underlying device size. This option is for changing mounted live
> 
>               file  system  size  on LVM volume. This functionality may not be
> ...

 Fair enough, but you should get the exact same functionality by detaching the loop device with `losetup -d /dev/loop0`, run the dd and cat commands to increase the size of the underlying file, and then simply recreate it with `losetup /dev/loop0 loopfile`.

Unless I'm missing something...

----------

## GNUtoo

i did this...the file is now bigger,

i also resized the luks volume and the filesystem...but at the end the filesystem is the same size as before

----------

## Sadako

What does `dmsetup table` tell you the size of the /dev/mapper device is?

It should be the third field (including the name of the mapping), and you'll probably need to divide by 2048 to get the size in megabytes.

Is this the size it should be after resizing?

----------

## GNUtoo

according to the manual:

 *Quote:*   

> TABLE FORMAT
> 
>        Each line of the table specifies a single target and is of the form:
> 
>            logical_start_sector num_sectors target_type target_args
> ...

 

so it's in sectors...how do i convert it in MB?

----------

## GNUtoo

i retyped the commands and it workd...

so it's possibile...great(very usefull on a raid5/6 with evms because if i add disk i would like to grow the partition)

dividing to 2048 worked...after that i had to: 

multiply by 4k and divide by 1024 the size of the filesystem

----------

