DON'T PANIC

Archive for November 2010

I will assume that the device will be format is called /dev/sdb

1. You should assure the device is unmounted.

# umount /dev/sdb

2. Fdisk is an Unix tool usefull to format devices.

# fdisk -l /dev/sdb

Usefull parameters:

2.1 -l list partitions table.
2.2 d delete partitions.
2.3 n Create partitions.
2.4 t Change partition type.
2.5 w Write changes.
2.6 q Quit.

3. Disconnect usb stick and come back to connect.

4. Format the usb stick.

# mkfs -t vfat /dev/sdb1

Advertisements

LVM is a logical volume manager for Linux kernel. It’s based on Veritas’s logical volume manager.
LVM can:

  • Resize volume groups online by absorbing new physical volumes (PV) or ejecting existing ones.
  • Resize logical volumes (LV) online by concatenating extents onto them or truncating extents from them.
  • Create read-only snapshots of logical volumes (LVM1).
  • Create read-write snapshots of logical volumes (LVM2).
  • Stripe whole or parts of logical volumes across multiple PVs, in a fashion similar to RAID 0.
  • Mirror whole or parts of logical volumes, in a fashion similar to RAID 1.
  • Move online logical volumes between PVs.
  • Split or merge volume groups in situ (as long as no logical volumes span the split). This can be useful when migrating whole logical volumes to or from offline storage.
  • (Last pharagraph was taken from Wikipedia)

    1. You can create a Physical Volume on whole disk or on a patition.

    # pvcreate /dev/sda

    2. Create a Volume Group too.

    # vgcreate vg0 /dev/sda

    3. Create a Logical Volume inside Volume Group created recently.

    # lvcreate -n lv_home --size 40g vg0

    4. Format the lv_home partition.

    # mkfs.ext3 -L home /dev/mapper/lv_home

    5. You have to add entries in ”/etc/fstab” file.

    # vi /etc/fstab


    /dev/mapper/home /home ext3 defaults,noatime 0 2 0

    5. Add necessaries data to ramdisk

    # update-initramfs -u -k all

    6. Extend a LVM partition
    6.1 Boot the system using a live cd
    6.2 Umount the partition to be extended.

    #umount/mnt/lvm/localvg-usrlv

    6.3 Extend the Logical partition to 2G (giga)

    #lvextend --size +2G -n /dev/localvg/usrlv

    6.4 Run fsck

    #e2fsck -f /dev/localvg/usrlv

    6.5 Extend the filesystem

    #resize2fs /dev/localvg/usrlv

    6.6 Run fsck

    #e2fsck -f /dev/localvg/usrlv

    7. Reduce a LVM partition
    7.1 Umount the partition

    #umount /home

    7.2 Reduce the filesystem

    #resize2fs /dev/myvg/homevol 524288

    7.3 Reduce the LVM partition

    #lvreduce -L-1G /dev/myvg/homevol

    7.4 Run fsck

    #e2fsck -f /dev/myvg/homevol

    7.5 Mount the partition

    # mount /home

    Tar

  • Pack
  • $ tar cvf archivo.tar /directorio/subdirectorios/*

  • Unpack
  • $ tar xvf archivo.tar

  • List details
  • $ tar tvf archivo.tar

    Tar and Gzip

  • Pack and compress
  • $ tar czvf archivo.tar.gz /directorio/subdirectorios/*

  • Unpack and uncompress
  • $ tar xzvf archivo.tar.gz

  • List details without extract
  • $ tar tzvf archivo.tar.gz

    Gzip

  • Compress
  • $ gzip -q archivo
    The last line returns the archive "archivo.gz".

  • Uncompress
  • $ gzip -d archivo.gz
    The last line returns the archive "archive"

    Bzip2
    Bzip2 only compress directorios not archives.

  • Compress
  • $ bzip2 archivo
    The last line returns an archive called "archivo.bz2"

  • Uncompress

  • $ bzip2 -d archivo.bz2
    $ bunzip2 archivo.bz2

    Ones last lines returns an archive called "archivo".

    Tar and Bzip2

  • Compress
    $ tar -c archivos | bzip2 > archivo.tar.bz2

  • Uncompress

  • $ bzip2 -dc archivo.tar.bz2 | tar -xv
    $ tar jvxf archivo.tar.bz2 (versiones recientes de tar)

  • List details
  • $ bzip2 -dc archivo.tar.bz2 | tar -tv

    Zip

  • Compress
  • $ zip archivo.zip /archivo/subdirectorios

  • Uncompress
  • $ unzip archivo.zip

  • List details
  • $ unzip -v archivo.zip

    Rar

  • Compress
  • $ rar -a archivo.rar /archivo/subarchivos

  • Uncompress
  • $ rar -x archivo.rar

  • List details

  • $ rar -v archivo.rar
    $ rar -l archivo.rar

    Running “apt-get update” command always before installing packages is boring and is a waste of time. Cron-apt is a tool that is run by a cron job at regular intervals. By default it just updates the package list and downloads new packages without installing.
    You can instruct it to run anything that you can do with apt-get or aptitude. It can optionally send mail to the system administrator on errors, log to syslog or a separate log file.

    1. Install “cron-apt” package.
    # apt-get install cron-apt

    2. You should define frecuency to run apt periodically in /etc/cron.d/cron-apt. In my case, I have defined to run cron-apt

    # vi /etc/cron.d/cron-apt


    #
    # Regular cron jobs for the cron-apt package
    #
    # All Sundays at 10:15 am.
    15 10 * * 0 root test -x /usr/sbin/cron-apt && /usr/sbin/cron-apt

    If you don’t remember cron definition, below I have pasted a piece of text from Wikipedia:

    Sintax
    «#» is a comment.
    At the moment to run it will define from next table:
    Minutes: (0-59)
    Hours: (0-23)
    Days: (1-31)
    Months: (1-12)
    Day of week: (0-6), siendo 1=Monday, 2=Thursday,... 6=Saturday y 0=Sunday (Sometimes it could be 7=Sunday)
    ##########################################################
    #minute (0-59), #
    #| hour (0-23), #
    #| | day of month (1-31), #
    #| | | month (1-12), #
    #| | | | day of week (0-6 which 0=Sunday) #
    #| | | | | commands #
    ##########################################################
    15 02 * * *

    3. You can define which tool use in /etc/cron-apt/config. It would be: apt or aptitude.

    # vi /etc/cron-apt/config


    # APTCOMMAND=/usr/bin/apt-get
    APTCOMMAND=/usr/bin/aptitude
    # APTCOMMAND

    4. In /etc/cron-apt/action.d/ you can define which actions do.

    Sshfs is a filesystem client based on the SSH File Transfer Protocol.
    On the server side there’s nothing to do. On the client side mounting the filesystem is as easy as logging into the server with ssh.

    On the client side, where you want to mount the filesystem.
    1. You need to install next packages:

    # apt-get install fuse-utils sshfs

    2. You have to create a mount directory:

    # mkdir --parents /mnt/sshfs

    3. Give access permission to mount directory.

    #chown user:group /mnt/sshfs
    #chmod 755 /mnt/sshfs

  • user: who have permission to mount /mnt/sshfs.
  • group: which is part the user.
  • 4. Add user to fuse group.

    # adduser user fuse

    5. You can check fuse permissions. It should show something like that:

    $ ls -l /dev/fuse
    crw-rw---- 1 root fuse 10, 229 ago 27 17:00 /dev/fuse

    How to use sshfs?
    1. Mount filesystem

    $sshfs user@remote_host:/music /mnt/sshfs

    2. Unmount filesystem

    $fusermount -u /mnt/sshfs

    Sshfs has many optional parameters, whose are pretty nice 🙂

    -o reconnect
    reconnect to server

    -o sshfs_sync
    synchronous writes

    -o no_readahead
    synchronous reads (no speculative readahead)

    -o sshfs_debug
    print some debugging information

    -o cache=YESNO
    enable caching {yes,no} (default: yes)

    -o cache_timeout=N
    sets timeout for caches in seconds (default: 20)

    -o cache_X_timeout=N
    sets timeout for {stat,dir,link} cache



    • analialorenzatto: Buzz is just a host name for this example, it doesn't have any relation to the topic. Instead of being "Buzz", could be whatever name.
    • fridelain: >buzz What's the story behind this host name? Actully running buzz, once running buzz and upgraded many times since, or unrelated to debian naming
    • Pratik: Nice, but I would change it to include more directories. Like my .mozilla and .kde4 by using .{config,mozilla,kde4} instead of just .config .

    Categories