Re: creating two device mapper files for an underline blockdevice

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Hi Milan,

Thanks for the documentation links... it was useful.. one of the link I had gone through it earlier.

Couple of questions more which I would post here...

Mapping the second half of the first device + the another device to create a new map. here I ma not mapping the whole of first disk. Or I ma not mapping the whole table, but still device creation is sucessfull.
[root@bladelinux01 ~]# losetup -a
/dev/loop0: [fd03]:2359319 (/root/dm/dm_test)
/dev/loop1: [fd03]:2359321 (/root/dm/dm_test1)
[root@bladelinux01 ~]# blockdev --getsize /dev/loop0
204800  < ------ 100 M
[root@bladelinux01 ~]# blockdev --getsize /dev/loop1
204800  < ------ 100 M

Using first half of the block device /dev/loop0. Here I have mapped the table from 0 to 102400 sectors.

[root@bladelinux01 ~]# fdisk -lus /dev/loop0

Disk /dev/loop0: 104 MB, 104857600 bytes
255 heads, 63 sectors/track, 12 cylinders, total 204800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Command is successful.... as expected.

[root@bladelinux01 ~]# dmsetup create firsthalf --table "0 102400 linear /dev/loop0 0"
[root@bladelinux01 ~]# dmsetup table firsthalf
0 102400 linear 7:0 0
[root@bladelinux01 ~]# dmsetup info firsthalf
Name:              firsthalf
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        0
Event number:      0
Major, minor:      253, 6
Number of targets: 1

Now here I am creating a new device named "anotherhalf_plus_otherdisk" by mapping the remaining first half of the first disk and then the whole of a second block device /dev/loop1.

Creating table to use with dmsetup.
[root@bladelinux01 ~]# echo 0 102400 linear /dev/loop0 102400 > table
[root@bladelinux01 ~]# cat table
0 102400 linear /dev/loop0 102400
[root@bladelinux01 ~]# echo 102400 204800 linear /dev/loop1 0 >>table
[root@bladelinux01 ~]# cat table
0 102400 linear /dev/loop0 102400
102400 204800 linear /dev/loop1 0
[root@bladelinux01 ~]# dmsetup create anotherhalf_plus_otherdisk table
[root@bladelinux01 ~]# dmsetup table anotherhalf_plus_otherdisk
0 102400 linear 7:0 102400
102400 204800 linear 7:1 0
[root@bladelinux01 ~]# dmsetup info anotherhalf_plus_otherdisk
Name:              anotherhalf_plus_otherdisk
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        0
Event number:      0
Major, minor:      253, 7
Number of targets: 2

device created with size as expected. Agian here I haven't used the start sector as "0" for the second block device,
I have used "102400"th sector to start from, which I believe should be continuation of the previous logical sector. < --- Please this part.
[root@bladelinux01 ~]# blockdev --getsize /dev/mapper/anotherhalf_plus_otherdisk
307200

[root@bladelinux01 ~]# fdisk -lus /dev/mapper/anotherhalf_plus_otherdisk

Disk /dev/mapper/anotherhalf_plus_otherdisk: 157 MB, 157286400 bytes
255 heads, 63 sectors/track, 19 cylinders, total 307200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Here I have some doubts which needs to be cleared to get a thorough understanding.
My questions:

The table format to be used is as follows from man page of dmsetup.
Each line of the table specifies a single target and is of the form:
logical_start_sector    num_sectors    target_type target_args

Here:
"logical_start_sector" start sector should be "0" for the start of any block device, rather I would say for the start of any new map would e more appropriate. What do you say...?
"num_sectors" as name suggestes would be the number of sectors, which would contribute to the size of the end mapped device.

For target type "linear" we use arguments as the following:
destination_device   start_sector   < -------- here which is the start sector..?
Is it the logical start scetor of the blockdevice or the physical sector of the blockdevice...? Or how do we define it...? This part is not yet clear to me.



On Tue, Nov 1, 2011 at 2:01 PM, Milan Broz <mbroz@xxxxxxxxxx> wrote:
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\n5000 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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

Add to Google Powered by Linux