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


http://en.wikipedia.org/wiki/Bzip2
http://www.gzip.org/

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

http://en.wikipedia.org/wiki/Loopback_mount

cdrecord

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


http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/getting-started-guide/s1-disks-cdrw.html

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

http://arg0.net/wiki/encfs/intro2

Cryptoloop

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
util-linux

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

http://tldp.org/HOWTO/Cryptoloop-HOWTO/

Monday, November 20, 2006

hdparm

View settings
hdparm /dev/hda

Test performance
hdparm -tT /dev/hda

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

http://www.linuxdevcenter.com/pub/a/linux/2000/06/29/hdparm.html?page=2