Skip to content

Instantly share code, notes, and snippets.

@rubiojr
Created November 15, 2011 12:47
Show Gist options
  • Save rubiojr/1367008 to your computer and use it in GitHub Desktop.
Save rubiojr/1367008 to your computer and use it in GitHub Desktop.
Create raw disk, loop mount and serve via iscsi
#!/bin/sh
yum install -y qemu-img iscsi-initiator-utils scsi-target-utils.x86_64 qemu-img --nogpgcheck
mkdir /data
qemu-img create /data/netdisk01.raw 10G
losetup /dev/loop0 /data/netdisk01.raw
cp /etc/tgt/targets.conf /etc/tgt/targets.conf.bak
cat > /etc/tgt/targets.conf <<EOF
default-driver iscsi
<target iqn.2008-09.com.example:server.target1>
backing-store /dev/loop0
</target>
EOF
service tgtd start
chkconfig tgtd on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment