How to mount an image file and access image content
To get access to the content of a virtual machine image or a ISO file, follow these steps:
- associate the file with a loop device node:
# losetup /dev/loop0 /var/otheros.img
- list the partition table of the device:
# fdisk -l /dev/loop0 Disk /dev/loop0: 21.4 GB, 21474837504 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/loop0p1 * 1 2609 20956761 7 HPFS/NTFS
- create device map (
kpartx
is part ofmultipath-tools
package on Ubuntu):
# kpartx -a /dev/loop0 # ls -l /dev/mapper/ total 0 crw-rw---- 1 root root 10, 62 Jul 6 2008 control brw-rw---- 1 root disk 253, 0 Jul 5 23:18 loop0p1
- mount the device partition:
# mount /dev/mapper/loop0p1 /mnt


Posted by: Z24 | Wed, May 04 2011 |
Category: /linux |
Permanent link |
home
Tagged as: command-line, linux, shell
Pausing a command
How to pause / suspend / sleep a running command in a terminal?
Press Ctrl+S
How to resume the paused command?
Press Ctrl+Q
Posted by: Z24 | Wed, May 04 2011 |
Category: /linux |
Permanent link |
home
Tagged as: command-line, linux, shell
How to rename multiple files from bash
Rename all *html files to *test:
for x in `ls *html`; do mv $x `echo $x | sed -e "s/html/test/"`; done
Bash for:
for var in some-list ; do command ; done


Posted by: Z24 | Wed, May 04 2011 |
Category: /linux |
Permanent link |
home
Tagged as: command-line, linux, programming, script, shell
Execute a command at shutdown
To dismount TrueCrypt volumes at shutdown and reboot time, I created a script, put it in/etc/init.d/
and symlinked it into the needed /etc/rc?.d/
directories using update-rc.d
.
Here is the detail:


Posted by: Z24 | Wed, May 04 2011 |
Category: /linux |
Permanent link |
home
Tagged as: command-line, linux, programming, script, shell