Sometimes I have to check drives under their native operating system. Recently I wanted to access a ntfs partition directly under Windows running inside a virtual machine. Here’s how to (easily) do it:
VBoxManage internalcommands createrawvmdk -filename ./ntfs_test.vmdk -rawdisk /dev/sdb -register
VirtualBox Command Line Management Interface Version 1.5.4
(C) 2005-2007 innotek GmbH
All rights reserved.
RAW host disk access VMDK file ./ntfs_test.vmdk created successfully.
[/ccNe_bash]
What this means? Well:
We create a virtual machine disk (vmdk) pointing to you physical drive. /dev/sdb in our case, be sure to point to yours. -register if set will tell VirtualBox to already register the drive inside your Virtual Media Manager.
DANGER: the disk will be fully available to the guest operating system. This means full access – so any command you use is definitive. Should you delete, partition or format the drive this will happen exactly as if you have booted the guest operating sytem directly.
Apache 2.2 will not serve corectly from CIFS mounted share
I have a home server I use for all kinds of stuff when I’m away. I have set it up recently so that it can serve a folder mounted over the network from a Windows machine.
And this is where the fun started!
The folders and files appear correctly, I can navigate and I can download them. Only that the files, even if apparently having the same size are corrupted. I checked the FollowSymLinks and as expected was set as required. I tried wget in the command prompt to see if I could find some enlightment but I got the following errors:
[ccNe_bash]
wget http://192.xxx.xxx.xxx/windowsshare/folder/file.jpg
–09:18:00– http://192.xxx.xxx.xxx/windowsshare/folder/file.jpg
=> `file.jpg’
Connecting to 127.0.0.1:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 763,685 (746K) [image/jpeg]
0%
[ ]
0 –.–K/s
09:18:00 (0.00 B/s) – Connection closed at byte 0. Retrying.
–09:18:01– http://192.xxx.xxx.xxx/windowsshare/folder/file.jpg
(try: 2) => `file.jpg’
Connecting to 127.0.0.1:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 763,685 (746K) [image/jpeg]
file.jpg has sprung into existence.
Retrying.
–09:18:03– http://192.xxx.xxx.xxx/windowsshare/folder/file.jpg
(try: 3) => `file.jpg.1′
Connecting to 127.0.0.1:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 763,685 (746K) [image/jpeg]
0%
[ ]
0 –.–K/s
[/ccNe_bash]
and it will continue like this creating empty files.
Especial the has sprung into existence baffled me. Also note that symlinking any other folder, even mounted as smbfs instead of cifs worked perfectly. At this point changing the mount to smbfs would have solved my problem but curiosity was stronger.
As it turns either apache or (more likely) the cifs driver has a bug. You can work around it by setting the following inside your apache configuration.
[ccNe_apache]
EnableSendfile off
[/ccNe_apache]
Further upgrades will probably eradicate this problem.
Get the new Firefox 4.0 beta for Linux 64 bit.
I wanted to play a bit with the Mozilla Firefox 4.0 beta. Well, if you go to the download site there’s no apparent way to download the 64 bit version of Firefox. This is where I got it:
How to check if TRIM is enabled on your SSD
God a fancy new drive? SSD maybe? TRIM support advertised?
Well, here’s how you can check if TRIM support is actually enabled and working in your windows installation:
Start a command prompt window (WIN+R, type cmd and press enter)
In the command prompt window type the following:
[ccNe_DOS]
fsutil behavior query disabledeletenotify
[/ccNe_DOS]
You will get one of the following:
DisableDeleteNotify = 1 (Means that Windows TRIM commands are disabled)
DisableDeleteNotify = 0 (Means that Windows TRIM commands are enabled)
What is TRIM and why do you need it
In computing, a TRIM command allows an operating system to inform a solid-state drive (or “SSD”) which data blocks, such as those belonging to a deleted file or affected by a format command, are no longer considered in use and can be wiped internally.
TRIM was introduced soon after SSDs started to become an affordable alternative for traditional hard disks as permanent storage in PCs. Because low-level operation of SSDs differs significantly from traditional hard disks (see details below), the typical way in which operating systems handle operations like deletes and formats (not communicating the involved sectors/pages to the storage medium) resulted in unanticipated progressive performance degradation of write operations on SSDs. TRIM enables the SSD to handle garbage collection overhead, that would otherwise significantly slow down future write operations to the involved blocks, in advance.
[from wikipedia.org]
Core I7 and I5 throtle more than the core 2
I recently found out that the power management inside the new I5 and I7 Intel processors is much more inteligent than what the older core2 has. For example a core2 would throttle back based on temperature only just before the critical point.
The newer I5s and I7s would turn cores on/off or independently, slow down depending on load, power consumption and temperature.
Basically this means that you might get less from your cpu if it runs hot – either because of the weather or because of inappropriate cooling,
Also overclockers should be careful. You might be happy that your machine is stable at the new speed but it could be that it’s only throttling down all the time.
Network interface bonding in Slackware (version 13.1)
A backup NAS I set up for a client had some problems – i.e. from time to time the network card would hang forcing a reboot (the machine was headless). The disks in the nas are RAID 1 providing redundancy in case of failure. We wanted the same with the network. So, nothing easier than to install a second network card and set up bonding.
What is network bonding?
Bonding is the same as port trunking. It means that two (ore more) physical network connections are combine to form one virtual network connection. The added benefit is that bandwidth adds too. So theoretically this could offer multi gigabit capabilities.
How is it configured
First you need a small utility that comes with the linux kernel: ifenslave. So we must compile it. After that it should be moved somewhere more apropriate.
[ccNe_bash]
cd /usr/src/linux/Documentation/networking
gcc -Wall -O -I/usr/src/linux/include ifenslave.c -o ifenslave
cp ifenslave /sbin/ifenslave
[/ccNe_bash]
Then we need some scripts that will set up bonding on boot. So we go to /etc/rc.d and create a new file called rc.bond
[ccNe_bash]
cd /etc/rc.d
touch rc.bond
[/ccNe_bash]
Edit the file you just created to contain the following:
[ccNe_bash]
#!/bin/sh
case “$1” in
‘start’)
echo “start bond0”
modprobe bonding mode=balance-rr miimon=100
modprobe tg3
ifconfig bond0 up
ifenslave bond0 eth0
ifenslave bond0 eth1
#You don’t necesarily need to change the hardware address
#It will take it from the first hardware interface
#ifconfig bond0 hw ether 00:16:3e:aa:aa:aa
;;
‘stop’)
ifconfig bond0 down
rmmod bonding
rmmod tg3
;;
*)
echo “Usage: $0 {start|stop}”
;;
esac
[/ccNe_bash]
Save this file and make it executable
[ccNe_bash]
chmod +x /etc/rc.d/rc.bond
[/ccNe_bash]
We need to start this on boot. So edit rc.M You need to find the line containing #Initialize the networking hardware and insert this after it
[ccNe_bash]
# If script rc.bond is executeable then start it
if [ -x /etc/rc.d/rc.bond ]; then
. /etc/rc.d/rc.bond start
fi
[/ccNe_bash]
Finally we must configure rc.inet1.conf to set our bond interface and to make sure the physical interfaces are not configured. Add the following:
[ccNe_bash]
IFNAME[4]=”bond0″
IPADDR[4]=”XXX.XX.XX.XX”
NETMASK[4]=”255.255.255.0″
USE_DHCP[4]=””
DHCP_HOSTNAME[4]=””
[/ccNe_bash]
Make sure that the physical interfaces, like 0, 1 and so on are NOT configured.
Reboot, and everything will be set.
For your reference those are the bonding modes available:
mode=0 (balance-rr)
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.mode=1 (active-backup)
Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond’s MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.mode=2 (balance-xor)
XOR policy: Transmit based on [(source MAC address XOR’d with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.mode=3 (broadcast)
Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.mode=4 (802.3ad)
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.Pre-requisites: 1. Ethtool support in the base drivers for retrieving the speed and duplex of each slave. 2. A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will require some type of configuration to enable 802.3ad mode.mode=5 (balance-tlb)
Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.
mode=6 (balance-alb)
Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.[source: http://www.linuxhorizon.ro/bonding.html]
The most used are the first four mode types…
Force fsck on next reboot
Let’s say you run a headless server and you want to fsck the main partition. The easy solution in this case is (if possible) to force fsck to run on the next boot.
If you run slackware than all you really need is to create an empty file in /etc called forcefsck
You could do this by running:
[ccNe_bash]
touch /etc/forcefsck
[/ccNe_bash]
Other linux distributions might check for this file elsewhere, for example in the root directory so the command would be
[ccNe_bash]
touch /forcefsck
[/ccNe_bash]
Checking the documentation will always help.
MYSQL: set first letter of field to uppercase
I recently had to set values of a set of values from a column from lowercase to Firstuppercase. Nothing easier, run the following code on the database:
[ccNe_sql]
UPDATE `affected_table` SET
`field_in_question` = CONCAT(UPPER(LEFT(`field_in_question`, 1)),
SUBSTRING(`field_in_question`, 2));
[/ccNe_sql]
Windows XP – prevent a user’s password from expiring
One of my clients called be mecause every now and then his was bugged by Windows XP to change his password. This seemed weird as XP doesn’t do this by default. Probably it was set to expire by someone or by some friendly security suite.
Fortunately the solution for this expiring password problem is easy. You just need to tell Windows that you want your password to never expire. This is not necessarily a good practice, nevertheless if you want to, here is how you do it.
- Go to START->RUN or WIN+R.
- Type control userpasswords2 and hit ENTER
You’ll get a window like this one showing up:
- You have to click the Advanced tab
- Unsurprisingly, on the Advanced tab you have to click the Advanced button. (Who designs this kind of interfaces?)
- In the window that opens you can see your local users and groups.
- Click on Users and double click in the right panel the user you want to set the password not to expire.
- Finally in the new window that opens check Password never expires.
- Apply or OK your way back!
Done. Still it’s a good ideea to change all your passwords from time to time, just to be on the safe side.
Good VPS hosting
Like I said some time ago I had to move my websites from a shared host (bluehost) to a dedicated sollution. Well, the websites I host (for clients, friends and myself) don’t account for the need of a dedicated server so I searched for a virtual sollution.
I finally came to the conclusion that unmanaged is the way for me. I’m working on the old premise “give me a machine, an IP, a net pipe and some power” and I’ll manage from there.
Finally after some research I was left with two: Slicehost and Linode. From the features listed and user testimonials I found on various forums they are equally good. Simply when I needed to sign up Linode offered more space and RAM for the same amount of money, so the choice was easy.
What I like:
- recently awarded more RAM as a 7 year Linode anniversary.
- broad choice of operating systems
- root access including console (if you borke your ssh daemon you can still login)
- disk image tools
- custom warnings on cpu, memory and bandwith increasing over certain limits you get to define(not that you are penalised but it simply means you probabbly have something hanging)
- you can choose the datacenter and move your machine from one to another
- you can easily buy more resources (ram, disk, bandwith)
- It was never down for me
- DNS manager
- Statistics and everything
What I don’t like:
- no symbian application or mobile admin website (only iphone and maybe android) – not a big deal, I still have an ssh client on my phone and the regular website works decent on my nokia’s browser
So, if you’re in the market for a virtual host I can recommend Linode from all my heart.