[centos-users 886] Re: 論理ボリュームをマウントできない
Takeshi Kusune
kusune @ sfc.wide.ad.jp
2008年 10月 27日 (月) 21:23:17 JST
楠根です。
(2008/10/27 16:43), Tetsuo Ooki さんは書きました:
> fdiskによって領域を確保してから、テーブルを更新したら、デバイスファイ
> ルができるものと思っていたのですが、その認識が間違っているのでしょうか。
はい。
fdisk command によって特定の file 上の partition table を編集できることと、
その partition table に従って kernel が partition を認識できることは、
独立した事象です。
fdisk command は指定された file を blok device file とみなし、
その file 上に partition table の形式のデータを書き込む application です。
fdisk は、指定された device file 上の partition table の編集後に、
その device file 上の partition table を kernel が再読み込みするよう、
partition を取り扱う全ての block device に実装されているはずの
ioctl を kick するように作られてはいます。
ただ、その処理をするのはそれぞれの device の driver なので、
そこに partition 操作の実装がなければ当然 OS を介した操作はできません。
/dev/sda は SCSI、/dev/hda は IDE、それぞれの whole disk device を
示す device number がくくりつけられた device file ですから、
その device file 上の partition table を fdisk command で編集すれば、
/dev/sda ないし /dev/hda に対する partition 操作の ioctl の発行により、
その device 上の partition table に従って partition 操作ができます。
/dev/VG01/LV01 というファイルは LVM の logical volume に対応しています。
つまり、LVM の logical volume に partition を扱う ioctl が実装されていれば、
その device にあった何らかの方法で partition 操作ができます。
個々の partition に対応した device file はあくまで操作のための I/F であり、
重要なのは partition table に従って作られた partition を操作できるように
device driver が実装されているかです。
もしそのように実装されていれば、
個別の partition device に対応する device number があるので、
その番号を使って device file を作ればアクセスできるようになります。
# その device file を自動的に作る機構なども実装できるでしょう。
ちなみに、基本的には個別の partition は whole disk の device の後に続く
一連の minor device number がつく実装になってるみたいですが、
LVM の logical volume に device mapper が振る device number は
単にあいてる次の minor 番号を振っているように見えるので、
ここから推測するに partition を操作できるようにはなっていない気がします。
また、kernel に認識されている(= device number が振られている)partition は
/proc/partition に一覧されていますので、
ここを見ても OS で使えるかどうかはわかるのではないかと思います。
/sbin/partx コマンドで kernel に partition table に沿って partition 操作を
させることができるようですが、/sbin/partx コマンドによって追加させようとしても、
BLKPG: Invalid argument
error adding partition x
というエラーになってしまうのを見ると、やっぱり現状では無理な気がします。
なお、上記の操作の CentOS 5 での実行ログを以下につけておきます。
[kusune @ midori LVM2.2.02.32]$ sudo /sbin/lvm lvcreate VolGroup00 -n LogVol02 -L 100M
Rounding up size to full physical extent 128.00 MB
Logical volume "LogVol02" created
[kusune @ midori LVM2.2.02.32]$ sudo /sbin/fdisk /dev/mapper/VolGroup00-LogVol02
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): o
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-16, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-16, default 16):
Using default value 16
Command (m for help): p
Disk /dev/mapper/VolGroup00-LogVol02: 134 MB, 134217728 bytes
255 heads, 63 sectors/track, 16 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/mapper/VolGroup00-LogVol02p1 1 16 128488+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[kusune @ midori LVM2.2.02.32]$ sudo /sbin/partx -l /dev/mapper/VolGroup00-LogVol02
# 1: 63- 257039 ( 256977 sectors, 131 MB)
# 2: 0- -1 ( 0 sectors, 0 MB)
# 3: 0- -1 ( 0 sectors, 0 MB)
# 4: 0- -1 ( 0 sectors, 0 MB)
[kusune @ midori LVM2.2.02.32]$ sudo /sbin/partx -a /dev/mapper/VolGroup00-LogVol02
BLKPG: Invalid argument
error adding partition 1
BLKPG: Invalid argument
error adding partition 2
BLKPG: Invalid argument
error adding partition 3
BLKPG: Invalid argument
error adding partition 4
[kusune @ midori LVM2.2.02.32]$ cat /proc/partitions
major minor #blocks name
202 0 2097152 xvda
202 1 104391 xvda1
202 2 1992060 xvda2
8 1 3145728 sda1
8 2 131072 sda2
8 3 30965760 sda3
253 0 1212416 dm-0
253 1 294912 dm-1
253 2 131072 dm-2
[kusune @ midori LVM2.2.02.32]$
--
Takeshi Kusune <kusune @ sfc.wide.ad.jp>
centos-users メーリングリストの案内