FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 11-01-2011, 07:31 AM
Milan Broz
 
Default creating two device mapper files for an underline blockdevice

On 11/01/2011 07:08 AM, Sanjana Shari wrote:

> But if I use the other part of the disk to map. The command is not successful
>
> [root@bladelinux01 root]# dmsetup create half1 --table "102401 102399 linear /dev/loop0 102400"
> device-mapper: reload ioctl failed: Invalid argument
> Command failed

You have to always map the whole table (starting at sector 0).
If you see syslog, you can see why
device-mapper: table: 254:2: linear: Gap in table
device-mapper: ioctl: error adding target to table

Anyway, for the info how it works, example how to switch active table:

1. create linear device mapped to /dev/sdb

# dmsetup create x --table "0 10000 linear /dev/sdb 0"
# dmsetup table x
0 10000 linear 8:16 0

2. Remap the first half of device to another target, here "error"

- load new (yet inactive) table
# echo -e "0 5000 error
5000 10000 linear /dev/sdb 5000" | dmsetup load x

- so now you have one active table and one inactive (prepared for switch)
# dmsetup table x
0 10000 linear 8:16 0

# dmsetup table x --inactive
0 5000 error
5000 10000 linear 8:16 5000

3. switch to new (inactive) table (note that "dmsetup suspend" here is implicit)
# dmsetup resume x

# dmsetup table x
0 5000 error
5000 10000 linear 8:16 5000


If you want more info about this low level DM operation, read
http://people.redhat.com/agk/talks/FOSDEM_2005/
http://mbroz.fedorapeople.org/talks/DeviceMapperBasics/
(old, but still useful, I hope :-)

Milan

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 
Old 11-02-2011, 06:57 AM
Milan Broz
 
Default creating two device mapper files for an underline blockdevice

On 11/01/2011 06:10 PM, Sanjana Shari wrote:
> Using the remaining of first half of the same blockdevice /dev/loop0.
> This seems to work. So I ma confused here how the mapping works..

There is no magic for linear mapping.
Imagine you have this mapping table

0 8 linear /dev/sdb 1000
8 8 linear /dev/sdc 500

It means you created 16 sectors device consisting of two segments.

First half (sectors 0-7) is mapped to /dev/sdb starting at sector 10000.
(IOW sectors 0-7 of newly mapped device is mapped to sectors 10000-10007 of /dev/sdb)

Second half (sectors 8-15) is mapped to /dev/sdc starting at sector 500.

See dmsetup man page, where linear mapping is described.
Just do not confuse source and destination device offset.

Milan

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 

Thread Tools




All times are GMT. The time now is 11:41 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org