A college buddy of mine has posted a tutorial on Meta II, a simple compiler/compiler that could express itself in just over a dozen lines.
We were impressed with what could be done with this "meta" compiler that dated back to 1964.
It still has uses today and can be easier to use for some projects than Lex/Yacc or LALRn compilers.
The tutorial can be found at his company website: http://www.bayfronttechnologies.com/mc_tutorial.htm.com
I put things here that I want to remember at some future time.
Thursday, December 17, 2009
Wednesday, April 15, 2009
Expanding a ZFS OpenSolaris (VirtualBox) VDI
Intro
I have been working using a OpenSolaris guest OS in VirtualBox hosted on XP.My original disk was set to a maximum of 16Gb.
Recently, my Boot Environment reached 12Gb, leaving little space for my stuff and not enough space to perform the next update.
If my guest OS was XP or Linux, I could have used the published technique of dd copying into a new VDI and using GParted or PartitionMagic to expand the partition in the new volume. XFS bring the different animal it is, and not finding an tool to expand the partition under OpenSolaris, I have found the following procedure to work.
Overview
In brief, here are the steps I took.- dd copied VDI contents into a larger VDI
- Expanded the partition definition.
- Edited the segment table to match the new partition
Gory Details
Going from a 16Gb VDI to a 30Gb VDI.- Use the "VBoxManage clonehd" command to make a copy of the VDI.
This is necessary to create a new VDI with a different UUID. - Create an new (suggest "dynamically expanding") VDI of the larger size.
- Attach the clone copy and the new VDIs to a Linux virtual machine.
My personal preference is Knoppix, because I can get it to boot into non-graphical multi-user mode by entering "knoppix 2" at the "boot:" prompt. - Find out the devices that the disks are mounted on using fdisk:
> fdisk -l
Disk /dev/hda: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Disk identifier: 0xeb5b91f0
Device Boot Start End Blocks Id System
/dev/hda1 1 4161 2097112+ 82 Linux swap / Solaris
Disk /dev/hdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Disk /dev/hdb doesn't have a valid partition table
Disk /dev/hdd: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/hdd1 * 2 2088 16763827+ bf Solaris
From the above we can tell the following:- /dev/hdb is the new disk (no partition table)
- /dev/hdd is the clone (System=Solaris)
- Further we note the start/end cylinders for partition 1 on both the drives of interest:
- hdb 2/3916
- hdd 2/2088
- With the Linux virtual machine, dd copy the clone contents into the new (empty) VDI.
e.g. dd if=/dev/hdc of=/dev/hdn bs=M
where c and n are for the drives are the clone and new VDIs.
For this specific case:
dd if=/dev/hdd of=/dev/hdb bs=M
Note: This copy operation will have duplicated the UUID of the clone into the new VDI. This means that you cannot have both the clone VDI and the new VDI registered with VirtualBox at the same time. - In the new VDI, using fdisk, delete the partition 1 definition and recreate it with a new ending cylinder.
> fdisk /dev/hdn
Command (m for help): p
Disk /dev/hdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/hdb1 * 2 2088 16763827+ bf Solaris
Command (m for help): d
Selected partition 1
Command (m for help): n
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3916, default 1): 2
Last cylinder or +size or +sizeM or +sizeK (1-3916, default 3916):
Using default value 3916
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): bf
Command (m for help): a
Command (m for help): p
Disk /dev/hdb: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/hdb1 * 2 3916 31447237+ bf Solaris
Command (m for help): w
Note the following in the above about the partition on the new VDI:- The original end cylinder is the same as on the clone VDI we dd'ed from.
- The final end cylinder matches the number of cylinders in the new VDI.
Write this value down, you will need it later.
- Exit the Linux VM and define a new virtual machine that uses the new VDI as the primary disk.
- Start the new virtual machine, and look at the disk usage using df -h .
This shoud be identical the the original VDI you started with. - Expand the Solaris partition to use the full partition:
> pfexec su -
# format -e
Searching for disks...done
AVAILABLE DISK SELECTIONS:
0. c3d0
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
Specify disk (enter its number): 0
selecting c3d0
NO Alt slice
No defect list found
[disk formatted, no defect list found]
/dev/dsk/c3d0s0 is part of active ZFS pool rpool. Please see zpool(1M).
FORMAT MENU:
:
format> p
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
:
partition> print
Current partition table (original):
Total disk cylinders available: 3913 + 2 (reserved cylinders)
Part Tag Flag Cylinders Size Blocks
0 root wm 1 - 2084 15.96GB (2084/0/0) 33479460
1 unassigned wm 0 0 (0/0/0) 0
2 backup wu 0 - 2084 15.97GB (2085/0/0) 33495525
3 unassigned wm 0 0 (0/0/0) 0
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 unassigned wm 0 0 (0/0/0) 0
8 boot wu 0 - 0 7.84MB (1/0/0) 16065
9 unassigned wm 0 0 (0/0/0) 0 - Note the available cylinders value. This should be very close to the end cylinder value seen in Linux. The end value you want to set in this next step, should be the available cylinders less 1. This value should be suffixed with the letter "e". We set the end cylinder for both partition 0 and 2. After that we write out changes out using the label command.
partition> 0
Part Tag Flag Cylinders Size Blocks
0 root wm 1 - 2084 15.96GB (2084/0/0) 33479460
Enter partition id tag[root]:
Enter partition permission flags[wm]:
Enter new starting cyl[1]:
Enter partition size[33479460b, 2084c, 2084e, 16347.39mb, 15.96gb]: 3912e
partition> 2
Part Tag Flag Cylinders Size Blocks
2 root wm 0 - 2084 15.96GB (2084/0/0) 33479460
Enter partition id tag[root]:
Enter partition permission flags[wm]:
Enter new starting cyl[1]:
Enter partition size[33479460b, 2084c, 2084e, 16347.39mb, 15.96gb]: 3912e
partition> label
[0] SMI Label
[1] EFI Label
Specify Label type[0]: 0
Ready to label disk, continue? y
partition> quit
format> quit - Finally we setup to have devices reconfigured:
> touch /reconfigure - Reboot guest OpenSoalris system
- Log in and verify with df -h that the disk size has changed.
- Done.
Subscribe to:
Posts (Atom)