header photo

sysadmin:~ caiozanolla#

dd if=/dev/me of=/dev/you

January 28, 2011

P2V a Linux Machine with an LVM

Filed under: hardware, linux, sysadmin, unix, virtualization — Caio @ 5:48 pm

VMware Converter is a great tool. It will easily convert most Linux systems with minor hassle.

There is one problem though. If the physical machine has an LVM it will some times confuse the converter and the resulting machine will not be consistent. Either it will fail to boot with wrong Grub entries pointing to old LVM volumes, will be missing a mount point or even be missing an entire drive.

Besides that, as a personal preference, i’d rather not use LVMs on single disk systems to avoid adding complexity to the layout. Unfortunately, some distros, specially RedHat makes default use of LVM and rushed admins will just leave it like that.
Anyway, the most practical way I found to deal with this is:

1 – Create a target VM with the hardware you want.
2 – Get hold of an install iso with the same distro/version as of the machine to be migrated
3 – Install the distro with minimal options. just enough to boot the VM.
4 – Log in the target VM, set up a network interface and bring up sshd.
5 – On the source machine, create a file “/tmp/exclude” with the following contents:

# cat /tmp/exclude
boot
proc
dev
sys
initrd
etc/hal
etc/fstab
etc/mtab
etc/lvm
etc/blkid
etc/udev
etc/mdadm
media/cdrom

PS. The contents of the file might be different on your setup, but the idea is to exclude things that will mess up booting and configuration of the target VM.

6 – on the source machine, tar everything and copy via ssh excluding the above by running:

cd /; tar -cvpf - -X /tmp/exclude * |ssh target "cd /; tar -xvpf - --numeric-owner"

7 – Reboot the VM and watch as it boots flawlessly :) . PS. RedHat will certainly prompt you to remove old hardware and configure new ones. Go on and do this. On the next boot the machine will be running clean.

July 7, 2010

proftpd daemon on VMware ESXi

Filed under: esxi, virtualization, vmware — Caio @ 7:52 pm

Running an ssh server within ESXi is a must nowadays, at least for me and for all those shell junkies out there :)

Now, try to transfer large files over ssh with scp or rsync and you’ll be pissed. Even on gigabit networks maximum throughput will be just a few MB/s.

This is expected behavior as explained here and here.

If you want to speed things up you could use vSphere Client’s datastore browser, VMware Converter and friends but you REALLY WANT to do it from ESXi shell so lets run ProFTPD:

1 – Get this file.
Its just an oem.tzg with proftpd daemon bundled, as well as its proftpd.conf.
ps. this oem.tgz was put together using the one from Dell Embedded ESXi 4 install image. It should be safe to use on any server brand though. Here and here there are the generic instructions if you would like to build your own.

2 – Copy it to ESXi /bootbank/oem.tgz.

3 – Add this line to /etc/inetd.conf.
“ftp stream tcp nowait root /usr/sbin/tcpd proftpd”

4 – Reboot ESXi.

Ftp will be happily listening on port 21 after boot.

June 2, 2010

Upgrading the CPU and Hard Drive of an iMac Aluminum (part 2)

Filed under: apple, hacking, hardware, macosx — Caio @ 4:35 am

Check out part 1 of this tutorial it you havan’t yet.

The surgery

Having all selected parts at hand, it was time to tear the iMac apart and change the components.

iFixit has very comprehensive tutorials on disassembling possibly every apple product there is, so I’m not walking you through this. Here are the instructions for the iMac at hand. Just click on “Heat Sink” and follow it.

Disassembling the iMac takes an hour. Not because it is difficult, but you will often find yourself staring at it thinking “damn, this is thing is awesome”. Don’t forget to have your thermal grease at hand to avoid finding yourself in the middle of the night with your machine in pieces unable to put it back because you forgot the goo. Also, you will need Torx 6, 8 and 10 wrenches.

Changing the processor is very easy, even if you never done it. Just make sure you have quality thermal compound at hand. I had a tube of premium grade compound Noctua NT-H1. It should keep the new processor confy on its new home.

Once again, if you got to this point it means you are very capable of changing the processor on you own. Put in the new one, spread the thermal goo, mount the heatsink back together and follow the iFixit guide backwards. Also, change the hardrive while you are at it. No surprises also, but you will need to take the thermal sensor from the old hd (it is glued) and stick it on the new one. Normally it will retain the glue when you take it off, so just put it on the same spot on the new hdd.

The results

If you got here dissapointed for the lack of pictures and details about the hardware part, well, im sorry but the whole point of this story is to prove it can be done without much hassle, and also warn you that the proccess is not as smooth as you think.

After putting everything back together and turning the iMac back on I realized the System Profiler was showing a 700MHz processor instead of a 2.6Ghz. I was shocked. Had all this trouble been in vain? would I have to dissassemble the whole damn thing to put the old CPU back in? would I have to sell the newly purchased SLAQH?

About This Mac

At this point I was freaking out, so I started searching for an answer. Shortly I got to this article: http://www.hexus.net/content/item.php?item=11295&page=1.
Basically it shows a failed attempt to upgrade an iMac processor for a X7900 Penryn.

According to them, the unlocked multiplier meant the mobo/efi didn’t knew how or didn’t care to manage multipliers. That was not my case though. The SLAQH has a 10x locked multiplier.

Anyways, their upgrade failed. Actually, it was the only attempt to upgrade an iMac I have ever found on the internet till this day. Lots of macminis, some white iMacs but not one Aluminum iMac. I hope I can change this.

Back to the problem at hand, there is no bios, no jumpers, no nothing, the speed is locked at 700Mhz so apparently I was fucked.

Then I realized boot time was not affected by the processor running at 700mhz. Well if the processor was really running at 700mhz I would certainly notice some delay in booting and other operations. Not that at this point I tried running anything. I was freaking out remember? So I fired up Xbench and waited.

Xbench finished the test and the results were stunning.

Not only the processor WAS NOT running at 700mhz, it was pretty damn fast. Comparing with my previous Xbench ran with the SLA45 my overall score went from a 152 to 170 points.

Time for another tool: MacCPPUID. Running it brought me yet more relief. It is an Intel tool that calculates the actual running speed of the processor. If it is being speedstepped it will show you exactly what the speed is at any given moment. I was glad to see it reported 2.59999999Ghz.

System Profiler, MacCPUID and xBench

Cool, now, instead of freaking out I am pissed off. How come System Profiler will only show 700mhz? Is it just cosmetic?

imac:~ caio$ sysctl -a | grep hw.cpu
hw.cpufrequency = 700000000
hw.cputype: 7
hw.cpusubtype: 4
hw.cpu64bit_capable: 1
hw.cpufamily: 2028621756
hw.cpufrequency: 700000000
hw.cpufrequency_min: 700000000
hw.cpufrequency_max: 700000000

For now I will just say the upgrade has succeeded… well, almost.

On part 3 I will try to explain the 700mhz mystery as well as some OSX internals, Kernel and EFI.

May 16, 2010

Upgrading the CPU and Hard Drive of an iMac Aluminum (part 1)

Filed under: apple, hacking, hardware, macosx — Caio @ 1:59 am

Motivation

Being an early adopter is good because well, you get to play first. Unfortunately, it also means that your hardware will be obsolete much earlier. Never mind paying premium. Thing is, eventually you will need better hardware and upgrading should keep you up to speed for some time.

Upgrading most non Apple hardware poses no problem as its very easy to just swap parts to keep up with software demands. For apple product though it can be a problem. Historically, apple products have been very difficult to upgrade except for some peripherals as hdd and memory.

This post will show you that “some” apple products will enable you to take upgrading much further. Mind that not all Intel macs are upgradable. Some of them will have BGA processors and are not suited for an upgrade. You can find out if yous has a Micro-FCPGA socket here.

We will be upgrading the CPU and Hard Drive of a mid 2007 iMac Aluminum.

The Rig

The iMac “Core 2 Duo” 2.0 20-Inch (Aluminum) features a 2.0 GHz Intel “Core 2 Duo” processor (T7300), with two independent processor “cores” on a single silicon chip, a 4 MB shared level 2 cache, an 800 MHz system bus, 4 GB of RAM (800 MHz DDR2 SDRAM), a 250 GB (7200 RPM) Serial ATA hard drive, a vertically-mounted slot-loading DVD+R DL “SuperDrive”, ATI Radeon HD 2400 XT graphics acceleration with 128 MB of GDDR3 memory, a built-in iSight video camera, and built-in stereo speakers underneath the 20″ glossy TFT Active Matrix LCD (1680×1050 native)

Choosing the right replacement parts.

- Hard Drive

There is no secret in choosing a replacement HDD. Any SATA model and it will work just fine. This site will help you choose a good one.

The iMac shipped with a Seagate ST3250820ASQ. It is a 7200 rpm drive with 8MB cache and it scores 323 points on Passmark test.
The replacement is a Maxtor STM3750330AS. It is a 7200 rpm drive with 32Mb of cache and it scores 590.

Benchmarks are based on sequential read/write and random read/write. And as stated, no secrets here, just get the biggest, fastest drive you can afford.

- CPU

The CPU has to be chosen carefully. There are constraints you have to take in account for choosing a correct replacement. Relevant parameters for choosing a replacement CPU are FSB speed, thermal design power and voltage range.

The FSB speed will ensure the replacement CPU will met specifications of the motherboard. Mind that on a mac you just cannot choose any FSB because there is no tweaking, no jumpers and no bios (its actually an EFI, but you wont be able to mess with it). Mine had 800mhz FSB so the processor would have to have the same FSB. If you choose a higher FSB processor, it will be underclocked. And because intel core 2 duo (except Extreme) has locked multipliers, the CPU speed will be underclocked too. So stick to your current FSB.

Thermal design is important too because there is no room for cooler/heatsink hacking. Your new processor will have to use the existing cooling solution. With that in mind you have to make sure your new processor dissipates the same amount of heat as the previews one.

Voltage range is critical. You cannot choose a processor that draws more energy than the previews one, period. Either it will not run smoothly under high loads, lock up or fry your motherboard. Stick to a processor that has close voltage requirements as the previews one.

With all that in mind I’ve chosen to replace the Intel T7300 (SLA45) that shipped with the iMac for a T9500 (SLAQH).

The T9500 is a 2.6Ghz, 6Mb cache and has the same 35W thermal design power. I also requires voltages within the boundaries of the SLA45 and should be a very safe replacement.

Head to Intel processor finder to choose choose your processor.

Part 2 is now avaliable, check it out!

April 15, 2010

How to disable journaling on a HFS+ volume

Filed under: Uncategorized — Caio @ 1:17 am

Mac OS X’s native file system (HFS+) supports journaling, a feature that is enabled by default on all new volumes. Journaling is a very nice feature as it allows a quick recovery of the file system’s status should anything bad happen to the machine — e.g. a power failure or a crash. With a journaled file system, the operating system can easily undo or redo the last operations executed on the disk without losing meta-data, effectively avoiding a full file system check.

However, journaling introduces a performance penalty for write operations. Every time the operating system has to modify the file system, it must first update the journal, then execute the real operation and at last mark the operation as completed in the journal. In most situations, this penalty is worth it for the reasons stated above. (Note: I haven’t benchmarked this penalty; it may be unnoticeable!)

There are some scenarios in which it can be avoided though. For example: I keep several disk images in my machine that hold the source code of some projects — NetBSD, pkgsrc — because these need to be placed in case-sensitive file systems. Up until now I had these configured as journaled HFS+ file systems, but I just figured out that I could gain some performance points by disabling this feature at the risk of losing the robustness introduced by journaling. After all, crashes are rare and power failures are non-existant in a laptop; plus the data stored in the images can be easily refetched at will in case of a disaster.

It turns out that the Disk Utility allows you to easily enable journaling for a volume (just check out the big icon in the toolbar), but the interface provides no way to disable it. Or at least I haven’t found that option. According to multiple articles I found, it was possible in older OS X versions. So I realized that the feature had to be available somewhere in recent versions.

And that’s right: the command-line diskutil program is able to disable journaling for a given mounted volume. Just run it as:

# diskutil disableJournal /Volumes/TheVolumeName

And voila! Journaling disabled.

shamelessly copied from: http://blog.julipedia.org/2007/04/how-to-disable-journaling-on-hfs-volume.html

March 20, 2010

Fix osx terminal for home, end, ctrl left, ctrl right.

Filed under: Uncategorized — Caio @ 1:03 pm

- control cursor left

\033b

- control cursor right

\033f

- home

\033[1~

- end

\033[4~

February 17, 2010

Hacking the Trendnet TEW652BRP v2 to work as a wireless bridge

Filed under: Uncategorized — Caio @ 3:37 pm

Although version 1 of this router is completely customizable through alternative firmwares, version 2 has another chipset and very little tweaking will be possible, for now.

The TEW652BRP v1 and v2 are two completely different routers. The first has a 400Mhz Atheros 9130 System on a Chip, making it perfect for aftermarket firmwares such as the openwrt. The former, although having the same model number sports a RealTek 330Mhz RTL8196B core. Both have 4MB Flash, 32MB RAM and 5 10/100 ethernet ports.

<code>
# cat /proc/cpuinfo
system type        : RTL8652
processor        : 0
cpu model        : R3000 V0.0
BogoMIPS        : 329.31
wait instruction    : yes
microsecond timers    : no
tlb_entries        : 32
extra interrupt vector    : no
hardware watchpoint    : no
ASEs implemented    :
VCED exceptions        : not available
VCEI exceptions        : not available
</code>

The source code of the RTL8196B driver is not publically avaliable and probably will have to be written from scratch. Chances are it will never happen.

Anyways, it does have some of its code under GPL so i’m trying to hack it to work on bridge mode.

As Trendnet has published the firmware source along with the required toolchain, the first thing I tried to do was get shell access at the router. Turned out it was not that easy.

Repackaging the firmware with /etc/inittab pointing to “/bin/busybox telnetd &” failed, as well as trying to run anything. Not even a simple ping would launch.
/etc/inittab, /etc/rcS, /etc/init.d/*, all failed to start any programs. Actually it was a very frustrating process as i had to recompile the firmware numerous times.

Reading through similar hardware information http://wiki.x-wrt.org/index.php/Trendnet_TEW-632BRP I managed to get shell through its serial port.
Pinout is shown below. Note that TX and RX are swapped, following the serial pinout from the TEW632 WILL NOT WORK. The right pinout for the TE652BRPv2 is:

<code>
pin 1 = +3.3V
pin 2 = TX
pin 3 = RX
pin 4 = Ground
</code>

Also, the speed of the serial port on this router is 38400.

For an easy interface, another router (WRT54gs) was used to make the serial connection avoiding the rs232 hassle.
One can just connect the wrt and trendnet serial lines directly. RX-TX  TX-RX  GND-GND
Once connected, just install and run picocom on the wrt like this:

<code>
~ # picocom -b 38400 /dev/tts/1
picocom v1.4

port is        : /dev/tts/1
flowcontrol    : none
baudrate is    : 38400
parity is      : none
databits are   : 8
escape is      : C-a
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : ascii_xfr -s -v -l10
receive_cmd is : rz -vv

Terminal ready
</code>

Here is the output from boot:

<code>
—RealTek(RTL8196B)at 2009.02.27-14:02-0500 version v1.3 [16bit](330MHz)
no rootfs signature at E0000!
Jump to image start=0×80500000…
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
Memory: 25876k/32768k available (2325k kernel code, 6892k reserved, 298k data, 120k init, 0k highmem)
Mount-cache hash table entries: 512
Checking for ‘wait’ instruction…  available.
NET: Registered protocol family 16
PCI: Bridge: 0000:00:00.0
IO window: 18c00000-18c00fff
MEM window: 19000000-190fffff
PREFETCH window: disabled.
PCI: Enabling device 0000:00:00.0 (0000 -> 0003)
NET: Registered protocol family 2
IP route cache hash table entries: 256 (order: -2, 1024 bytes)
TCP established hash table entries: 1024 (order: 0, 4096 bytes)
TCP bind hash table entries: 512 (order: -1, 2048 bytes)
TCP: Hash tables configured (established 1024 bind 512)
TCP reno registered
Squashfs 2.2-r2 (released 2005/09/08) (C) 2002-2005 Phillip Lougher
Squashfs 2.2 includes LZMA decompression support
io scheduler noop registered
io scheduler anticipatory registered (default)
Skipping PCI bus scan due to resource conflict
PCI: Bridge: 0000:00:00.0
IO window: 18c00000-18c00fff
MEM window: 19000000-190fffff
PREFETCH window: disabled.
Realtek GPIO Driver for Flash Reload Default
init gpio_ioctl Successful,  major = 201
Serial: 8250/16550 driver $Revision: 1.1.1.1 $ 1 ports, IRQ sharing disabled
serial8250: ttyS0 at MMIO 0×0 (irq = 12) is a 16550A
Probing RTL8186 10/100 NIC…
eth0 added. vid=9 Member port 0×1de…
eth1 added. vid=8 Member port 0×1…
PPP generic driver version 2.4.2
MPPE/MPPC encryption/compression module registered
NET: Registered protocol family 24
PPTP driver version 0.7
RTL8192SE driver version 1.15 (2009-09-08)
PCI: Enabling device 0000:01:00.0 (0000 -> 0003)
correcting to 32
RealTek E-Flash System Driver. (C) 2002 RealTek Corp.
Found 1 x 4M Byte MXIC MX29LV320AB at 0xbd000000
table size = 0×400000, table region is 4
mtd->numeraseregions = 0×4
Creating 5 MTD partitions on “DiskOnChip Millennium”:
0×00000000-0×00010000 : “boot+cal”
0×00010000-0×000f0000 : “linux”
0×000f0000-0×003e0000 : “rootfs”
0×003e0000-0×003f0000 : “nvram”
0×003f0000-0×00400000 : “mac”
Netfilter messages via NETLINK v0.30.
ip_conntrack version 2.4 (256 buckets, 2048 max) – 236 bytes per conntrack
ip_conntrack_rtsp v0.6.21 loading
ip_nat_rtsp v0.6.21 loading
ip_conntrack_pptp version 3.1 loaded
ip_nat_pptp version 3.0 loaded
ip_tables: (C) 2000-2006 Netfilter Core Team
ipt_time loading
ClusterIP Version 0.8 loaded successfully
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
Realtek FastPath v1.02
VFS: Mounted root (squashfs filesystem) readonly.
Go to out!!
Freeing unused kernel memory: 120k freed
mount /proc file system ok!
mount /var  file system ok!
init started:  BusyBox v1.01 (2010.02.08-23:07+0000) multi-call binary
BusyBox v1.01 (2010.02.08-23:07+0000) Built-in shell (ash)
Enter ‘help’ for a list of built-in commands.
</code>

As I said, trying to run things on this router from traditional startup scripts failed. Busybox on this router does have its inittab honoring enabled but it will just not work. It seems all the start/stop and management code is run from the “rc” proprietary code. Running through rc’s objects one can clearly see it has an important role.

<code>
caio@linuxdev:~/tew652/src/Matrix/projects/TEW-652BRPR1/apps/rc$ ls
app.o    firewall.o  Makefile  network.o  platform.o  process.o  rc    route.o  wantimer.o
build.h  lan.o       mtd.o     Pconfig    ppp.o       psmon.o    rc.o  wan.o    wlan.o
</code>

Anyway, the next step is to try and see if the wireless control tools has any hints on their inner workings.

Running strings on wlan.o shows calls to iwpriv, brctl and lots of other stuff.

To try to reverse its code would be a complete nightmare and I didnt have the time or knowledge to go down this route, so I took a different aproach.

Googling some of its strings, a realtek developers document showed up. Also some russian site with info on the DLINK G700.
Apparently, all wireless controls are the same for realtek chips, limited only by the the individual chips capabilities.
According to the specification, RTL8196B is capable of working on all modes, Client, AP and WDS.
Since the controls are avaliable as binaries (iwpriv), finding out the right commands was a matter of time.

My needs are only to bridge a pair of these TEW652BRP v2 so what I came up with was:

#set the working mode to Client.
<code>
iwpriv wlan0 set_mib opmode=8
</code>

#set the ssid of the access point to connect
<code>
iwpriv wlan0 set_mib ssid=”TRENDNETACCESSPOINT”
</code>

The rest of the configuration can be made from the administrative interface as they are shared among all working modes.

So, to brigde both routers what I did was:

replicate all wireless settings on both routers
issue a “iwpriv wlan0 set_mib opmode=8″ on the client
ifconfig down/up on wlan0 interface of the client

After that the access point showed the client mac address connected as one of its clients.

Next, get this things done on boot time. Although busybox does not read inittab or any other default init scripts, it does source /etc/profile, so it can be done from there.

January 3, 2010

Eight Ways to Kill An Idea

Filed under: Uncategorized — Caio @ 3:36 pm

*original work by Scott Campbell

Eight ways to kill an idea

Eight ways to kill an idea

March 19, 2009

convertendo uma instalacao normal em RAID1

Filed under: Uncategorized — Caio @ 1:17 am

Adicionando um segundo hd, juntando tudo num RAID1, e com alguma sorte não perdendo nada.

1 – adicionar o segundo hd

root@ubuntu:/home/caio# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×00008f89

Device Boot Start End Blocks Id System
/dev/sda1 * 1 993 7976241 83 Linux
/dev/sda2 994 1044 409657+ 5 Extended
/dev/sda5 994 1044 409626 82 Linux swap / Solaris

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0×00000000

Disk /dev/sdb doesn’t contain a valid partition table

2 – instalar suporte a raid

root@ubuntu:/home/caio# apt-cache search mdadm
mdadm – tool to administer Linux MD arrays (software RAID)
root@ubuntu:/home/caio# apt-get install mdadm
Reading package lists… Done
Building dependency tree
Reading state information… Done
Recommended packages:
mail-transport-agent
The following NEW packages will be installed:
mdadm
0 upgraded, 1 newly installed, 0 to remove and 266 not upgraded.
Need to get 220kB of archives.
After unpacking 627kB of additional disk space will be used.
Get:1 http://br.archive.ubuntu.com gutsy/main mdadm 2.6.2-1ubuntu2 [220kB]
Fetched 220kB in 2s (99.3kB/s)
Preconfiguring packages …
Selecting previously deselected package mdadm.
(Reading database … 92659 files and directories currently installed.)
Unpacking mdadm (from …/mdadm_2.6.2-1ubuntu2_i386.deb) …
Setting up mdadm (2.6.2-1ubuntu2) …
Generating mdadm.conf… done.
Removing any system startup links for /etc/init.d/mdadm-raid …
update-initramfs: deferring update (trigger activated)
* Starting MD monitoring service mdadm –monitor [ OK ]

Processing triggers for initramfs-tools …
update-initramfs: Generating /boot/initrd.img-2.6.22-14-generic

3 – clonar a a tabela de particao e salvar backup da tabela no arquivo setores-sdb.bak

root@ubuntu:/home/caio# sfdisk -d /dev/sda | sfdisk /dev/sdb -O setores-sdb.bak
Checking that no-one is using this disk right now …
OK

Disk /dev/sdb: 1044 cylinders, 255 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
/dev/sdb1 * 63 15952544 15952482 83 Linux
/dev/sdb2 15952545 16771859 819315 5 Extended
/dev/sdb3 0 – 0 0 Empty
/dev/sdb4 0 – 0 0 Empty
/dev/sdb5 15952608 16771859 819252 82 Linux swap / Solaris
Successfully wrote the new partition table

Re-reading the partition table …

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

4 – setar tipos de todas as particoes de /dev/sdb para FD (Linux raid autodetect), exceto a particao extendida

root@ubuntu:/home/caio# sfdisk –change-id /dev/sdb 1 FD
Done
root@ubuntu:/home/caio# sfdisk –change-id /dev/sdb 3 FD
Done
root@ubuntu:/home/caio# sfdisk –change-id /dev/sdb 4 FD
Done
root@ubuntu:/home/caio# sfdisk –change-id /dev/sdb 5 FD
Done

5 – criar RAID devices (modo degradado). md0 para a raiz e md1 para swap

root@ubuntu:/home/caio# mdadm -C /dev/md0 –level=raid1 –raid-devices=2 missing /dev/sdb1
mdadm: array /dev/md0 started.
root@ubuntu:/home/caio# mdadm -C /dev/md1 –level=raid1 –raid-devices=2 missing /dev/sdb5
mdadm: array /dev/md1 started.
root@ubuntu:/home/caio# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1]
7976128 blocks [2/1] [_U]

md1 : active raid1 sdb5[1]
409536 blocks [2/1] [_U]

unused devices:

6 – criar swap no /dev/md1

root@ubuntu:/home/caio# mkswap /dev/md1
Setting up swapspace version 1, size = 419360 kB
no label, UUID=9e18cec6-63a5-434a-9581-f99b58fbaadd
root@ubuntu:/home/caio# swapon /dev/md1
root@ubuntu:/home/caio# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 409616 0 -1
/dev/md1 partition 409528 0 -2

7 – criar sistema de arquivos no md0

root@ubuntu:/home/caio# mkfs -t ext3 /dev/md0
mke2fs 1.40.2 (12-Jul-2007)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
997472 inodes, 1994032 blocks
99701 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2042626048
61 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

8 – copiar todos arquivos para o novo device RAID

root@ubuntu:/home/caio# mkdir /mnt/md0
root@ubuntu:/home/caio# mount /dev/md0 /mnt/md0/
root@ubuntu:/# find . -xdev -print0 | cpio -0pdvum –sparse /mnt/md0

9 – alterar fstab

# /dev/sda1
#antes
#UUID=e40d8ae6-03c1-4519-91d9-2d2b17a23832 / ext3 defaults,errors=remount-ro 0 1
#depois
/dev/md0 / ext3 defaults,errors=remount-ro 0 1

# /dev/sda5
#antes
#UUID=e596805b-c899-4c46-981e-56d6dc6ae600 none swap sw 0 0
#depois
/dev/md1 /swap sw 0 0

10 – editar menu.lst

title Ubuntu 7.10, kernel 2.6.22-14-generic RAID
root (hd0,0)
kernel /boot/vmlinuz-2.6.22-14-generic root=/dev/md0 ro quiet nosplash
initrd /boot/initrd.img-2.6.22-14-generic-raid
quiet

11 – instalar o grub

grub> device (hd0) /dev/sdb
grub> root (hd0,0)
grub> setup (hd0)
Checking if “/boot/grub/stage1″ exists… yes
Checking if “/boot/grub/stage2″ exists… yes
Checking if “/boot/grub/e2fs_stage1_5″ exists… yes
Running “embed /boot/grub/e2fs_stage1_5 (hd0)”… 17 sectors are embedded.
succeeded
Running “install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst”… succeeded
Done.
grub> quit

12 – criar novo initrd para o RAID

cd /mnt/md0
mount -o bind /proc ./proc
mount -o bind /dev ./dev
chroot /mnt/md0
mkinitramfs -r /dev/md0 -o initrd.img-2.6.22-14-generic-raid

13 – testar boot

entrar no grub, setar root como hd1,0
definir configfile como /boot/grub/menu.lst
bootar.
o sistema deve bootar normalmente mas pelo RAID (ainda em modo degraded)

14 – configurar as particoes do sda para RAID

root@ubuntu:/home/caio# sfdisk –change-id /dev/sda 1 FD
Done
root@ubuntu:/home/caio# sfdisk –change-id /dev/sda 3 FD
Done
root@ubuntu:/home/caio# sfdisk –change-id /dev/sda 4 FD
Done
root@ubuntu:/home/caio# sfdisk –change-id /dev/sda 5 FD
Done

15 – Adicionar os sda ao RAID

root@ubuntu:/home/caio# mdadm /dev/md0 -a /dev/sda1
mdadm: added /dev/sda1
root@ubuntu:/home/caio# mdadm /dev/md1 -a /dev/sda5
mdadm: Cannot open /dev/sda5: Device or resource busy

ops, o sda5 esta sendo usado para swap

root@ubuntu:/home/caio# swapon /dev/md1
root@ubuntu:/home/caio# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 409616 0 -1
/dev/md1 partition 409528 0 -2
root@ubuntu:/home/caio# swapoff /dev/sda5
root@ubuntu:/home/caio# swapon -s
Filename Type Size Used Priority
/dev/md1 partition 409528 0 -2

root@ubuntu:/home/caio# mdadm /dev/md1 -a /dev/sda5
mdadm: added /dev/sda5

agora sim. neste momento o RAID está sendo sincronizado.
verifique o status com:

root@ubuntu:/home/caio# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda5[0] sdb5[1]
409536 blocks [2/2] [UU]

md0 : active raid1 sda1[0] sdb1[1]
7976128 blocks [2/2] [UU]

unused devices:

16 – reinstalar grub

grub>
device (hd0) /dev/sda
root (hd0,0)
setup (hd0)
quit

17 – bootar e certificar que tudo funciona e que o raid está integro

caio@ubuntu:~$ cat /proc/mounts
rootfs / rootfs rw 0 0
none /sys sysfs rw,nosuid,nodev,noexec 0 0
none /proc proc rw,nosuid,nodev,noexec 0 0
udev /dev tmpfs rw 0 0
fusectl /sys/fs/fuse/connections fusectl rw 0 0
/dev/md0 / ext3 rw,data=ordered 0 0
/dev/md0 /dev/.static/dev ext3 rw,data=ordered 0 0
tmpfs /var/lock tmpfs rw,nosuid,nodev,noexec 0 0
tmpfs /lib/modules/2.6.22-14-generic/volatile tmpfs rw 0 0
tmpfs /dev/shm tmpfs rw 0 0
devpts /dev/pts devpts rw 0 0
tmpfs /var/run tmpfs rw,nosuid,nodev,noexec 0 0
tmpfs /var/lock tmpfs rw,nosuid,nodev,noexec 0 0
securityfs /sys/kernel/security securityfs rw 0 0
caio@ubuntu:~$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sda5[0] sdb5[1]
409536 blocks [2/2] [UU]

md0 : active raid1 sda1[0] sdb1[1]
7976128 blocks [2/2] [UU]

unused devices: <none>

March 3, 2009

Último dia do julgamento do TPB (The Pirate Bay)

Filed under: Uncategorized — Caio @ 1:10 pm

Terminou hoje o julgamento do caso do The Pirate Bay.
Por se tratar de um caso “complexo”, a sentença só será dada em 14 de abril de 2009 às 10:00 UTC.

Demostre seu apoio assim:

- Envie tweets com a keyword #spectrial

- Abra uma conta em www.bambuser.com e poste um video. Ele poderá ser passado no onibus estacionado do lado de fora do forum em Stockholm.
Veja como faze-lo:

- Assista a coletiva? de imprensa na integra aqui:
http://bambuser.com/channel/Spectrial/broadcast/73736

- Assista aos videos de Anna Oscarsson, RP? do TPB aqui:
http://bambuser.com/channel/Spectrial

- Acompanhe o blog do TPB sobre o julgamento aqui:
http://trial.thepiratebay.org/

Contato

Caio Zanolla
zanolla@gmail.com
+55 31 9177-2980
Belo Horizonte - MG
BRASIL

View Caio Zanolla's profile on LinkedIn Follow zanolla on Twitter

Status Atual

Disponível para:
Consultoria
Freelance
Contratos de curta duração
Contratos de longa duração
Efetivação CLT
Projetos
Viajens

Especialidades

Servidores:
Unix
Linux
BSD
Windows

Integraçao:
Asterisk
Samba
LDAP
AD

Storage:
Local
NAS
NFS
iSCSI
Fiber Channel
auth LDAP/AD

Virtualização:
VmWare Server
ESXi
vCenter
vSphere
XEN

Telefonia VoIP:
Asterisk
AGI
IVR
Realtime
auth LDAP/AD.

Redes:
seguranca
firewall
disponibilidade
dual wan
balanceamento de carga.

Hardware:
dimensionamento
aquisicao
manutencao
tunning
troubleshooting

Gerencial:
Gerencia de projetos
Governança de TI
Planejamento estratégico
Segurança da Informação