This blog has moved! Redirecting...
You should be automatically redirected. If not, visit http://scrolls.mafgani.net/ and update your bookmarks.

Saturday, March 25, 2006

Mounting fat32 partition/hard disk

I found this easy method somewhere online:

First find out what the partition is labelled as by performing fdisk -l


[root@localhost /]# fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2611 20972826 7 HPFS/NTFS
/dev/sda2 2612 3886 10241437+ 83 Linux
/dev/sda3 3887 5161 10241437+ 83 Linux
/dev/sda4 5162 14593 75762540 5 Extended
/dev/sda5 5162 8221 24579418+ b W95 FAT32
/dev/sda6 8222 11281 24579418+ b W95 FAT32
/dev/sda7 11282 14593 26603608+ b W95 FAT32


So sda5, 6 and 7 are my fat32 partitions. I need to mount those so that I can make use of them. The following method also mounts them at reboot so you only need to do this once.

Open /etc/fstab in any convenient editor.

In my case, I had to append the following at the end of the file:

/dev/sda5 /mnt/academics vfat users,owner,rw,umask=000 0 0
/dev/sda6 /mnt/media vfat users,owner,rw,umask=000 0 0
/dev/sda7 /mnt/storage vfat users,owner,rw,umask=000 0 0


This gives all users read/write access to the three paritions. I decided to name them academics, media and storage. If you want only read access and no write access, change the "rw" to "ro".

Save the fstab file.

Next, you would like to create mount points for these partitions. I decided to have them under "/mnt". So:


[root@localhost /]# mkdir /mnt/academics
[root@localhost /]# mkdir /mnt/media
[root@localhost /]# mkdir /mnt/storage


And finally, automount:

[root@localhost /]# mount -a


The drives should be accessible now. Furthermore, they stay accessible after reboot. Enjoy.

Wednesday, March 15, 2006

SSH automatic reconnect on timeout

There may already be some builtin option that allows a client to reconnect when a timeout occurs but I was too lazy to look through the man pages. So I came up with line of bash commands that will do just that:

$ while [ 1 ]; do ssh user@host.domain; sleep 120; done

This will keep reconnecting to the host 120 seconds after a connection drops out for whatever reason. This is specially handy to make sure that a remote tunnel stays open. Right now I use it to reach a single host (A,http) on a remote private network from home (B) via another machine in the private network (C) and an intermediate SSH server (D):

  1. [user@C ~]$ while [ 1 ]; do ssh -R someport:A:80 user@D; sleep 120; done

  2. [user@B ~]$ ssh -L 80:localhost:someport user@D

  3. [root@B ~]# echo "127.0.0.1    A" >> /etc/hosts


Now it is possible to type "http://A" and visit the site from B as easily as from within the remote private network.