Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)

A package install I was doing got interrupted and when I tried to remove it I got the following error.

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?.

To fix I found out what process was using the lock

sudo lsof /var/lib/dpkg/lock

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME dpkg 9442 root 3uW REG 179,2 0 7067 /var/lib/dpkg/lock

And then killed it off

sudo kill -9 9442

Continue Reading

Upgrade Debian 6 Squeeze To Wheezy 7

I had a debian box which I needed to upgrade speciffically to wheezy.

Open the sources file and change the word squeeze to wheezy
nano /etc/apt/sources.list
Change the words ‘squeeze’ to ‘wheezy’

deb wheezy main
deb-src wheezy main
deb wheezy/updates main
deb-src wheezy/updates main

# wheezy-updates, previously known as 'volatile'
deb wheezy-updates main
deb-src wheezy-updates main

Save and exit
apt-get update
apt-get upgrade
apt-get dist-upgrade
Job done 🙂
Continue Reading

Samba hide dot files

Setting up a Samba server at work using local users I found that when logging via windows the following files were displayed in the shared folder

 Now there there is a possibility that these files can be deleted via the share which would impact the local ssh user. After searching I found that there is a variable that can be set in smb.conf by putting
hide dot files = yes
 in the [homes] section, however as I found out if you have windows set to ‘view hidden files’ this takes priority and the files are still shown.
 After much more searching I found the veto function, so adding
veto files = /.*/
to [homes] section results in the . (dot) files not being displayed. So my smb.conf [homes] looks like this
comment = Home
Directories browseable = no
writable = yes
create mask = 0700
directory mask = 0700
valid users = %S
veto files = /.*/
Don’t forget to restart Samba after making the change.
Continue Reading

bash: /bin/rm: Argument list too long

I came across this error when trying to delete lots of files on Debian Squeeze. This error apparently occurs due to the reason that the system commands show limitations when a large number of arguments are fed into a single command.
so I created a bash script called bulkrm containing
for i in *; do
rm -f $i;
chmod +x bulkrm
Continue Reading

NAS space getting low

Alas after 3 running for 3 years the space on my home NAS is running low.
Filesystem            Size  Used Avail Use% Mounted on
/dev/md0              915G  905G  9.9G  99% /
So it's time to upgrade however due to budget constraints and the fact I need 2 for raid it will only be to 2TB drives.
Now comes the question of which disks to use. Currently I use 1TB Samsung HD103SJ drives and to be honest they've served me well in a 24/7 environment running for 3 years. 
Go with cheaper Toshiba drives for £60 each however i'm a little cautious as I haven't used Tosh drives much. 
Or for £77.96 each I can have the quality Western Digital "RED" drives but reading the reviews on amazon there seems to be an issue with warranty being 'out of region' which means they will not honour the warranty in the UK meaning you would only get the 1 year warranty from amazon and not the full 3 year WD one. It also appears the seller is shipping the 3 platter version instead of the 2 platter one which perform better with less noise.
After some research and reading of reviews i've decided to stick with the samsungs and found them slightly cheaper here
Continue Reading

Testing usb flash drive speeds in linux

I’m pondering a project which will need a reasonably fast write usb flash drive so I decided to root around in drawers behind cupbaords and under sofas to find some to test.

All are formatted as FAT32 and tested on my Debian linux box.

read test conducted using dd if=/dev/sde of=/dev/null bs=10000 count=10000
write test conducted using dd if=/dev/zero of=/dev/sde bs=1M count=100

Sandisk cruzer slice 8GB
r 100 MB copied, 6.01249 s, 16.6 MB/s
w 105 MB copied, 28.5709 s, 3.7 MB/s

integral Courier 4GB
r 100 MB copied, 6.60859 s, 15.1 MB/s
w 105 MB copied, 23.9367 s, 4.4 MB/s

Sony Microvault 4GB
r 100 MB copied, 5.85735 s, 17.1 MB/s
w 105 MB copied, 11.8885 s, 8.8 MB/s

Integral AG47 4GB
r 100 MB copied, 5.53511 s, 18.1 MB/s
w 105 MB copied, 13.9816 s, 7.5 MB/s

Continue Reading

Installing Debian Lenny Via USB Flash

On existing Debian machine insert formatted usb flash

dmesg should show something similar to

usb 4-4.4: new high speed USB device using ehci_hcd and address 8
usb 4-4.4: configuration #1 chosen from 1 choice
scsi4 : SCSI emulation for USB Mass Storage devices
usb 4-4.4: New USB device found, idVendor=0781, idProduct=5406
usb 4-4.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 4-4.4: Product: U3 Cruzer Micro
usb 4-4.4: Manufacturer: SanDisk
usb 4-4.4: SerialNumber: 45271013A181B72F
scsi 4:0:0:0: Direct-Access     SanDisk  Cruzer           8.01 PQ: 0 ANSI: 0 CCS
sd 4:0:0:0: [sde] 3907711 512-byte hardware sectors (2001 MB)
sd 4:0:0:0: [sde] Write Protect is off
sd 4:0:0:0: [sde] 3907711 512-byte hardware sectors (2001 MB)
sd 4:0:0:0: [sde] Write Protect is off
sde: sde1
sd 4:0:0:0: [sde] Attached SCSI removable disk


zcat boot.img.gz > /dev/sde (where sde is your USB device name which was obtained from the dmesg output)

Now it is a good idea to remove un-plug and plug back in your USB devices so that the new partition table/structure is recognized by the Linux system. I had to do this. This refreshes the drives partition table stored by udev.

mount /dev/sde /mnt/ (replace sde with whatever your dmesg shows)


cp debian-508-i386-netinst.iso /mnt

umount /mnt/sde

That’s it. You have successfully created USB flash installation media. Just plugin the USB stick to the computer on which you would like to install Debian Lenny and set the BIOS to boot from USB stick.

Continue Reading