Friday, January 16, 2009

Mounting an External Hard Drive in SuSE (Linux)

I have setup my environment to have a Samba server running with shares on a large external hard drive. However, the external hard drive is not accessable unless someone is logged into the machine. In order to fix this, I will need to configure the system to automatically mount the external hard drive on startup of the machine. The process I took to do this is as follows:

First, you need to determine the drive name for the external disk. You can do this by examining your dmesg. In a terminal run:

dmesg | less

My drive name is sdc.

You may also find the drive location easier by opening the partition manager in YaST after logging in (if you have it available).

Open /etc/fstab in a text editor. I use terminal based vi. My file, before editing, contained:

/dev/disk/by-id/scsi-SATA_WDC_WD400BB-75FWD-WCAJA2880525-part2 swap swap defaults 0 0
/dev/disk/by-id/scsi-SATA_WDC_WD400BB-75FWD-WCAJA2880525-part1 / ext3 acl,user_xattr 1 1
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0

I needed to add the line:

/dev/sdc /media/disk auto auto 0 0

This line means to mount the drive found at /dev/sdc to /media/disk; to automatically detect the file system time and automatically mount the drive, the last two 0s have to do with how the drive is backed up, by putting 0 0, I told the system to ignore the drive. The resulting file looked like:

/dev/disk/by-id/scsi-SATA_WDC_WD400BB-75FWD-WCAJA2880525-part2 swap swap defaults 0 0
/dev/disk/by-id/scsi-SATA_WDC_WD400BB-75FWD-WCAJA2880525-part1 / ext3 acl,user_xattr 1 1
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
usbfs /proc/bus/usb usbfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0

/dev/sdc /media/disk auto auto 0 0

From here all we need to do is restart the machine and the drive should automatically mount without needing to login as a user!

No comments:

Post a Comment