dpkg commands

dpkg --get-selections

Lists all currently installed packages on the system. If a package has been removed with apt-get remove command but not purged, it will list deinstall next to the package in the list.

dpkg --purge `dpkg --get-selections | grep deinstall | cut -f1`

This will purge all packages listed as deinstall by –get-selections command (http://nialldonegan.me/2007/09/05/cleaning-up-after-aptget-remove/). It can be prevented by editing /etc/apt/apt.conf, or in ubuntu by creating a file in /etc/apt/apt.conf.d/ (I called mine 20get) with the below in it.

    APT
    {

Get
{
    Purge “true”;
}

}

ISCSI Commands

Show Targets:
tgtadm --lld iscsi --mode target --op show
Add Initiator to Target:
tgtadm --lld iscsi --mode target --op bind --tid=1 -I 1.1.1.1
Remove Initiator from Target:
tgtadm --lld iscsi --mode target --op unbind --tid=1 -I 1.1.1.1

VZ iptables config

/etc/sysconfig/iptables-config
IPTABLES_MODULES="iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_conntrack ipt_state ipt_helper iptable_nat ip_nat_ftp ip_nat_irc ipt_REDIRECT xt_mac ipt_owner ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp"

/etc/vz/vz.conf
IPTABLES="iptable_filter iptable_mangle ipt_limit ipt_multiport ipt_tos ipt_TOS ipt_REJECT ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_LOG ipt_length ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_conntrack ipt_state ipt_helper iptable_nat ip_nat_ftp ip_nat_irc ipt_REDIRECT xt_mac ipt_owner ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp"

How to check the filesystem for a Windows VE if it has ntfs errors?

Symptoms
The following error appears on the node in Event Viewer:

Event Type: Error
Event Source: Ntfs
Event Category: Disk
Event ID: 55
Date: 8/24/2006
Time: 8:04:16 AM
User: N/A
Computer: VZWINNODE
Description:
The file system structure on the disk is corrupt and unusable. Please run the chkdsk utility on the volume \Device\VZLPBKVolumes\VZLPBKVolume{F9B7EA79-9590....For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Cause
Virtual disk of VE with GUID started with {F9B7EA79-9590... is corrupted.

Resolution:
1. List GUIDs of all VEs and choose the required one (create a .cmd, copy commands below and run to list all GUIDs):
@echo off
for /F "skip=3 usebackq tokens=*" %%i in (`cmd /c "vzlist -ao veid"`) do (cmd /c "vzcfgt get %%i GUID" && echo is GUID of VE %%i)

2. Stop issued VE:
vzctl stop VEID

3. Do copy of z:\vz\private\VEID\root.efd for emergency cases.

4. Mount root.efd file:
vzdskctl mount z:\vz\private\VEID\root.efd GUID

5. Run chkdsk on mounted root.efd
chkdsk /f \\?\VolumeGUID

where GUID (after Volume) is a value obtained at step (1).

6. When it’s finished – unmount root.efd:
vzdskctl umount GUID

7. Start VE:
vzctl start VE

A real life example:

vzctl stop 115
vzcfgt get 115 GUID
vzdskctl mount c:\vz\private\115\root.efd {799251BE-720C-468E-B877-913F49476001 }
chkdsk /f \\?\Volume{799251BE-720C-468E-B877-913F49476001 }
vzdskctl umount {799251BE-720C-468E-B877-913F49476001 }
vzctl start 115

Note: this approach works perfectly for additional drives, added via the Mount manager, ie drives D:\ or E:\ Use the additional drive’s GUID from the c:\vz\conf\VEID.conf instead of the VE’ primary GUID to perform the same operations, see GUID example for drive D: DRIVE_D=”type=loopback;file=lpbk0000.efd;guid={cc4a1cb5-9f9d-47ac-a09f-0e6b87643105 };”

Source: http://kb.parallels.com/1008