All of lore.kernel.org
 help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: clodoaldo.pinto.neto@gmail.com
Cc: "Jens-U. Mozdzen" <jmozdzen@nde.ag>, linux-bcache@vger.kernel.org
Subject: Re: undo make-bcache (was: Re: Can't mount an encrypted backing device)
Date: Sat, 18 Jan 2020 22:31:36 +0800	[thread overview]
Message-ID: <073b1b48-2d2c-369f-114e-5b608ffea683@suse.de> (raw)
In-Reply-To: <abfeedfa-f973-de4e-3b54-53d1502af939@suse.de>

On 2020/1/18 10:16 下午, Coly Li wrote:

>>>> It works like this:
>>>>
>>>> # echo '0 3774578664 linear /dev/mapper/backing-device 8' | dmsetup create dmb
>>>>
>>>> But then I can't mount it:
>>>>
>>>> # mount /dev/mapper/dmb /r
>>>> mount: /r: wrong fs type, bad option, bad superblock on
>>>> /dev/mapper/dmb, missing codepage or helper program, or other error.
>>>
>>> It might be my fault, from bcache-tools, it seems the offset is
>>> BDEV_DATA_START_DEFAULT (16 sectors). How about:
>>> # echo '0 3774578656 linear /dev/mapper/backing-device 16' | dmsetup
>>> create dmb
>>
>> Still no luck
>>
>> # echo '0 3774578656 linear /dev/mapper/backing-device 16' | dmsetup create dmb
>> # mount /dev/mapper/dmb /r
>> mount: /r: wrong fs type, bad option, bad superblock on
>> /dev/mapper/dmb, missing codepage or helper program, or other error.
> 
> The tricky part is to calculate the correct linear mapping size.
> 
> For example, I have a 500G hard drive, from fdisk I see its size is
> 1048576000 sectors. I use it as a bcache backing device and format an
> Ext4 file system on it. Then I use the following mistaken command line
> to setup a linear target to skip the first 8 sectors,
>  # echo '0 1048575000  linear /dev/sdc 16' | dmsetup create dmb
> Then mount /dev/mapper/dmb to /mnt fails, the kmesg hints me,
>  [1884572.477316] EXT4-fs (dm-0): bad geometry: block count 131071998
> exceeds size of device (131071875 blocks)
> 
> So I realize Ext4 file system will check the block device size, so I
> need to provide an exact accurate length number for the linear target.
> From the kmesg I see the correct sector size should be
> (131071998*8=)1048575984, then I re-create the linear target by,
>  # echo '0 1048575984  linear /dev/sdc 16' | dmsetup create dmb
> Then I mount /dev/mapper/dmb to /mnt, it works and I have the following
> line from command 'mount',
>  /dev/mapper/dmb on /mnt type ext4 (rw,relatime)
> 
> I don't use the encrpyt file system and I don't know the excact detail
> about it. But I guess, it might because the incorrect length number for
> your dm linear target as I show by the above example.
> 

Sorry I realize maybe I mislead you....

I re-read the first email, it seems you create the bcache backing device
on top of a raid raid1, then you cryptsetup on the bcache device.

So I guess the linear dm target should be created on top of the md
raid1, not /dev/mapper/backing-device. Which might be,
# echo '0 3774578656 linear /dev/md127 16' | dmsetup create dmb

The above line assumes luks has its superblock on offset zero from its
own LBA, and <0 3774578656> should be a correct pair.

If all the offset numbers are correct, dmb should be the block device
for your to run cryptsetup open. Then you will have a
/dev/mapper/backing-device for following mount.

-- 

Coly Li

      reply	other threads:[~2020-01-18 14:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CA+Z73LFJLiP7Z2_cDUsO4Om_8pdD6w1jTSGQB0jY5sL-+nw1Wg@mail.gmail.com>
     [not found] ` <CA+Z73LGvXa_V8t=KYPkrmeJ-xmEXmz1uAnaT=Yj5AReZgLeqhg@mail.gmail.com>
     [not found]   ` <alpine.LRH.2.11.2001062258320.2074@mx.ewheeler.net>
2020-01-11 13:42     ` Can't mount an encrypted backing device Clodoaldo Neto
2020-01-16 22:55       ` Eric Wheeler
2020-01-18 10:44         ` Clodoaldo Neto
     [not found]   ` <65c05b80-679b-2ccb-1bd1-a9a6887c9c51@suse.de>
2020-01-13 12:44     ` undo make-bcache (was: Re: Can't mount an encrypted backing device) Jens-U. Mozdzen
2020-01-13 14:18       ` Coly Li
     [not found]         ` <CA+Z73LGG1pBtT=0WN5vEyqEvzxEnqMRZ26S_2x4Gd5JPSmuXmQ@mail.gmail.com>
     [not found]           ` <CA+Z73LFNxP8kDMSq74DBKDbCXpbtMA9svpc1KddkUmrk-cfnOA@mail.gmail.com>
     [not found]             ` <CA+Z73LGXJOwYEb+GmPuuDi3TcJbGG=NLv-5vCRcEvB+kgr4a+A@mail.gmail.com>
2020-01-16 21:56               ` Clodoaldo Neto
2020-01-16 23:00                 ` Eric Wheeler
2020-01-18 11:44                   ` Clodoaldo Neto
2020-01-17  0:58               ` Coly Li
2020-01-18 10:54                 ` Clodoaldo Neto
2020-01-18 12:22                   ` Clodoaldo Neto
2020-01-18 12:34                     ` Coly Li
2020-01-18 13:43                       ` Clodoaldo Neto
2020-01-18 14:16                         ` Coly Li
2020-01-18 14:31                           ` Coly Li [this message]

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=073b1b48-2d2c-369f-114e-5b608ffea683@suse.de \
    --to=colyli@suse.de \
    --cc=clodoaldo.pinto.neto@gmail.com \
    --cc=jmozdzen@nde.ag \
    --cc=linux-bcache@vger.kernel.org \
    /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.