Turn Your Ipod Into a ZFS Storage Device….And While you are at it, Why Don’t You Run a Sparse Zone on it as Well !
So the following is for pure fun and extremely destructive. Again, DESTRUCTIVE. Let me say it again DESTRUCTIVE
Since I know what I am doing ( a little bit more on this in a minute ), what you will need here is VirtualBox, Solaris 10 Update 9 installed on it as the guest OS and VirtualBox Extension Pack and an IPOD that you don’t care about.
WHY?
Well, First ZFS is really fun and its capabilities are tremendously useful. Second I have this certain distaste against the 4th generation Ipod Video. I think I used it about three months and then I stashed it on my bookcase. It started to pick some dust after that. I love the rest of Ipod Products. Third, ZFS is very inspirational, in fact this blog article is completely inspired by the video that was put together by some very talented engineers .
Greasy Details
So get your VirtualBox if you already have not done so, and install the extension pack. Back up your music files because by the end of this article they will be gone baby gone!.
So here is the system I have on VB:
root@solu9# cat /etc/release
Oracle Solaris 10 9/10 s10x_u9wos_14a X86
Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
Assembled 11 August 2010
root@solu9# uname -a
SunOS solu9 5.10 Generic_142910-17 i86pc i386 i86pc
Basically, your Ipod will act like a USB storage device for your Solaris System. After you install your VB and the Extension Pack, you will need to let your Guest OS to use the USB device from the GUI:
So boot your SM and connect to it either from your ssh terminal or just use the GUI itself. When you connect your ipod to the VirtualMachine, it is not going to be very obvious to you that it is there.
root@solu9# format
Searching for disks…doneAVAILABLE DISK SELECTIONS:
0. c0d0 <DEFAULT cyl 10440 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
I am only seeing one disk, which is c0d0. Additionally for my case I had to unmount CD/Drive because I had GuestAdditions installed on the OS. There are many ways of doing this, but I did the following for a quick and easy way:
root@solu9# /etc/init.d/volmgt stop
One way to see if the USB is really there is to use iostat:
root@solu9# iostat -En
c0d0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0
Model: VBOX HARDDISK ….
Vendor: Apple Product: iPod Revision: 1.62 Serial No:
Size: 30.01GB <30005821440 bytes>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 10 Predictive Failure Analysis: 0
Lookie what showed up above . So to really really see it, you’ll need to use format utility -e format
root@solu9# format -e
Searching for disks…doneAVAILABLE DISK SELECTIONS:
0. c0d0 <DEFAULT cyl 10440 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
1. c2t0d0 <DEFAULT cyl 3645 alt 2 hd 255 sec 63> ipod
/pci@0,0/pci8086,265c@b/device@1/storage@0/disk@0,0
So c2t0d0 is our guy. One thing to note here is that since we are going to be talking about ZFS pools, you will need to fdisk this partition and label it with EFI instead of SMI label.
AVAILABLE DISK SELECTIONS:
0. c0d0 <DEFAULT cyl 10440 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
1. c2t0d0 <DEFAULT cyl 3645 alt 2 hd 255 sec 63> ipod
/pci@0,0/pci8086,265c@b/device@1/storage@0/disk@0,0
Specify disk (enter its number): 1
selecting c2t0d0: ipod
[disk formatted]FORMAT MENU:
disk – select a disk
type – select (define) a disk type
partition – select (define) a partition table
current – describe the current disk
format – format and analyze the disk
fdisk – run the fdisk program
repair – repair a defective sector
label – write label to the disk
analyze – surface analysis
defect – defect list management
backup – search for backup labels
verify – read and display labels
save – save new disk/partition definitions
inquiry – show vendor, product and revision
scsi – independent SCSI mode selects
cache – enable, disable or query SCSI disk cache
volname – set 8-character volume name
!<cmd> – execute <cmd>, then return
quit
format> l
[0] SMI Label
[1] EFI Label
Specify Label type[0]: 1
Warning: This disk has an SMI label. Changing to EFI label will erase all
current partitions.
Continue? yesroot@solu9# format -e
Searching for disks…doneAVAILABLE DISK SELECTIONS:
0. c0d0 <DEFAULT cyl 10440 alt 2 hd 255 sec 63>
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
1. c2t0d0 <Apple-iPod-1.62-27.95GB>
/pci@0,0/pci8086,265c@b/device@1/storage@0/disk@0,0
Nice, so now we get to create our pool:
root@solu9# zpool create myipod c2t0d0s0
root@solu9# df -h
Filesystem size used avail capacity Mounted on
rpool/ROOT/s10x_u9wos_14a
78G 4.1G 72G 6% /
/devices 0K 0K 0K 0% /devices
….
rpool/export 78G 23K 72G 1% /export
rpool/export/home 78G 21K 72G 1% /export/home
rpool 78G 32K 72G 1% /rpool
rpool/zones 78G 29K 72G 1% /zones
myipod 27G 21K 27G 1% /myipod
Let’s see the status of our pools:
root@solu9# zpool status
pool: myipod
state: ONLINE
scrub: none requested
config:NAME STATE READ WRITE CKSUM
myipod ONLINE 0 0 0
c2t0d0s0 ONLINE 0 0 0errors: No known data errors
pool: rpool
state: ONLINE
scrub: none requested
config:NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
c0d0s0 ONLINE 0 0 0
Now here, we step back and realize once more how powerful zfs is. I created a zfs pool in this device and I am about to create a sparse zone which will be directly running on the Ipod. Instead of creating a scratch zone, I will be cloning a sparse zone into this device. I have an .xml file that is extracted from another zone:
root@solu9# cat zipod.xml
create -b
set zonepath=/myipod/ipodzone
set autoboot=false
set ip-type=shared
add inherit-pkg-dir
set dir=/lib
end
add inherit-pkg-dir
set dir=/platform
end
add inherit-pkg-dir
set dir=/sbin
end
add inherit-pkg-dir
set dir=/usr
end
add net
set address=192.168.1.185/24
set physical=e1000g0
end
add attr
set name=comment
set type=string
set value=”Zone zipod”root@solu9# zonecfg -z ipodzone -f /root/Configs/zipod.xml
root@solu9# zoneadm -z ipodzone clone -s rpool/zones/ztest@SUNWzone1 ztest
root@solu9# cp sysidcfg /myipod/ipodzone/root/etc/.
I had this sysidcfg file in hand so that I could copy into the ipodzone I created. Now let’s list the available zones:
root@solu9# zoneadm list -civc
ID NAME STATUS PATH BRAND IP
0 global running / native shared
……
– zperl installed /zones/zperl native shared
– ipodzone installed /myipod/ipodzone native shared
Take a note on the zonepath, it is residing on /myipod which is the pool I created earlier. Zfs list would show this nicer:
root@solu9# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myipod 375M 26.9G 23K /myipod
myipod/ipodzone 375M 26.9G 375M /myipod/ipodzone…..
This is pretty cool, all I need to do is to boot the zone now:
root@solu9# zoneadm -z ipodzone boot
root@solu9# zlogin ipodzone
[Connected to zone ‘ipodzone’ pts/4]
Last login: Fri Jun 17 23:24:31 on pts/4root@ipodzone# pwd
/root
root@ipodzone# ls
Downloads Scripts
root@ipodzone# uname -a
SunOS ipodzone 5.10 Generic_142910-17 i86pc i386 i86pc
Now I have a zone running on my usb drive. So this certain distaste of ipod turned into a delightful fun with ZFS and zones.