$ du -shdanbookpro:~ daniel$ du -sh
53G .Very good then. Carry on.
Update
If you’re looking for a real good time, give this a try (thanks Nick):du -chs ~/*This will give you a list of each file/directory and the amount of disk space used by each. In my case something like this:
danbookpro:~ daniel$ du -chs ~/*
58M /Users/daniel/Bin
853M /Users/daniel/Desktop
1.3G /Users/daniel/Documents
1.1M /Users/daniel/Droplets
10G /Users/daniel/Library
25M /Users/daniel/Movies
7.2G /Users/daniel/Music
26G /Users/daniel/Pictures
1.5G /Users/daniel/Public
112K /Users/daniel/Sites
6.2G /Users/daniel/Work
53G total
danbookpro:~ daniel$
It’s been a long time since the last time I installed and used Ubuntu, but with another shiny newish version out, 6.10 or whatever it is, I wanted to give it another go. Of course, I’m afraid of hard disk crashes (as should you be), so the first thing I do is set up a software RAID. I’ll go with a RAID-1 (Mirror) so we’re protected in the event that one of the disks decides to up and die.
The last time I did this was for Ubuntu 5.10 (don’t ask me what nifty nickname that version had) – but it looks like a few things (not many) have changed. In 6.10 (AKA Edgy Eft) the Disks Manager is gone, but you can still use the Device Manager to figure out what disks you want to use to create your RAID. I still have two of these 160GB SATA Seagate drives that I’ll use for the sake of this example. Here’s a screen shot of the Device Manager, I’ve browsed to the first of the disks I’m planning on using, and you can see that it’s /dev/sda (screenshot, top right).
This screenshot also shows that my drives contain the Backup volume – I’m nuking this volume to create this RAID.
Now we open up the terminal, and get going. My drives are /dev/sda and /dev/sdb, so the first step is to use cfdisk to partition them:
daniel@ubuntu:~$ sudo cfdisk /dev/sda
daniel@ubuntu:~$ sudo cfdisk /dev/sdb
Running cfdisk opens a cursor based application that you need to use to create the partitions. I deleted all existing partitions, and then created a Primary partition that took up the entire disk. Then I set the Type to FD which is Linux Raid Autodetect.
Next we load the RAID module for RAID-1 (Mirror):
daniel@ubuntu:~$ sudo modprobe raid1After this, I opened up Device Manager again to see what the partitions had been called that we created on our disks. One of my partitions is /dev/sda1 and the other is /dev/sdb2. You can check out the screen shot below to see what I was looking at:
You can also notice from this screen that the Backup volume has indeed been nuked, and now we simply have Volume (linux_raid_member).
The next thing I want to do is run mdadm, but in my install of Ubuntu 6.10 it doesn’t exist, so we’ll install it:
daniel@ubuntu:~$ sudo apt-get install mdadmThat will spit out a bunch of stuff and eventually you should get the message:
* Starting RAID monitoring service mdadm —monitor [ ok ]Alright, now let’s run mdadm to create the RAID:
daniel@ubuntu:~$ sudo mdadm —create
/dev/md0 —level=1 —raid-devices=2 /dev/sda1 /dev/sdb1For me, I was prompted to confirm that I wanted to continue to create the array, because it looked like my disks were already a part of an array. I just pressed ‘y’ and carried on.
At this point, the RAID is being constructed, it’s not yet completed, even though you’ve been dumped back to the terminal. We can view the progress of the resyncing like so:
daniel@ubuntu:~$ sudo cat /proc/mdstat
Personalities : [raid1]md0 : active raid1 sdb1[1] sda1[0]
156288256 blocks [2/2] [UU]
[>....................] resync = 2.4%
(3886336/156288256) finish=52.6min speed=48201K/secunused devices: <none>
daniel@ubuntu:~$
So in 52.6 minutes we should be good to go. Now is your queue to grab me a Caramel Macchiato from Starbucks…Triple Grande, please.
Once the RAID is finished doing the resync, we need to create a file system on that bad boy. I’m going to use ext3, but you can go ahead and use whatever strikes your fancy.
daniel@ubuntu:~$ sudo mkfs.ext3 /dev/md0And voila! Once that’s finished, we should have a nice shiny file system that’s all RAIDified. Before we can actually do anything with it, we first need to mount it. I’m going to mount mine at /backup, but again, you can mount it however or wherever you see fit.
daniel@ubuntu:~$ sudo mkdir /backup
daniel@ubuntu:~$ sudo mount /dev/md0 /backup
Now with any luck, we should have 160GB of RAID goodness mounted at /backup, let’s check to see what we’ve got:
daniel@ubuntu:~$ df -k /dev/md0I would love to paste the result of the above command here, but the stupid terminal is not copying my selected text to the clipboard, but trust me when I say it tells us we have a nice ~160GB file system mounted at /backup.
Since we don’t want to have to remount the file system every time we reboot, we can add an entry to /etc/fstab to get it to mount at boot. As I’ve mentioned before, I’m not a Linux ninja by any stretch of the imagination, but if you read the man page for fstab and take a look at what’s in your current file, I’m confident you’ll easily be able to get it to mount the way you’d like. For me, I basically copied the line from my boot disk and changed /dev/hdc to /dev/md0 and also changed the last column (pass) from 1 to 2.
/dev/md0 /backup ext3 defaults,errors=remount-ro 0 2There you are, a newly updated entry on how to set up a nice software RAID in Edgy Eft (Ubuntu 6.10). Enjoy.
The nice thing about writing a little ‘signup’ application for a class that your wife teaches is that you have full control over the hijacking of that application any time you feel like it. See figure one:

Fortunately for me I didn’t get shot down, and we got some Gold Class seats at VivoCity.
Today, unfortunately, is not turning out nearly as good as yesterday. My mac is seriously on the fritz exhibiting the following completely random and seemingly unrelated ‘features’.
As I’m typing this, SuperDuper! has just finished backing up all my user files, and Mr. Laptop is now going to receive a full enema. I sure hope that this isn’t a hardware problem, or I’ll be severely unimpressed. At least the thing is under warranty. But if Apple is going to take my laptop for a week while they try to figure out what’s going wrong – I might have switched to Ubuntu by the time they give it back to me.
Note: There is an updated version of this article for Ubuntu 6.10 here
Wanting to finally put these stupid SATA disks to good use, I managed to get them thrown into a RAID-1 configuration on my happy Ubuntu install.
Just thought I’d share how I did it, and the resources I used. Standard disclaimer applies: If you follow these instructions, and you lose all your data, or the world explodes, or the sky starts falling, or you die, I’m not liable.
Here are the resources I used.
Go to Disks Manager to figure out the Devices that you want to actually make into a RAID, for me that was /dev/sda and /dev/sdb. These are 2×160GB Seagate SATA disks attached to a Promise FastTrak 378 controller on an Asus A8V Deluxe motherboard.
So now you need to create the partitions that you want to use as a RAID.
daniel@ubuntu:~$ sudo cfdisk /dev/sda
daniel@ubuntu:~$ sudo cfdisk /dev/sdb
I made mine Primary Partitions (not sure if this is good, bad, or if it matters at all), and you NEED to make the filesystems of type Linux Raid Autodetect (FD).
After that, i loaded the RAID module for RAID-1 (Mirror) because that’s the type of RAID I wanted to build:
daniel@ubuntu:~$ sudo modprobe raid1
After this, I restarted the Disks Manager to see what the partitions had been called on my disks. I selected the disk on the left, and took a look at the partition tab on the right, noticing that one of my disk partitions was /dev/sda1 and the other was /dev/sdb1.
Now we can run mdadm:
daniel@ubuntu:~$ sudo mdadm —create /dev/md0 —level=1 —raid-devices=2 /dev/sda1 /dev/sdb1
Now let’s take a look at the status of the disks as they are rebuilding the RAID:
daniel@ubuntu:~$ sudo cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1] sda1[0]
156288256 blocks [2/2] [UU]
[>....................] resync = 0.9% (1459904/156288256) finish=54.7min speed=47093K/sec
unused devices:
daniel@ubuntu:~$
So, 54.7 minutes left for the disks to finish the sync [start twiddling thumbs].
You can get some information about the partition by going like so:
daniel@ubuntu:~$ sudo mdadm —misc —detail /dev/md0
So, once it finished, let’s make a file system. I’m going to use ext3, but you go ahead and use whatever you like, so we go:
daniel@ubuntu:~$ sudo mkfs.ext3 /dev/md0
And once it finished, we should (technically) have a nice pretty file system. But now we have to mount it. I want to mount mine in a /backup directory, because I’m going to be using this RAID for backups.
So here we go:
daniel@ubuntu:~$ sudo mkdir /backup
daniel@ubuntu:~$ sudo mount /dev/md0 /backup
Now, technically, we should have nearly 160GB of yummy RAID1 love available to us in the /backup directory. Let’s run df and see what it tells us:
daniel@ubuntu:/backup$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda2 35064712 5173932 28109576 16% /
tmpfs 1026508 0 1026508 0% /dev/shm
tmpfs 1026508 13536 1012972 2% /lib/modules/2.6.12-10-amd64-generic/volatile
/dev/sdc1 199093056 136388704 62704352 69% /media/EXTERNAL
/dev/md0 153834788 131228 145889148 1% /backup
Excellent, /dev/md0 is mounted at /backup, and we’ve got lots of backup space.
In order to get this thing to mount each time we boot, we’ll want to put it into our /etc/fstab file. Let’s do that now.
I added a line like this to my /etc/fstab:
/dev/md0 /backup ext3 defaults,errors=remount-ro 0 2
I’m not a super-linux-ninja, but I was able to figure out what I wanted to do here by reading the man page for fstab, and by looking at the other entries in the file. So run “man fstab” and then you can edit the fstab file (by using something like “sudo vi /etc/fstab” once you’re feeling like you’re comfortable with what to add there).
Ok, that’s going to be the last entry for a while, I’m heading to New Zealand tomorrow, and won’t be back for three weeks. I also haven’t rebooted my machine yet to see if that /etc/fstab change worked, so lets hope I didn’t mess something up.
This will let you know how to determine free disk space on a *nix box (Linux, FreeBSD, Mac OS X, Solaris, etc.) The man page for df says this:
df - report filesystem disk space usage
When I type df -k on one of my Linux machines, it tells me how much free space (in Kilobytes) I have on each of my mounted filesystems. Here is the output:
[daniel@localhost daniel]$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda2 76541056 31788324 40864604 44% /
/dev/hda1 101089 9272 86598 10% /boot
none 188248 0 188248 0% /dev/shm
This tells me that I have about 56% free space on my main /dev/hda2 partition, which is mounted at /. This translates into roughly 40864604 Kilobytes, or 40GB.
Your output will vary depending on the number of filesystems you have, and where they are.
This page will describe a couple of ways in which you can get Linux (specifically RedHat) to start certain applications (any application really) at boot time. Some of the common apps that people may want to configure to start automatically are Apache, MySQL, Tomcat, JBoss, Zope, xinetd, etc. Most versions of RedHat should come with this handy tool called chkconfig
You may find that it is not in your path by default (eg: on my linux box, chkconfig is in /sbin, but I did not have /sbin in my path by default. So I added /sbin to my path first, in order to gain access to chkconfig easily on the commandline, without having to type /sbin/chkconfig. The first thing you might want to try is something like the following:
netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
xinetd based services:
chargen-udp: off
rsync: off
chargen: off
daytime-udp: off
daytime: off
echo-udp: off
echo: off
services: off
servers: off
time-udp: off
time: off
cups-lpd: off
sgi_fam: on
ktalk: off
cvspserver: on
The output above is a partial output of the command
chkconfig —listWhat the output is basically telling you is which apps that have startup scripts in /etc/init.d are configured to be in an on/off state at which run level. In my example, I want to configure my linux machine to have httpd (which is Apache) start on boot, so the command I want to type to get this to happen is:
chkconfig httpd onThis will ensure that my service httpd from /etc/init.d is in a started state at (by default) run levels 2, 3, 4, and 5 (for all intents and purposes, these run levels indicate a “normal” machine state, describing what all of the run levels mean is much beyond the scope of this document). Now if I reboot my machine, I will notice that httpd was started automatically at boot.
This page describes how to create a symbolic link in linux
For example, I want to create a symbolic link in my /usr/local directory called mysql that symbolically links to /usr/local/mysql-standard-4.0.18-pc-linux-i686
Here is what I do:
shell> cd /usr/local
shell> ln -s /usr/local/mysql-standard-4.0.18-pc-linux-i686 mysql
shell> ls -l mysql
shell> lrwxrwxrwx 1 mysql mysql 46 May 30 13:59 mysql -> /usr/local/mysql-standard-4.0.18-pc-linux-i686
The last two commands are just to demonstrate that the link was created. Do a directory listing with ls -l mysql and then you can see that now there is a link mysql that points to the directory /usr/local/mysql-standard-4.0.18-pc-linux-i686.
On most (any?) Linux or Unix system, you should be able to check which operating system it is running by using:
[root@humandoing root]# uname
Linux
This of course can be great when used in a shell script and you need to perform different actions depending on the operating system that the script is being executed on.
Or if you want the kernel version
[root@humandoing root]# uname -r
2.4.27rimu1-3um
If you want to get really crazy:
[root@humandoing root]# uname -a
Linux humandoing.net 2.4.27rimu1-3um #1 Thu Sep 9 02:48:08 UTC 2004 i686 i686 i386 GNU/Linux