Setup Freenas iScsi Target
Pre-requisites
- A FreeNAS server with a ZFS filesystem. I have Freenas 8.04p2 with RAIDZ1 accross 3x2TB disks
- Another computer on the same network with Virtual Box installed - in my case an ubuntu 11.04 workstation (sudo apt-get install virtualbox virtualbox-guest-additions virtualbox-guest-additions-iso)
Create ZFS Volume
Easy with freenas, just needs a name and a size. My case - 'coppervmroot' and 30gb.
Set up iScsi
- Create a 'portal' - the default 0.0.0.0:3260 is fine.
- Create an 'authorized initiator' using the defaults (all/all)
- Create a target. name: coppervmroot, type 'disk', portal group '1', initiator group '1', auth method 'none.
- Create a device extent. coppervmrootextent refering to the coppervmroot ZVOL
- Create an 'associated target', in this case the coppervmrootextent and the coppervmroot target
- Turn on iscsi !
Testing from Ubuntu
Get the iscsi tools:
sudo apt-get install open-iscsi open-iscsi-utilsSee what volumes are exported by (as root)
# iscsiadm -m discovery -t sendtargets -p 10.xx.xx.xx:3260
10.xx.xx.xx:3260,1 iqn.2002-02.jfdi.org.tgt:coppervmroot
Try mounting a the iScsi volume as a local block device
# iscsiadm -m node --targetname iqn.2002-02.jfdi.org.tgt:coppervmroot --portal 10.xx.xx.xx:3260 --login
Logging in to [iface: default, target: iqn.2002-02.jfdi.org.tgt:coppervmroot, portal: 10.xx.xx.xx,3260]
Login to [iface: default, target: iqn.2002-02.jfdi.org.tgt:coppervmroot, portal: 10.xx.xx.xx,3260]: successful
And you should see a device appear in /var/log/syslog:
# tail -f /var/log/syslog
Jun 5 ... sd 4:0:0:0: [sdc] Attached SCSI disk
OK, so unmount it:
# iscsiadm -m node --targetname iqn.2002-02.jfdi.org.tgt:coppervmroot --portal 10.xx.xx.xx:3260 --logout
Logging out of session [sid: 1, target: iqn.2002-02.jfdi.org.tgt:coppervmroot, portal: 10.xx.xx.xx,3260]
Logout of [sid: 1, target: iqn.2002-02.jfdi.org.tgt:coppervmroot, portal: 10.xx.xx.xx,3260]: successful
Setup Virtual Box VM with iScsi target for HDD
You can't (yet!) manage an iscsi volume from the Virtual Box GUI. But you can do it with the vboxmanage command:
vboxmanage storageattach copper --storagectl sata0 --port 1 --device 0 --type hdd --medium iscsi --server 10.xx.xx.xx --target iqn.2002-02.jfdi.org.tgt:coppervmroot
That's it. Boot off a CD and install onto the iScsi HDD.
N.B. during installation my VM disconnected a couple of times. Resuming the VM (which stops automatically when this happens) seemed to do the trick.
No comments:
Post a Comment