Suponha que você tem um processo chamado program e quer congelar seu funcionamento. Para congela-lo sem mata-lo você pode mandar um sinal SIGSTOP com:
I thought about these two problems my entire life.
Graphical arts have a significant role in everything I do. I always expressed my feelings thorough graphical drawings. First on paper, so notebooks, then walls and others surfaces like the computer screen. But the possibility of transform my body, my own skin in a art canvas always fascinated me. This was a natural step.
But the tattoo is an art that raises a tricky philosophical question, it’s something that you can not undo it. Once you did it, it’s done. You can change or add the meaning with others tattoos but you can not remove meaning of a draw in a negative way by erasing it like other forms of arts. Of course there’s some kinds of treatments with different approaches and variant results but I see no point on think about tattoos looking on how remove them. It seems obvious that doesn’t matter how cool and incredible something could appear or how sure I am about it, I could always change my mind and repent. This puzzle was around my mind for a long time until finally I saw way out.
The key is that the life you live itself is also a tattoo. You say words that cannot be unsaid. You see things that you can not unseen.You feel such strong emotions that you can not heal your scars. Every moment it’s also a tattoo in the thin skin of the time and there’s nothing you can do about that because the time flows only in one direction. Of course you don’t paint all your life with ink in your own skin but at least, you can choose some parts of it to express as a beautiful tattoo.
The second problem is witch draw do. There are hundred of drawings that I love and besides I also enjoy old school tattoo drawings, I choose a piece of programming code. More specifically the Jaromilmost elegant forkbomb code ever written:
This small piece of code fork itself twice in parallel creating more processes that will be forked again and again until stop the entire system. You can read a more detailed explanation on its operation, history and variations on Wikipedia’s Fork bomb article.
It has several meanings to me, from the aesthetics from the computer science field to the shape and possibilities the draw allow. The exponential grow of the number of forked process it’s also another beautiful aspect of this code. From the viewer perspective, even a casual one, it has a beautiful as a puzzle to be decipher or a totem pole of different emoticons.
Blood and ink.
I tried for months several different fonts and styles to use on it, from mono space to stylized draws. In the end I choose the Bitstream Vera Sans by Jim Lyles. A free (as in freedom) font very common on GNU/Linux systems. I also did small change in the draw by reducing almost entirely the spacing between the braces. This made it look better when looking it by side creating a stronger emoticon illusion.
Blood stain in the paper towel after dry the finished tattoo.
The process almost doesn’t involve pain and hurt, in contrast with what I thought. It’s like a little cat scratch in your arm for almost 2 hours of painting. I did in the Freedom of Tattoo studio, from the well-known here tattoo artist Dereka, with Thiago, a very skilled artist.
My thanks to the studio, to Dereka, to Thiago and to my friend Silvio who took the pictures and accompanied me. There’s a photo album with all tattoo photos. I’m very happy with the final work.
I created some illustrative and simple implementations of common Unix commands. For those who are familiar with Unix-like systems them make easier to understand Java. For those who are familiar with Java them make easier to understand Unix-like systems. 🙂
1. PWD
The first one is pwd that show the current working directory.
public class Jpwd {
public static void main(String[] args) {
String pwd = System.getProperty("user.dir");
System.out.println(pwd);
}
}
Running this at /home/silveira directory gives us as output:
$ java Jpwd
/home/silveira
1. CAT
The command cat is usually utilized for displaying files.
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class Jcat {
public static void main(String[] args) {
if(args.length==1){
try {
FileReader fileReader = new FileReader(args[0]);
BufferedReader in = new BufferedReader(fileReader);
String line;
while((line = in.readLine())!= null){
System.out.println(line);
}
} catch (FileNotFoundException ex) {
System.out.println(args[0]+", file not found.");
}
catch (IOException ex) {
System.out.println(args[0]+", input/output error.");
}
}
}
}
$ java Jcat /etc/timezone
America/Fortaleza
3. LS
The command ls is to list files. The File API (java.io.File) is very flexible and portable, but in this example I want just list files and directories of the current directory.
import java.io.File;
public class Jls {
public static void main(String[] args) {
File dir = new File(System.getProperty("user.dir"));
String childs[] = dir.list();
for(String child: childs){
System.out.println(child);
}
}
}
Usage:
$ java Jpwd
/home/silveira/example
$ java Jls
directoryA
fileA
.somefile
4. CD
The cd command changes the current working directory.
import java.io.File;
public class Jcd {
public static void main(String[] args) {
if(args.length==1){
File dir = new File(args[0]);
if(dir.isDirectory()==true) {
System.setProperty("user.dir", dir.getAbsolutePath());
} else {
System.out.println(args[0] + "is not a directory.");
}
}
}
}
This is the first of a serie of posts I’d like to write while I’m studying more about OpenSolaris. The idea is to create simple posts showing a specific feature through practical examples that you can reproduce in your computer.
One of the most interesting feature on OpenSolaris is the 128-bit filesystem ZFS.
For those who are starting with ZFS, the main diference is the abstraction used for volumes. Unlike traditional file systems, which reside on single devices and thus require a volume manager to use more than one device, ZFS filesystems are built on top of virtual storage pools called zpools. One zpool is constructed of virtual devices (vdevs), which are themselves constructed of block devices: files, hard drive partitions, or entire drives (the recommended usage).
In this first experiment we will construct a mirrored zpool (RAID-1) and so try to corrupt its data and see what happens. In a mirrored pool the data is replicated into many disks and that eliminates the critical point, ie if one disks stops the data is not corrupted. You’ll can create a mirror with two or more disks and inside a pool you can have many mirrors. By example, one pool of 100Gb made by two mirrors, each one with 50Gb and each mirror made by volumes of 25Gb. You’ll scale your pool according your needs and capabilities.
This part of corrupt data make this experiment a little dangerous. You have these options:
Install OpenSolaris in your disk and have at least two more disks to make a mirrored zpool. I don’t recommend this option because if you don’t know exactly what you are doing you can lose important data if you use the wrong volumes.
Install OpenSolaris in a virtual machine and create fake volumes for this experiment. If you make some mistake nothing too bad will happen. That’s the option I’m using. Here I’m using VirtualBox with OpenSolaris 2008.5. VirtualBox is a free virtual machine, easy to use and works well with OpenSolaris.
Although there is already a graphical tool for manage ZFS, this is not available at OpenSolaris 2008.5. Also for who are studying ZFS a little bit deeper, know how to manage it by command line tools is interesting.
With your OpenSolaris booted, open a terminal and log yourself as root. Consult your available devices with echo|format.
If you are familiar with Linux, OpenSolaris nomenclature for devices may sound strange. I recommend you to take a look at this document.
To create a pool with the devices c4d1 (80G) and c5d1 (60GB) just type zpool create ourpool mirror c4d1 c5d1.
Explaining this command word by word:
zpool: for manage ZFS you need to be familiar with only two commands: zpool and zfs. Zpool command is for configure and manage ZFS pools.
create: the action, in this case, creation.
ourpool: name I chose for the pool.
mirror: we want a mirror in ourpool, so the next words will be more devices.
If your command works, it’ll works silently e will returns nothing. For check pool’s status do a zpool status ourpool.
This output shows that a pool called ourpool is ONLINE and is made of one only mirror, that is made of two devices c4d1 e c5d1.
We can list all pools with zpool list.
Ourpool has approximately 60Gb size which 900kb is already used for store metadata. As we did a mirror using volume of 60Gb and 80Gb, the mirror size is determined by the smaller volume. The another pool, rpool is a pool that OpenSolaris creates by defaul to place the system.
Now we’ll populate the pool with data. These data could be real important data like data base files, your photo collection or personal documents. For illustrative effect I’m using a 100Mb empty file called data. mkfile 100m data.
While the file creation I did a zpool iostat -v ourpool too see the IO traffic in the pool. Note that there’s traffic on both disks as they form a mirror.
We will create and save a file of md5 checksum of date to be able to check its integrity later, md5sum data > data.md5. Too see if a checksum matches we do a md5sum –check data.md5.
Now comes the critical part of this simulation. We will simulate a physical defect on the disc. Storage devices will fail at some point, but we don’t know when. When it happens it can corrupt your data or stop important applications.
Let’s get 20Mb of garbage from /dev/urandom e throw them in the disk c4d1, dd if=/dev/urandom of=/dev/dsk/c4d1 bs=1024 count=20480. There’s more fun (and expensive) ways to case physical defects in a disk, take a look into this video where they use ZFS and hammers. 🙂
Ready, the damage was done. Let’s look the pool status, zpool status ourpool.
We see no error but the ZFS uses strongly memory cache. Let’s force clean this cache by disabling and enabling the pool. First cd / to assure we are not into the pool, so zpool export ourpool followed by zpool import ourpool.
Checking it’s status again, zpool status ourpool.
Pool remains ONLINE but ZFS noticed that something is wrong.
Let see the data integrity, md5sum –check data.md5.
Data are intact.
This is one of the characteristic of self healing in ZFS. The corruption that occurred in one volume was silently repaired. In a traditional volume manager you would not only lost our data but not event know that a corruption has occurred.
In this point the system administrator should be warmed to take some action on the defective disk. Here some advices:
Find out the defective disk: if the disk fails once so is probably that it’ll fail again or even take others disks to fail. ZFS have a mechanism called scrubbing that scan blocks finding out checksum erros and trying to correct them using the safe data. A zpool scrub ourpool will force the scrubbing process, that will run in background. After that If you look at the pool status zpool status ourpool you can see which disk is the defective one.
Look the pool history: you can examine all pool history and understand all that happening before you came. A zpool history ourpool will show all commands that was used since its creation.
Repair de mirror: a zpool clean ourpool will repair the mirror, but keeps the defective disk, what can be dangerous.
Turn off the defective disk: you can turn off it using a zpool offline ourpool c4d1 without alter the pool structure.
Unmirror the pool: with a zpool detach ourpool c4d1 you can remove the device from the pool, but as the mirror was composed of two devices, it’s no longer a mirror.
Change the defective disk: if you have another disk, like c6d1, you put it in the place of the defective disk and it’ll assume it role in the mirror. For that use a zpool replace c4d1 c6d1. This will start in background a process called resilvering, but that is subject for another post. 🙂
I also did a screencast the resumes the entire process:
Esse primeiro experimento vai ser construir zpool espelhado (RAID-1) e depois tentar corromper os dados dele e ver o que acontece. Em um pool espelhado, os dados são replicados para vários discos e isso elimina o ponto crÃtico, ou seja, se um disco parar de funcionar, os dados não são corrompidos. Você pode criar um espelho com dois ou mais discos e dentro de um mesmo pool você pode ter vários espelhos. Por exemplo, um pool de 100Gb formado por dois espelhos, cada um com 50GB e cada espelho formado por discos rÃgidos de 25Gb cada um. Você vai dimensionar seu pool de acordo com suas necessidades e capacidades.
Essa parte de corromper os dados faz experimento ser um pouco perigoso. Eu te aconselho a fazer uma dessas sugestões:
Instalar o OpenSolaris no seu disco e pelo menos outros dois discos rÃgidos para fazer um zpool espelhado. Eu não recomendo essa opção porque se você não souber muito bem o que está fazendo você pode corromper dados acidentalmente.
Com o OpenSolaris já bootado, abra um terminal, logue-se como root e consulte os seus dispositivos com echo|format.
Se você esta bem familiarizado com Linux você deve estranhar a nomenclatura dos dispositivos no OpenSolaris, eu recomendo voce dar uma olhada nesse documento.
Parar criar um pool com os dispositivos c4d1 (80G) e o c5d1 (60GB) basta simplesmente um zpool create ourpool mirror c4d1 c5d1.
Agora vamos povoar o pool com dados. Estes dados poderiam ser dados reais importantes como os arquivos de um banco de dados, sua coleção de fotos ou seu arquivo de documentos. Para efeitos ilustrativos eu vou usar aqui um arquivo vazio de 100Mb chamado data. mkfile 100m data.
Durante a criação do arquivo eu dei um zpool iostat -v ourpool para ver o tráfego na entrada/saÃda do pool. Note que há tráfego em ambos os discos já que eles formam um espelho.
Vamos criar e guardar um checksum md5 do arquivo data para podermos checar sua integridade mais tarde, md5sum data > data.md5. Para checarmos se esse checksum bate com o checksum do arquivo fazemos um md5sum –check data.md5.
Agora vem a parte crÃtica dessa simulação. Vamos simular um defeito fÃsico no disco. Dispositivos de armazenamento vão falhar em algum momento, só não sabemos quando, e quando acontecer ele poderá corromper seus dados ou parar aplicações importantes.
Vamos pegar 20 Mb de lixo retirado do /dev/urandom e joga-los no disco c4d1, dd if=/dev/urandom of=/dev/dsk/c4d1 bs=1024 count=20480. Existem formas mais divertidas (e caras) de provocar defeitos fÃsicos, dê uma olhada nesse vÃdeo onde eles usam ZFS e martelos. 🙂
Pronto, o estrago foi feito. Olhamos o status do pool, zpool status ourpool.
Examinar o histórico do pool: você pode examinar todo o histórico do pool para entender o que aconteceu com ele antes de você chegar. Um zpool history ourpool vai mostrar que comandos de pool foram dados desde a criação do pool.
Desligar o disco defeituoso: você pode desliga-lo usando zpool offline ourpool c4d1 sem precisar alterar a estrutura do pool.
Desespelhar o pool: com um zpool detach ourpool c4d1 você retira o dispositivo do pool, mas como o espelho era formado de dois dispositivos, ele passa a não ser mais um espelho.