August 19

Linux: Create an ISO Image from a source CD or DVD under Linux

If an ISO image has been created with the help of the dd (diskdump) command from a CD or DVD then the ISO file created thereby may have an MD5 checksum, which is different than the original ISO file that was used for burning the source CD or DVD. A pair of zero data blocks at the end of the CD or DVD are responsible for this. Such an ISO image can be used without any problems, however testing the MD checksum against the source disk cannot be done (the download servers that provide ISO image for Linux, for example, typically also provide MD5 checksums for testing).

Using the following procedure, exactly the same ISO image that was used for burning the CD or DVD can be read from a CD or DVD:

1. Reading the block size and the volume size:

[root@testserver ~]# isoinfo -d -i /dev/cdrom | grep -i -E 'block size|volume size' 
Logical block size is: 2048
Volume size is: 327867

2. Running dd with the parameters for block size and volume size:

[root@testserver ~]# dd if=/dev/cdrom of=test.iso bs=<block size from above> count=<volume size from above>

Note: When reading the ISO image, the following command can be used in a second console for viewing the current progress status (requires root rights):

killall -USR1 dd

With the of watch, this call can also be executed each second:

watch -n 1 killall -USR1 dd

Thereby, dd will display the progress status as follows:

admin@adminpc:~/Downloads/isos$ dd if=/dev/sr0 of=cdimage.iso bs=10M
1+0 records in
0+0 records out
0 bytes (0 B) copied, 10.2447 s, 0.0 kB/s
2+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 16.3769 s, 640 kB/s
3+0 records in
2+0 records out
20971520 bytes (21 MB) copied, 22.3123 s, 940 kB/s
5+0 records in
4+0 records out
41943040 bytes (42 MB) copied, 33.6603 s, 1.2 MB/s

By: Werner Fischer

Category: Linux | Comments Off on Linux: Create an ISO Image from a source CD or DVD under Linux
July 20

Linux: Download from a list of URLs

Downloading a list of files is very easy using wget.
1. Save your url list to a text file on in a folder of your choice
2. Type: wget –content-disposition –trust-server-names -i yoururllist.txt

You can download your files even faster using parallel processing.
1. Save your url list to a text file on in a folder of your choice
2. sudo apt-get parallel
3. parallel –gnu -a yoururllist.txt wget –content-disposition –trust-server-names

This will download as many of the files as it can at one time using all of your computers processor cores.
If you have a File Manager open it is pretty cool to see the files appearing at the same time.
If the server you are connecting to allows multiple connections from the same source, it is an incredibly fast way to download a list of files.

Credit: Tim Conrad

Category: Linux | Comments Off on Linux: Download from a list of URLs
July 14

Linux: Detect a new drive without rebooting

Sometimes we can run into a situation where we need to add a drive to a running virtual linux machine.    There is a way to nudge linux to see the newly attached physical drive from the command line.

In the below path you can find a list of host symlinks pointing to the iscsi device configured on your Linux box

# ls -l /sys/class/scsi_host/
yourname@computername:~$ ls -l /sys/class/scsi_host/
total 0
lrwxrwxrwx 1 root root 0 Jun 15 08:30 host0 -> ../../devices/pci0000:00/0000:00:07.1/host0/scsi_host/host0
lrwxrwxrwx 1 root root 0 Jun 15 08:30 host1 -> ../../devices/pci0000:00/0000:00:07.1/host1/scsi_host/host1
lrwxrwxrwx 1 root root 0 Jun 15 08:30 host2 -> ../../devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2

But to detect a new hard drive attached you need to first get your host bus number used which you can get by using below command
# grep mpt /sys/class/scsi_host/host?/proc_name

You should get a output like below
/sys/class/scsi_host/host2/proc_name:mptspi

So as you see your host2 is the relevant fiels where you need to reset the storage buffer values. Run the below command
# echo “- – -” > /sys/class/scsi_host/host2/scan

Here “- – -“ defines the three values stored inside host*/scan i.e. channel number, SCSI target ID, and LUN values. We are simply replacing the values with wild cards so that it can detect new changes attached to the Linux box. This procedure will add LUNs, but not remove them.

Once done verify if you can see the new hard drive which in my case worked very fine as I see below
# fdisk -l
Disk /dev/sdb: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Credit: D. Prasad

Category: Linux | Comments Off on Linux: Detect a new drive without rebooting
June 15

Linux: How to open multiple xterm windows while running a command in bash

My goal was to ssh to several servers at the same time. I wanted to open a new terminal for each connection. Then within the terminal, run a separate bash session launching my ssh connection. You have to launch within bash if you want to be able to continue using the terminal session after you exit your ssh session. I also wanted each terminal window to open at a different location on my screen,

The code below does the following
1. Generates six random horizontal numbers
2. Generates six random vertical numbers
3. starts each xterm application at random location, launching the command inside of a bash shell.

#!/bin/bash
data=($( shuf -i 75-1000 -n 6))
data2=($( shuf -i 75-450 -n 6))
#echo ${data[1]}
#echo ${data[2]}
xterm -geometry 150×32+${data[1]}+${data2[1]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[2]}+${data2[2]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[3]}+${data2[3]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[4]}+${data2[4]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[5]}+${data2[5]} -e bash -c ‘command; bash’ &
xterm -geometry 150×32+${data[6]}+${data2[6]} -e bash -c ‘command; bash’ &

By: nighthawk

Category: Linux | Comments Off on Linux: How to open multiple xterm windows while running a command in bash