From: test532@codingninjas.org
To: dm-crypt@saout.de
Cc: solarflow99 <solarflow99@gmail.com>
Subject: Re: [dm-crypt] cryptsetup
Date: Tue, 1 Sep 2009 22:42:29 -0400 [thread overview]
Message-ID: <200909012242.29613.test532@codingninjas.org> (raw)
In-Reply-To: <7020fd000909011814m147b1d15xb0219d34d33d31f1@mail.gmail.com>
Hi There,
I don't know anything about the internals of dmcrypt, but I was in an
inquisitive mood, so I did some testing, and this is what I found:
I had success, and it appears that you don't have to do anything special with
dmcrypt/cryptsetup. I did luksClose before resizing the 'partition' however,
which is either required or at least a good idea to be safe.
Here is what I did:
1.I created a test file in my home directory:
# dd if=/dev/zero of=test bs=10000000 count=1
2. I then created a loop back device for it:
# losetup -f test
(this created /dev/loop0)
3. I then did a luksFormat on it:
# cryptsetup luksFormat /dev/loop0
4. Opened it.
# cryptsetup luksOpen /dev/loop0 test
5. formatted it
# mkfs.ext2 /dev/mapper/test
6. mounted it
# mkdir /mnt/test && mount /dev/mapper/test /mnt/test
7. filled it up
# dd if=/dev/urandom of=/mnt/test/fill
(resulting file was ~9megs, df reports 0 space left on drive)
8. md5sum on file to make sure it doesn't get corrupted from the next steps.
# md5sum /mnt/test/fill
(25d32f5e6a66e3ad7d7979b7785d7f02 fill)
9. unmounted
# umount /mnt/test
10. luksClosed it.
# cryptsetup luksClose /dev/mapper/test
11. detached the loop back device.
# losetup -d /dev/loop0
12. made the 'partition' bigger. (doubled the size of the file, by adding
10megs of zeros to the end, not overwriting the first original 10 megs)
# dd if=/dev/zero of=test bs=10000000 seek=1 count=1
13. losetup'ed it.
# losetup -a test
14. luksOpened it, no special other luks stuff needed.
# cryptsetup luksOpen /dev/loop0 test
15. expanded the ext2 filesystem to fill the new larger size of the
blockdevice.
# fsck.ext2 -f /dev/mapper/test && resize2fs /dev/mapper/test
(resize wants you to first run a fsck on it)
16. Mounted it,
# mount /dev/mapper/test /mnt/test
17. Filled it some more.
# dd if=/dev/urandom of=/mnt/test/fill2
(Resulted in another ~9meg file, thus proving that the filesystem resized
properly)
18. checksumed the first fill file again to make sure it didn't change (Ie.
get corrupted).
# md5sum fill
(25d32f5e6a66e3ad7d7979b7785d7f02 fill)
As you can see everything worked fine.
Here are the versions of my cryptsetup and dmsetup:
cryptsetup --version
cryptsetup 1.0.6-pre1
dmsetup --version
Library version: 1.02.27 (2008-06-25)
Driver version: 4.14.0
So based upon my testing, you should be fine. It shouldn't mater if you are
resizing a loop back device like I did to test, or are resizing a partition,
or are resizing a logical volume (LVM). What is important is it seems a
luksFormat does not store any info regarding the size of the blockdevice. So
if you close, resize and open, it will take advantage of the new space. I
cannot say about shrinking though. If you are trying to shrink, try the same
thing I did above, but with shrinking. I would assume that shrinking is more
risky as who knows how cryptsetup stores the data, it might put stuff at the
end of the drive that then you would be truncating away.
As for growing, as long as you do the things in the order I did, everything
should be fine. (Like make sure to luksClose the partition/logical_volume
before resizing it).
Good Luck!
Sam
> can anyone say if this command is needed when resizing a partition? What
> if I just used resize2fs? how could it know about the change of size?
> Also its a shame information like this has to be a secret, no one seems to
> know or say anything about it.
>
> Thanks,
>
next prev parent reply other threads:[~2009-09-02 2:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-02 1:14 [dm-crypt] cryptsetup solarflow99
2009-09-02 2:42 ` test532 [this message]
2009-09-02 3:01 ` f-dm-c
2009-09-02 5:13 ` Milan Broz
2009-09-02 10:12 ` Gilles PIETRI
-- strict thread matches above, loose matches on Subject: below --
2012-04-20 11:37 omar ahizoun
[not found] <CAAdJYJY6e9XTbZs8VTji9WKSPvEs7w4J8xxXLeo9=htOZS_5Hw@mail.gmail.com>
2017-11-10 17:05 ` [dm-crypt] Cryptsetup Steven Houtchen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200909012242.29613.test532@codingninjas.org \
--to=test532@codingninjas.org \
--cc=dm-crypt@saout.de \
--cc=solarflow99@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.