Published on
12. August 2011 in
Linux.
Hi out there!
Because modifying an initial ramdisk is something I had to do every once a while and I am pretty oblivious when it comes to “exotic” commands, I will persist the knowledge at this point.
First of all, modern linux kernels (like everything above 2.6 or so) use an initrd that is a gzipped cpio-image (use file to be sure).
Extract an initial ramdisk
- Extract (i.e. gunzip) the gzipped image
1
2
| ~ $ mv initrd initrd.gz
~ $ gunzip initrd.gz |
- Extract the contents of the cpio image
1
2
| ~ $ mkdir extracted && cd extracted
~/extracted $ cpio -id < ../initrd |
(Re-)build an initial ramdisk
- Create the cpio image
1
| ~/extracted $ find . | cpio -H newc -o > ../initrd.new.cpio |
- Compress (i.e. gzip) the image
1
2
3
| ~/extracted $ cd ..
~ $ gzip initrd.new.cpio
~ $ mv initrd.new.cpio.gz /boot/initrd-2.6.22-some-kernel |
It might be possible to simplify some steps of this howto, but I tend to clarify things to avoid confusion.
Note:
I stumbled over the newc format of cpio. Actually, I think that there’s not pretty much of a choice here.
The documentation doesn’t say much about that, just use it.
Have fun, take care!
Published on
31. March 2011 in
Linux.
Hi peeps,
I’ve been stumbling on this so many times, so I decided to dedicate this post to the following issue:
If you connect an USB device to your computer, trying to access it under Linux, you might run into permission issues caused by the UDEV daemon.
In my case, I was trying to connect an Android smartphone in order to work with it.
However, somehow, I had no permissions to access it, due to UDEV.
Here’s how to fix such a problem:
-
Determine the vendor-id and the product-id of your device using lsusb:
1
2
3
4
5
6
7
| Bus 002 Device 009: ID 0bb4:0c97 High Tech Computer Corp.
Bus 002 Device 004: ID 04b3:310c IBM Corp. Wheel Mouse
Bus 002 Device 003: ID 046d:c318 Logitech, Inc. Illuminated Keyboard
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub |
-
Create a new udev rule for this device, i.e., create a file /etc/udev/rules.d/51-mydevice (for instance), with the following contents:
1
| SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct} =="41db", 2 MODE="0666", OWNER="%username%" |
Published on
3. December 2010 in
Linux.
I was looking for a tool to set the itunescompilation (see here) ID3-field of certain mp3-files. This is necessary for iTunes to recognize that imported files belong to a compilation (or not). Most of the (decent) Linux tools for id3 tagging are not able to perform that task (including EasyTag). Fortunately, I found eyeD3 (see here), which can be used as follows:
$ eyeD3 --set-text-frame=TCMP:1 <file.mp3>
Published on
14. November 2010 in
Linux.
These days I needed to convert some FLAC (Free Lossless Audio Codec) audio files to mp3. As usual when dealing with audio/video formats, there are lots of (useless) tools available on the internet, most of them being shareware or even voruses (windows). Fortunately, this is a strength of Linux … at least if you are used to the console. All you need is lame and the necessary codecs (use apt-cache search to find what you need).
for file in *flac ; do flac -dc "$file" | lame -h - "${file%flac}mp3" ; done
Published on
1. September 2010 in
Linux.
With Ubuntu 10.04 alias “Lucid Lynx” the new “Ambiance”-theme was introduced.
Furthermore, the designers of Ubuntu decided to change the location of the window buttons from the right to the left, which in my opinion is really unusual.
Fortunately, Linux is very customizable and this behavior can be changed in order to move the buttons back to their previous location on the right.
Therefore, you’d have to change the attribute
/apps/metacity/general/button_layout
to the value “menu:minimize,maximize,close”, which can be done with Ubuntu’s configuration editor (GConf). This editor can be started by invoking the gconf-editor command on the console.
Alternatively, you could use the gconftool-2 utility to change the setting directly on the command line:
$ gconftool -s /apps/metacity/general/button_layout -t string menu:minimize,maximize,close
Published on
23. June 2010 in
Linux.
This Script was designed to backup a database onto a backup-server that (only) provides SMB-Shares.
If there are already more than $CYCLE files present within the destination directory, the oldest file will be overwritten.
You might get the impression that I am abusing my blog to host scripts.
Well, you’re right
There you go:
#!/bin/sh
# This script backs up a db with adjustable cycles
BAKPATH='/mnt/backup' ## The Path to store the backups in
SMBPATH='//10.10.10.10/backup' ## Path to the smb-share to store the backup in
SMBUSER='user' ## User to login with
SMBPASSWD='' ## Password to use for smb-auth. in base64 encoding
CYCLE=7 ## Number of backup-files in one cycle, the oldest backup will be overwritten
SUFFIX='_backup.sql' ## The suffix of the filename
MYSQL_ROOTPW='' ## MySQL-Password for root in base64 encoding
MYSQL_DB='somedb' ## The database to be backed up ;)
LOGFILE='/var/log/backups' ## Where shall i write logs to?
### Mount the SMB-share to BAKPATH
mount -t smbfs $SMBPATH $BAKPATH -o username=$SMBUSER,password=$( echo $SMBPASSWD | openssl enc -base64 -d )
### Is it mounted correctly?
MOUNTS=$( mount | grep $BAKPATH | wc -l )
if [ $MOUNTS -eq 0 ] ; then
echo $(date)" Couldn't map SMB-share to my local FS! Exiting, no Backup created" >> $LOGFILE;
if [ ! -d $BAKPATH ]; then
echo $(date)" The specified BAKPATH doesn't exist!" >> $LOGFILE;
fi
else
echo $(date)" SMB-share $SMBPATH mapped successfully to $BAKPATH!" >> $LOGFILE;
### Get the number of files in our BAKPATH
NUMFILES=$(ls -1 $BAKPATH | wc -l)
### While the number of backups is >= $CYCLE
while [ $NUMFILES -ge $CYCLE ]; do
### Get the oldest backup; delete it and do some output/logging
OLDESTFILE=$( ls -t1 $BAKPATH | tail -n 1 )
OLDESTABSFILE=$BAKPATH"/"$OLDESTFILE
rm $OLDESTABSFILE
if [ ! -f $OLDESTABSFILE ]; then
NUMFILES=`expr $NUMFILES - 1`
echo $(date)" Deleted Backup $OLDESTABSFILE to make space ;)" >> $LOGFILE
fi
done
### Now create the backup
FILE=$(date +%Y%m%d)"_"$(date +%H%M%S)$SUFFIX
ABSFILE=$BAKPATH"/"$FILE
mysqldump --user=root --password=$( echo $MYSQL_ROOTPW | openssl enc -base64 -d ) $MYSQL_DB > $ABSFILE
tar -czf $ABSFILE.tar.gz $ABSFILE
rm $ABSFILE
### Do some logging
if [ -f $ABSFILE.tar.gz ]; then
echo $(date)" Backup '$ABSFILE' successfully created" >> $LOGFILE;
else
echo $(date)" Couldn't create the backup!" >> $LOGFILE;
fi
umount $BAKPATH
fi
Published on
23. June 2010 in
Linux.
Hey,
I figured out that nautilus, the file browser of GNOME, has a nice feature of adding scripts to the context menu (right click).
For instance, you can place the following two scripts in ~/.gnome2/nautilus-scripts/ and make them executable (chmod +x).
Then you will be able to do a right-click on iso-images for (un)mounting them.
mount.sh:
#!/bin/bash
# mount
gksudo -k /bin/echo "got r00t?"
BASENAME=`basename $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS`
MOUNTPOINT="/media/$BASENAME"
if [ ! -d "$MOUNTPOINT" ] ; then
sudo mkdir "$MOUNTPOINT"
fi
ret=`sudo mount -o loop,uid=$UID,gid=$GROUPS $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS "$MOUNTPOINT"`
if [ $? ] ; then
zenity --info --title "ISO Mounter" --text "$BASENAME Successfully Mounted."
exit 0
else
zenity --error --title "ISO Mounter" --text "Could not mount $BASENAME!\nReason: $ret"
sudo rmdir "$MOUNTPOINT"
exit 1
fi
unmount.sh:
#!/bin/bash
# unmount
gksudo -k /bin/echo "got r00t?"
BASENAME=`basename $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS`
MP="/media/$BASENAME"
ret=`sudo umount "$MP"`
if [ $? ] ; then
zenity --info --title "ISO Mounter" --text "Successfully unmounted $MP"
sudo rmdir "$MP"
exit 0
else
zenity --error --title "ISO Mounter" --text "Could not
unmount $MP\nReason: $ret"
fi