creating two device mapper files for an underline blockdevice
Hello,I am trying to create two device mapper files for an underline blockdevice. One file( half1) will be mapped to the first half of the block-device. and the second half (half2) will be mapped to the rest of the space in the same block device.
1.Using dd command I have created a 100 MB file.
# dd if=/dev/zero of=dm_test bs=512 count=2048002. associated it with loop device:
# losetup /dev/loop0 /tmp/dm_test# blockdev --getsize /dev/loop0
204800using dmsetup to create dm file.
# dmsetup create half --table "0 102400 linear /dev/loop0 0"
[root@bladelinux01 root]# dmsetup table half0 102400 linear 7:0 0
[root@bladelinux01 root]# dmsetup info halfName:************* half
State:************ ACTIVERead Ahead:******* 256
Tables present:*** LIVEOpen count:******* 0
Event number:***** 0Major, minor:***** 253, 6
Number of targets: 1
[root@bladelinux01 root]# ls -l /dev/mapper/halflrwxrwxrwx. 1 root root 7 Nov* 1 01:44 /dev/mapper/half -> ../dm-6
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 argumentCommand failed
[root@bladelinux01 root]#* dmsetup create half1 --table "102401 102399 linear /dev/loop0 0"
device-mapper: reload ioctl failed: Invalid argumentCommand failed
The format used seems to be correct according to the man page of dmsetup. Please guide me. I am not sure what am I missing.
-- sanjana
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
11-01-2011, 05:10 AM
Sanjana Shari
creating two device mapper files for an underline blockdevice
Please do put me in cc list while replying.
On Tue, Nov 1, 2011 at 11:38 AM, Sanjana Shari <sanjana.linux@gmail.com> wrote:
Hello,
I am trying to create two device mapper files for an underline blockdevice. One file( half1) will be mapped to the first half of the block-device. and the second half (half2) will be mapped to the rest of the space in the same block device.
1.Using dd command I have created a 100 MB file.
# dd if=/dev/zero of=dm_test bs=512 count=2048002. associated it with loop device:
The format used seems to be correct according to the man page of dmsetup. Please guide me. I am not sure what am I missing.
-- sanjana
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
11-01-2011, 03:52 PM
Sanjana Shari
creating two device mapper files for an underline blockdevice
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.
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
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
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@redhat.com> 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
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
11-01-2011, 04:10 PM
Sanjana Shari
creating two device mapper files for an underline blockdevice
Hi,
In an another example:
[root@bladelinux01 ~]# dmsetup table firsthalf
0 102400 linear 7:0 0
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..
[root@bladelinux01 ~]# dmsetup create x --table "0 102400 linear /dev/loop0 102400"
[root@bladelinux01 ~]# dmsetup table x
0 102400 linear 7:0 102400
[root@bladelinux01 ~]# dmsetup table firsthalf
0 102400 linear 7:0 0
[root@bladelinux01 ~]# dmsetup table x
0 102400 linear 7:0 102400
[root@bladelinux01 ~]# dmsetup deps x
1 dependencies* : (7, 0)
[root@bladelinux01 ~]# dmsetup deps firsthalf
1 dependencies* : (7, 0)
[root@bladelinux01 ~]# dmsetup info x
Name:************* x
State:************ ACTIVE
Read Ahead:******* 256
Tables present:*** LIVE
Open count:******* 0
Event number:***** 0
Major, minor:***** 253, 7
Number of targets: 1
[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
--sanjana
On Tue, Nov 1, 2011 at 10:22 PM, Sanjana Shari <sanjana.linux@gmail.com> wrote:
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.
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
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
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@redhat.com> 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