Automatically mounting a hard disk partition at boot

Get the Blockid of the hard disks

[email protected]:~$ sudo blkid
[sudo] password for droidzone:
/dev/sda1: LABEL="Windows7" UUID="10909D8B909D77C4" TYPE="ntfs"
/dev/sda2: UUID="f3606d11-5fbc-4d31-846a-cc812e4cd53f" TYPE="ext4"
/dev/sda5: UUID="4cc50c11-af2a-4352-8dfa-c967deed997a" TYPE="swap"
/dev/sr1: LABEL="UDF Volume" TYPE="udf"
/dev/sdb1: LABEL="WindowsXP" UUID="E6BCC858BCC82541" TYPE="ntfs"
/dev/sdb2: LABEL="Windows8" UUID="94C0680DC067F440" TYPE="ntfs"
/dev/sdb5: LABEL="STORAGE" UUID="642C-370E" TYPE="vfat"
/dev/sdb6: LABEL="userdata" UUID="3ad6396d-9ab2-4435-a850-e03501810734" TYPE="ext4"
/dev/sdb7: LABEL="gentoo" UUID="f8960404-f785-464e-9c43-06777c679153" TYPE="ext4"
/dev/sdb8: UUID="ca39c78d-85ee-4db1-8589-45beb6cc62e8" TYPE="swap" [/code]

Create the mount point for the disk

sudo mkdir -p /hdd/windows7[/code]

Edit /etc/fstab as root

kdesudo kate /etc/fstab[/code]

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda2 during installation
UUID=f3606d11-5fbc-4d31-846a-cc812e4cd53f / ext4 errors=remount-ro 0 1
# swap was on /dev/sda5 during installation
UUID=4cc50c11-af2a-4352-8dfa-c967deed997a none swap sw 0 0
# swap was on /dev/sdb8 during installation
UUID=ca39c78d-85ee-4db1-8589-45beb6cc62e8 none swap sw 0 0
UUID=10909D8B909D77C4 /hdd/windows7 auto user,rw,auto,exec,nobootwait 0 0[/code]

The line added is:

UUID=10909D8B909D77C4 /hdd/windows7 auto user,rw,auto,exec,nobootwait 0 0[/code]


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.

Force unmount of a removable drive

Recently I was running Unetbootin to install a live dvd image on a pen drive. It got stuck in the middle of the job, and even after closing it, I couldnt umount it with umount or gparted. It was suggested that I use fuser or lsob to identify and terminate the running process.

Gparted showed me that the drive was the device /dev/sdc1

So I tried to identify the process using the device

$ ps ax | grep '/media/D514-D264'
20291 ? D 0:09 /usr/lib/p7zip/7z -bd -aos -o/media/D514-D264 e /userhome/CD Images/livedvd-x86-amd64-32ul-2012.1.iso image.squashfs
21055 ? D 0:05 /usr/lib/p7zip/7z -bd -aos -o/media/D514-D264 e /userhome/CD Images/livedvd-x86-amd64-32ul-2012.1.iso image.squashfs
22896 pts/4 S+ 0:00 grep --color=auto /media/D514-D264[/code]

The integer displayed on lefthand coloumn is the PID (processid)

The command kill can be used to stop the process, by specifying the kill signal and process id.

Table 12-2. Common kill signals

Signal name Signal value Effect
SIGHUP 1 Hangup
SIGINT 2 Interrupt from keyboard
SIGKILL 9 Kill signal
SIGTERM 15 Termination signal
SIGSTOP 17,19,23 Stop the process

So to kill (signal 9) processes 20291,21055,22896 I would issue the command:

[[email protected] c]$ sudo kill -9 21055
[[email protected] c]$ sudo kill -9 22896
kill: No such process
[[email protected] c]$ ps ax | grep '/media/D514-D264'
[/code]

There, no more running processes using the device. Voila, now gparted has no problem unmounting the device!


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.