hddetach

The hddetach script is a Bash script to safely detach (umount+sync+stop) an external hard disk on a GNU/Linux system.

The only argument $1 must be the label of a volume (partition) in the hard disk (e.g. MYDATA) which is mounted on the file system.
The script gets the device path (e.g. /dev/sdb) of the disk which holds the volume labeled $1 and then try to umount all the disk’s volumes, sync the internal cache and stop the disk and finally to removes it from the system (delete volume icon(s), file manager, desktop etc.).
Superuser rights are requested.

The hddetach script is free software, released under the terms of the GNU General Public License version 3 or (at your option) any later version.

Comments, suggestions and bug reports are welcome.

#!/bin/bash
#
# NAME
# 	hddetach
# 
# SYNOPSIS
# 	hddetach 
# 
# DESCRIPTION
# 	This script safely detach an external hard disk.
# 	The only argument $1 must be the label of one volume (partition) of 
# 	the hard disk (e.g. MYDATA) which is mounted on the file system.
# 	The script gets the device path (e.g. /dev/sdb) of the disk which holds 
# 	the volume labeled $1 and then try to umount all the disk's volumes, sync 
# 	the internal cache and stop the disk and finally to removes it from the 
# 	system (delete volume icon(s), file manager, desktop etc.).
# 	Superuser rights are requested.
# 	
# AUTHOR
# 	Alexus
# 	
# COPYRIGHT
# 	Copyright (c) 2014+ Alexus
# 	License: GPLv3+ (GNU GPL version 3 or later)
# 	This program is free software: you can redistribute it and/or modify
# 	it under the terms of the GNU General Public License as published by
# 	the Free Software Foundation, either version 3 of the License, or
# 	(at your option) any later version.
# 	This program is distributed in the hope that it will be useful,
# 	but WITHOUT ANY WARRANTY; without even the implied warranty of
# 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# 	GNU General Public License for more details.
# 	You should have received a copy of the GNU General Public License
# 	along with this program.  If not, see http://www.gnu.org/licenses/.

# Function desc
desc() {
echo ""
echo "${0##*/}: safely detach an external hard disk"
echo "$COPY, version $VER $DATE"
echo ""
}

# Function usage
usage() {
echo "  Usage: ${0##*/} "
echo "  : label of one volume (partition) of the disk to detach"
press_key
exit 1 
}

# Function press_key
press_key() { echo ""; read -rsn 1 -p "Press any key to exit..."; echo ""; echo "";}

# Function umount_all
umount_all() { local dev="$DEVNAME"; mount | cut -d' ' -f1 | while read vol; do if [[ $vol =~ /dev/$dev. ]]; then umount "$vol"; fi; done; } 

# Intro
VER="1.0"
DATE="18/11/2014"
COPY="Copyright (c) 2014+ Alexus, GPLv3+"
desc

# Check argument
if [[ $# -eq 0 ]]; then echo "  *** Fatal error: Missing argument."; usage; fi

# Get disk device path and device name
LABEL=$1
PATTERN="\[$LABEL\]"
DEVPATH=$(mount -l | grep $PATTERN | cut -d' ' -f1)
DEVNAME=$(echo $DEVPATH | cut -d'/' -f3 | grep -Eo "[[:alpha:]]*")

# Check disk presence
if [[ ${#DEVNAME} -eq 0 ]]; then echo "  *** Fatal error: Not found any device with a volume labeled '$LABEL'."; usage; fi

# Ask user confirmation
echo "  Disk /dev/$DEVNAME holding a volume labeled '$LABEL' will be detached."
echo "  Superuser rights might be requested."
read -p "  Continue? (y/N) " -n 1 -r
if [[ ! "$REPLY" =~ ^[Yy]$ ]]; then echo "  Nothing done."; press_key; exit 0; fi
echo ""

# Unmount partitions on disk
echo "  Trying to umount all the volumes on $DEVPATH..."
umount_all

# Detaches (sync, stop, forget) disk and exit
echo "  Trying to sync, stop and forget $DEVNAME disk..."
sudo sdparm --command=sync /dev/$DEVNAME
sudo sdparm --command=stop /dev/$DEVNAME
sudo sh -c "echo 1 >/sys/block/$DEVNAME/device/delete"
echo "  Done."
press_key
exit 0

Back again

Hey!

Still alive and back again.
Next days I will try to publish some useful (?) Bash scripts.

GNU IceCat 14.0.1 prebuild binaries tarball

Image: GNU IceCat logo.

A tarball containing the prebuild binaries of GNU IceCat 14.0.1, compiled by me for a GNU/Linux i386 system based on Debian stable, is available at the GNU IceCat downloads page of this site.

Language files should be available at the Gnuzilla FTP site: ftp://ftp.gnu.org/gnu/gnuzilla/lang/.

Also see how to install GNU IceCat tarballs.

Enjoy!

GNU IceCat 13.0.1 prebuild binaries tarball

Image: GNU IceCat logo.

A tarball containing the prebuild binaries of GNU IceCat 13.0.1, compiled by me for a GNU/Linux i386 system based on Debian Squeeze, is available at the GNU IceCat downloads page of this site.

Language files should be available at the Gnuzilla FTP site: ftp://ftp.gnu.org/gnu/gnuzilla/lang/.

Also see how to install GNU IceCat tarballs.

Enjoy!

GNU IceCat 10.0 prebuild binaries tarball

Image: GNU IceCat logo.

A tarball containing the prebuild binaries of GNU IceCat 10.0, compiled by me for a GNU/Linux i386 system based on Debian Squeeze, is available at the GNU IceCat downloads page of this site.

Also see how to install GNU IceCat tarballs.

Enjoy!

How to install GNU IceCat tarballs

To install a generic prebuild binaries tarball package just unpack it in a folder (which is usually already defined decompressing the file itself) and copy or move it (also renaming it if necessary) in a suitable position, usually into your /home directory or in the /opt system directory. Might also be necessary to change the permissions of the directory and/or the contained files (see the instructions which usually come with the package).

I suggest this way to install the GNU IceCat prebuild binaries tarball packages provided by this website:

prepare the system

  • update your system (this is not strictly necessary, but it is better before removing or installing software):

    $ sudo apt-get update
    $ sudo apt-get upgrade
    
  • if you are updating a previous version already installed in /opt/icecat, then it is better to rename this folder before to install the new package:

    $ sudo mv /opt/icecat /opt/icecat-old
    

    so that you might eventually delete it later (be very careful using the rm command!):

    $ sudo rm -R /opt/icecat-old
    

download and install

(notice: below you should substitute x.y.z with the actual version number of the tarball package to install)

  • download the wanted GNU IceCat x.y.z tarball package from the GNU IceCat downloads page of this site
  • rename the downloaded package to fix the file extension (this is need as, due to bugs in WP, the file extensions of the tarballs have been changed from ‘.tar.gz’ to ‘tar_.gz’):

    $ mv icecat-x.y.z.tar_.gz icecat-x.y.z.tar.gz
    
  • unpack it (you will have a icecat-x.y.z folder):

    $ tar -jxvf icecat-x.y.z.tar.gz
    
  • move the icecat-x.y.z folder to the /opt system directory, renaming it at the same time to icecat:

    $ sudo mv icecat-x.y.z /opt/icecat
    
  • now you can finally run IceCat:

    $ /opt/icecat/icecat
    

Enjoy!

GNU IceCat 9.0.1 prebuild binaries tarball

Image: GNU IceCat logo.

A tarball containing the prebuild binaries of GNU IceCat 9.0.1, compiled by me for a GNU/Linux i386 system based on Debian Squeeze, is available at the GNU IceCat downloads page of this site.

Enjoy!

Update: Also see how to install GNU IceCat tarballs.

Back

Hey!
After a long time… still alive and back here!

fSimpleX 3.0

fSimpleX version 3.0!

Until August 2011, NoBlogs.org was using the LifeType blogging platform. So this blog was using fSimpleX, a free (GNU GPLv3) template for the LifeType blogging platform by al3xu5/dotcommon (based on the fSimple theme by Fredrik Fahlstad).

The fSimpleX 3.0 template I was using is available at the fSimpleX downloads page of this site.

Release notes (fSimpleX 3.0, 17/06/2010):

  • Layout fully revisited and code optimized! Now pages have a liquid 2 columns right-menu layout which comes with a lot of improvements:
    • percentage widths
    • no CSS hacks
    • SEO (Search Engine Optimisation) friendly (the the left-hand main page comes first, then the right column)
    • full length column background colours
    • no images
    • no JavaScript
    • resizable text compatible
    • no quirks mode (XML declaration to display correctly in older versions of IE is not required)
    • no IE conditional comments
    • high browser compatibility
    • valid XHTML 1.0 strict
    • valid CSS 2.1
  • Better graphics (css)
  • Better images (from the gnome theme image set)
  • Fixed a lot of minor code bugs

Enjoy!

References for SlimGnewsense

The SlimGnewsense theme is now also available at the official theme’s page of the SLiM (Simple Login Manager) project website.

More, the artwork section of the gNewSense website has now a page about SlimGnewsense.