Sunday, November 26, 2006

Tar gzip and Bzip2 usage

Tar and bzip2 in one command:
tar -cf - /etc/ | bzip2 > etc.tar.bz2
tar -cjvf etc.tar.bz2 /etc/

Tar and gzip in one command:
tar -cvzf file.tar.gz files (GNU tar)
tar -cvf - files | gzip > file.tar.gz

List contents of gzip file:

gzcat file.tgz | tar -tvf -
gunzip < file.tgz | tar -tvf -

To Extract gzip (.tar.gz /.tgz) files:
gunzip < file.tgz | tar -xvf -
gzcat file.tgz | tar -xvf -
tar -zxvf file.tgz

List contents of bzip2 file:
bzcat jazwww.tar.bz2 | tar -tvf -
bzip2 -cd jazwww.tar.bz2 | tar -tvf -

To Extract bzip2 files:
bzcat jazwww.tar.bz2 | tar -xvf -
bzip2 -cd jazwww.tar.bz2 | tar -xvf -

To List or Extract a subset of files from a tar:
tar -tvf jazwww.tar usr/bin/
tar -xvf jazwww.tar usr/bin/
bzip2 -cd jazwww.tar.bz2 | tar -tvf - usr/bin/

# -p option preserves original permissions upon extract

loopback mount

Enable loopback support in the kernel
Device Drivers > Block Devices > Loopback device support

Mount file / ISO
mount -o loop -t iso9660 filename.iso /mnt/iso


Create an ISO Filesystem
mkisofs -o backup.iso -x /home/joeuser/junk/ -J -R -A -V -v /home/joeuser/
-o Specifies an output file name of the ISO image.
-J Generates Joliet naming records; for Windows environments.
-R Generates Rock Ridge (RR) naming records
-A Sets an Application ID
-V Sets a Volume ID
-v Sets verbose execution
-x Excludes any directory

Check for scsi device
  cdrecord -scanbus
Burn disk
  cdrecord -v -eject speed=4 dev=0,3,0 backup.iso
Blank CD-RW
  cdrecord --dev=0,3,0 --blank=fast

EncFS Usage

To install
./configure; make; make install

To test:
mkdir /tmp/crypt-raw
mkdir /tmp/crypt
encfs /tmp/crypt-raw /tmp/crypt
Asks you for various options like password
cd /tmp/crypt

To unmount
fusermount -u /tmp/crypt


Kernel options needed:
Device Drivers > Block Devices > Loopback device support cryptoloop support
Cryptographic Options > (select cyphers.. ex. aes, twofish)

Update user space tools if needed

Fill a file or partition with random data:
dd if=/dev/urandom of=/dev/hda1 bs=1M
dd if=/dev/urandom of=/somefile.aes bs=1M count=10

Check what encryption methods are available
Note: the method will not show up if the method was compiled as a module and the module was not yet loaded.
cat /proc/crypto

Associate loop device with created file or partition
losetup -e aes-256 /dev/loop0 /dev/hda1
losetup -e aes-256 /dev/loop0 /somefile.aes
losetup -e twofish-256 /dev/loop0 /somefile.aes
You are asked to create a password

Format the new filesystem
mkfs.ext3 /dev/loop0

Mount the new filesystem
mkdir /mnt/crypto
mount -t ext3 /dev/loop0 /mnt/crypto

To unmount:
unmount /mnt/crypto
losetup -d /dev/loop0

Monday, November 20, 2006


View settings
hdparm /dev/hda

Test performance
hdparm -tT /dev/hda

Set Settings
hdparm -X66 -d1 -u1 -m16 -c3 /dev/hda