星期三, 1月 16, 2008

iscsi 開機自動掛載

server side (Centos)
修改 /etc/init.d/tgtd
start 結尾加入
------------------------------------------------------------------------------------------------------------------------
sleep 1s
tgtadm --mod target --op new --tid=1 --targetname=pcname
tgtadm --mod logicalunit --op new --tid=1 --lun=1 --backing-store=/dev/
i2o/hdx
tgtadm --mode target --op bind --tid=1 --initiator-address=192.168.0.1
------------------------------------------------------------------------------------------------------------------------
stop 開頭加入
------------------------------------------------------------------------------------------------------------------------
tgtadm --mode target --op delete --tid=1
sleep 1s
-----------------------------------------------------------------------------------------------------------------------

client side (Ubuntu)
修改/etc/iscsi/iscsid.conf ==> node.startup = automatic
修改/etc/init.d/open-iscsi
starttargets 結尾加入
------------------------------------------------------------------------------------------------------------------------
sleep 1s
mount /mnt/iscsi_folder

------------------------------------------------------------------------------------------------------------------------
stoptargets 開頭加入
------------------------------------------------------------------------------------------------------------------------
umount /mnt/iscsi_folder
iscsiadm --mode node --target pcname --logout

-----------------------------------------------------------------------------------------------------------------------

 2013/10/4補充
較新的系統可以在/etc/fstab的iscsi設備設為 auto,_netdev ,automount會自動將這個device排在網路啟動後才掛載。

星期三, 1月 09, 2008

mount a virtual disk

Case1. image file
  1. on guest run -> fdisk -luC /dev/hda
  2. on host run -> mount -o loop,offset 9999999 image_file /mnt/image 9999999=partion start point=start*unit
Case2. physical partition as virtual disk
  1. on host run -> kpartx -av /dev/partion #This tool create device maps from partition tables under /dev/mapper
  2. on host run -> mount /dev/mapper/partion /mnt/virtual_partion