EXT3 File System On A USB Stick
This how-to will create USB memory stick with ext3 file system. First of all, use sudo fdisk -l to get the device handle of USB stick. It might look something like this:
Disk /dev/sdd: 4041 MB, 4041211392 bytes
125 heads, 62 sectors/track, 1018 cylinders
Units = cylinders of 7750 * 512 = 3968000 bytes
Disk identifier: 0xddeb26e6
Device Boot Start End Blocks Id System
/dev/sdd1 1 61664 3944719 b W95 FAT32
Now unmount it by typing:
sudo umount /dev/sdd1
Afterwards, format the USB stick using the following code. Remember to spell the USB device properly. This command is quite dangerous, it will erase everything on the drive specified.
sudo mkfs.ext3 /dev/sdd
Now that the USB stick is formatted, a new partition has to be create on it. Type:
sudo fdisk /dev/sdd
to create a partition on the USB stick. This will be the new sdd1 partition. After this is done it has to be formatted again using:
sudo mkfs.ext3 /dev/sdd1
to get the ext3 file system on it.
Now then, label the new ext3 USB stick using the command:
sudo e2label /dev/sdd1 usb_backup
Automatically mounting the USB stick when the server reboots
After the usual backup of the /etc/fstab, edit it to include a new line at end:
/dev/sdd1 /media/usb-backup ext3 user,rw 0 0
Create a new directory ‘usb-backup’ and make it readable and writable by the user:
sudo mkdir /media/usb-backup
sudo chmod 755 /media/usb-backup
Use sudo mount -a to mount the drive.
This USB stick can now act as a backup disk.
Inspecting Network Cards In Ubuntu
I was planning to upgrade my home network into Gigabit. Before I start to spend money on it, I wanted to check the capabilities of the network cards on my laptop. Here is how I did it.
Install ‘hwinfo’. Its quite an useful tool as it can check the configuration of any hardware. Refer the manpage of more information.
sudo apt-get install hwinfo
To display details of the network cards on the system, type:
sudo hwinfo --netcard
Alternatively one can use
lshw -C network
to display details of the network card. Read manpage for more on lshw.
Monitoring Real-time User Logins In Ubuntu 8.04 Server
‘whowatch’ is a console, interactive users and process monitoring tool. It displays information about the users currently logged on to the machine, in real-time. Besides the standard informations such as login name, tty, host and the user’s processes, the type of the connection (ie. telnet or ssh) is also shown. A particular user can be selected and his processes tree may be viewed. Trees are displayed with an additional column that shows the owner of each process. In the process tree mode SIGINT and SIGKILL signals can be sent to the selected process. Killing processes is just as simple and fun as deleting lines on the screen [information from somewhere on the www]. To install ‘whowatch’:
sudo apt-get install whowatch
How To Check The Memory Usage Stats On Ubuntu Server Via Command Line
Following are some methods to check the memory usage in Ubuntu. More details about these tools can be found from the man pages.
free
free command displays amount of total, free and used RAM in the system, as well as shoing information on shared memory, buffers, cached memory and swap space used by the Linux kernel.
vmstat
vmstat reports report virtual memory statistics, which has information about processes, swap, free, buffer and cache memory, paging space, disk IO activity, traps, interrupts, context switches and CPU activity. With vmstat command, administrators can has instantaneous reports on memory usage.
top
top command displays dynamic real-time view of the running tasks managed by kernel and system information in Linux system. The memory usage stats by top command include real-time live total, used and free physical memory and swap memory with their buffers and cached memory size respectively.
ps
ps command reports a snapshot on information of the current active processes. Advantage of ps command is that system admins will be able to see where the memory is used. ps will show the percentage of memory resource that is used by each process or task running in the system. With this command, top memory hogging processes can be identified.
Migrating MediaWiki To A New Server
Today I decided to move my MediaWiki (MW) from the ailing old server to the new one. Overall it was a fairly simple process but I wanted to share a few things that I learned from the experience.
1. The database
a. Creating the backup
The very first thing that I had to do was to create a safe backup of my MW database. This database now contains all the data in my MW including images, user settings, comments and chats. To do this in MySQL I used the following syntax:
mysqldump -u username -p databasename > database.sql
b. Creating a new database
This created a file containing all the data from the old database. I used a copy of this file to create a new database in my new server. To do this I had to first create the database and then import the data using the following syntax:
mysql -u root -p new_database_name < database.sql
c. Creating a database user
Then I created an account that has access to this database and gave it permissions. Details about this new user can be found in the LocalSettings.php file of the MW. Details about the database connection can also be found in this file. For example:
$wgDBserver = “localhost”; $wgDBname = “database_name”; $wgDBuser = “username”; $wgDBpassword = “password”; $wgDBtype = “mysql”;
I used the following commands to give proper permission to the new MySQL user account.
GRANT DELETE,INSERT,SELECT,UPDATE ON new_database_name.* TO ‘username’@localhost IDENTIFIED BY ‘password’;
GRANT DELETE,INSERT,SELECT,UPDATE ON new_database_name.* TO ‘username’@unnionline.com IDENTIFIED BY ‘password’;
2. Moving MW files
Now that the database is properly setup, the next step was to move the MW from the old server to the new one. I recommend anybody using this technique to stick with the original directory structure. I used ssh to do the transferring.
3. Configuring apache
Now that my MW is ready to go online, I had edit my apache configuration file to recognize and host the wiki. Details about configuring apache can be found at http://www.apache.org/









