Pages

Showing posts with label lvm. Show all posts
Showing posts with label lvm. Show all posts

Thursday, March 1, 2012

Linux Tools

This list will continue to grow as I come across useful tools in Linux. I have also listed the command-line that I most frequently use:

ps - get the process information
  • ps -flycae # will give information on scheduling class and kernel function name where process is sleeping
mcelog - Machine check log
  • Determine system errors, decode, and log in syslog like /var/log/messages
    mcelog --dmi --syslog
    PS: The decoded hardware module is sometimes not helpful in determining the module at fault
OProfile - Profiling Linux system
  • Covered under separate post here
mdadm - Manage Software  RAID
  • Use mdadm for software mirroring devices:
    mdadm -C --level=raid1 --raid-devices=2 /dev/md0 /dev/sdb1 /dev/sdc1
    mdadm --manage /dev/md0 --fail /dev/sdc1
    mdadm --manage /dev/md0 --remove /dev/sdc1
    mdadm --manage --stop /dev/md0
    For striping, better to use LVM
LVM - Logical Volume Manager
  • pvcreate <list of devices>
  • vgcreate <vg-name> <list of pv devices>
  • lvcreate -i<#of vg devices to stripe across> -I<stripe-size-default64k> -L<size-in-MB> -n<volume-name> <vg-name>
MUTT - The Mutt Mail User Agent
  • echo "<message-body>" | mutt -a <attachment-file> -s "<subject>" <To email> [-b <BCC email>] [-c <CC email>] 

Sunday, May 22, 2011

Editing Xen System.img

This post is useful when you want to change system configuration files of a stopped guest VM without botting up the guest first. This method can be used especially when your guest VM crashes or hangs during boot up due to a configuration error.


The following steps have been tested on Xen 4 and Oracle VM 2.2 as well for a Linux guest VM. From DOM0: 


Check FS Type
fdisk -u -l System.img

If FS type is ext3, you can directly mount a partition using lomount, otherwise follow the mounting LV's steps.

Mount Ext3 Partitions

Linux system.img with ext3 partitions can be mounted as:
lomount -diskimage System.img -partition 2 /mnt

Mounting LV's

# Mounting guest's root partition locally
# Find a free loop device
loop_dev=`losetup -f`

# Now bind the image file to that loop device
losetup ${loop_dev} System.img

# Next, scan the loop device for partitions
kpartx -av ${loop_dev}

# If /dev/mapper doesn't list LVs for the partitions from kpartx, find LV:
vgscan
vgchange -ay sysvg

# Mount the desired LVM
mount /dev/mapper/loop0p2 /mnt

LVs UnMounting
# After editing in /mnt, unmount and remove partitions:
umount /mnt

# Disable the LV
vgchange -an /dev/mapper/loop0p2

# Remove the discovered partitions
kpartx -dv ${loop_dev}

# Delete the loop device
losetup -d ${loop_dev}