Showing posts with label sysadm. Show all posts
Showing posts with label sysadm. Show all posts

2010-09-27

Archiving on hard disk

How I archive at home:

The difference between an archive and a backup


The most important difference is an archive is the master copy and a backup is not a master copy. If you lose the archive copy, you risk losing the content permanently. Because it is is the master copy, it is sensible to have a backup for the master copy.


Media choice


I used to archive to CD-Rs and DVD-Rs. They had a great GiB/$ ratio which was an important factor for me. They were also impervious to some damages: power surge, file-system corruption, fat-finger deletion, etc. But they were inconvenient to handle as you need many of them. It was not so bad 10 years ago when I had my first CD-R drive because my data size was small wrt. to CD-R size. But over the years, my data size grew and grew and I've gotten lazier feeding DVD-Rs into the drive.

Now I archive to harddisk. It has became economical to do so. As of today, the lowest ratio for SATA harddrive [1] on newegg.com is 14.70GiB/$. You'd need at least 2 of them, which brings it to 7.35GiB/$. The cheapest DVD-R media goes for $18.00 for 100 single-layer discs[2], equivalent to 24.27GiB/$. DVD-Rs are still cheaper, but it takes a lot of time to write to them.

Burning one DVD-R takes 15 mins, writing the equivalent amount, 4.37GiB to a harddisk through USB2 (assume write speed is 20MiB/s) takes about 3.7 mins. Let's assume that we are going for time and so we do not bother validating the archive (re-reading), and also the data stored exactly occupies a DVD-R.  The first assumption gives a huge advantage to the DVD-R because it eliminates a huge overhead in validation: the media has to be ejected and re-inserted. The second assumption also eliminates the overhead in changing DVD-R media. So, the time saved is 11.3 mins/4.37GiB = 2.59mins/GiB. If you have to archive 100GiB, copying it to harddrive is quicker by 100*(15-3.7 mins/4.37GiB) = 4.31 hours. In reality, the time saved, thus the time-cost difference, is even more pronounced as you don't have to wait in front of the computer while the data is being copied. I am usually present for less than 5 minutes total: initiate copying, initiate validation. The time difference that matters to you (you not being a slave to the DVD-R drive overlord) is 100*15mins/4.37GiB - 5mins = 5.63 hours/100GiB.

For a time saving of 5.63 hours/100GiB, I'd pay the cost difference of 100*(24.27-7.35)/(24.27*7.35) = $9.49/100GiB for harddrive.


[1] $95 for 1.5 TB HD is $95 for 1396.98 GiB = 14.70GiB/$.
[2] SL DVD+R capacity: 2295104 2KiB sectors = 4.37 GiB. $18 for 100 discs = 24.27GiB/$.


Backup of archive


According to some articles, harddrive is prone to losing its magnetism when stored for a long time. This supposedly affects recent, high-density harddisk because the bits are packed closely together. Other causes that can affect a harddrive: the motor lubrication may evaporate or chemically degrade so as to prevent the disk spinning correctly, a power surge may fried some drive electronics.

Since the archive copy is the master copy, it is prudent to back it up. The easiest way is to have a similarly-sized drive. Then you can just do a bit-by-bit copy from the master archive to the backup archive which is faster than filesystem-level copy if the drive is fully filled.

The backup media should not be of the same make and model. Harddrive is manufactured in batches, and the same defect usually is present in every drive in a batch. If you buy two drives of the same make and model at the same time, they may come from the same batch.



Partitioning archive disk


If the archive disk is big if you may want to partition it into smaller pieces. Partitioning can limit the extent of filesystem corruption as long as you operate on (mount) one partition at a time.

How big should a partition be is up to you. For my data, I'd partition a 500GB drive into 2 250GB slices, and a 1.5TB drive to 3 500GB slices.


Encryption


Encyption is optional. But it can be useful in Windows OS.

Windows eagerly mount all partitions on a disk. This defeats the intention of having multiple partitions. However, encyrpting each partition will let you mount only certain partitions. FreeOTFE or Truecrypt is my encryption software choice on Windows.


Operation & maintenance


After archiving to the master disk, I follow up with doing a bit-by-bit copy of the affected partition to backup disk. This shows another benefit of partitioning: if you have a gargantuan drive, you don't have to touch all.

After copying to the master disk, I took both disks offline. I use SATA drives for my archive disks and have 2 SATA docks. The disks are offline (unpowered, plugged off, in safe storage) most of the time. The master is online only when I need to read or write from it. The backup is online whenever I modify master. Whenever the backup is online, there is a brief window of risk where both drives may be destroyed (e.g.: a power surge).

The window can be eliminated. One way is to copy the master partition to online disk, take the master offline, bring the backup online, write the copy of master partition from online disk to the backup disk. This is too cumbersome for me and I have no need for this kind of data guarantee.

Around every New Year, I do badblocks -n on the whole disk for each disk to rejuvenate the 'magnetism'. This takes a lot of time, about 5.5 hours/100GiB when connected through USB2. An alternative, according to this article, is to simply do a read. This can be accomplished with dd if= of=/dev/null [bs=1M].


Update: A quick reading of Predicting Archival Life of Removable Hard Disk Drives (circa 2008) shows:
  • hard drive can easily survive 20 years (*simulated environment),
  • 2.5" form has better survivability rate than 3.5" HD,
  • storing HD at 20C increases its survivability
I honestly are not bothered by these for my personal usage. I'd likely move over the content to some new media when SATA becomes obselete. I am pretty sure that SATA will become obselete within the next 10 years. I'd keep upgrading the media to keep up ahead of obsolescence. It is no fun trying to retrieve something from an obselete interface.

2010-05-26

Setting up Samsung ML-1740 in OpenVZ VE

This is a quick walkthrough for setting up Samsung ML-1740 (or other Samsung laser printers) through USB port in Debian Linux OpenVZ VE . This adds on my previous guide and present a shorter walkthrough than the one in http://wiki.openvz.org/USB_Printing_in_VE

On HN:


Make sure the printer is on and connected to the usb port.

# aptitude install usbutils
# lsusb

Make sure the printer is listed in lsusb's output.
If this is the first USB printer connected to HN, then there should be /dev/usb/lp0.
Make sure /dev/usb/lp0 uid is "root" and gid is "lp" and the permission is at least 660 (u=rw,g=rw).


# vzctl set 555 --devnodes usb/lp0:rw --save


Now enter the VE:

# vzctl enter 555

Make sure there is /dev/usb/lp0 in VE (exported by HN). Make sure the permission is the same as in HN, owner user "root" and group "lp", and permission is at least 660.

# aptitude install cups splix
If you already have CUPS installed, restart it because the printer has to be powered on and plugged in before CUPS is started for it to see the printer.



# ${webbrowser} http://localhost:631

Go to "Administration", "Add printer", Enter name and click "Continue".
Next there's a device selection. Your printer should be listed there. My printer was listed as "Samsung ML-1740 USB #1 (Samsung ML-1740)".
If your printer is not there, the more likely causes are incorrect permission and/or CUPS started before the printer is up.

Select your Samsung model on the next screen and keep pressing "Continue".
You're done.

I'll never use JFS for root FS anymore

I love JFS, but I'm not going to use it for root FS anymore.

One of the computers had JFS for its root FS. The computer crashed. The filesystem became dirty and refused to be mounted rw until it is fsck-ed. Unfortunately, the fsck program for JFS exists only as a userland tool (kernel cannot do it) and Debian's standard initramfs image does not have fsck.jfs. So the root fs was mounted ro and, as a result, several important services, including ssh, failed to start.

It was a good thing that the computer was downstair. I just went downstair and used a rescue CD to fsck.jfs the volume. I had 3 rescue CDs: trinity 3.3, knoppix 6.2 and system rescue disk 1.3.2. Only the last one has fsck.jfs.

From now on, I'll be using JFS only for data volumes.

2009-07-30

iftop, vmstat, iostat, dstat, iotop, lsof, fuser

Some utilities I find helpful:

iftop -- shows current open connections and their transfer rates
vmstat -- shows virtual memory status (found in procps package)
iostat -- shows current IO transfer rate by devices (found in sysstat package)
dstat -- combines vmstat, iostat and iostat-like info for network IO
iotop -- like top, but the focus is on IO transfer rate
lsof -- get info from currently open files
fuser -- does a subset of lsof: identify processes and users using certain files

2009-07-20

Adding an md device to a LVM VG containing the root filesystem

Debian:

When adding an md device to a LVM VG containing the root filesystem, like so:
vgextend vg_with_root /dev/md99

Don't forget to run the following:

/usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
dpkg-reconfigure mdadm

The first one is to update the mdadm.conf, and the second one is to reconfigure the initrd image the new md device will also be assembled prior to activating the VG. Otherwise, activating the VG will fail because it cannot find a required PV (the new md device).

2009-03-17

Keeping track of manually installed packages in Debian

This is how I keep track of manually installed packages in Debian:

Everytime I need to install a package, I create a file with the same name as the package name.

Examples:

$ touch /usr/local/etc/packages/list/qmail
$ echo 2009-03-17 J requested ipsvd for his app > /usr/local/etc/packages/ipsvd

$ make -f /usr/local/etc/packages/Makefile
apt-get install "ipsvd"
touch /usr/local/etc/packages/list/.ipsvd
apt-get install "qmail"
touch /usr/local/etc/packages/list/.qmail

And if you do another make:

$ make -f /usr/local/etc/packages/Makefile
make: Nothing to be done for `install-packages'.


In practice, I use aliases so I don't have type long paths. Here's how to set it up. Just copy-and-paste the code below:


mkdir -p /usr/local/etc/packages/list
cd /usr/local/etc/packages
cat > Makefile <<EOF

packages=/usr/local/etc/packages/list/*

install-packages: \$(packages)

\$(packages): /usr/local/etc/packages/list/%: /usr/local/etc/packages/list/.%

/usr/local/etc/packages/list/.%:
`echo -e \\\t`apt-get install "\$*"
`echo -e \\\t`touch \$@
EOF

2008-08-14

A much easier way to access Samba share on Linux guest on Windows host

There is a much simpler solution to my earlier's one.

Steps:

  1. Create a VirtualBox's HIF and attach it to the VM.
  2. Set its IP address to, say, 192.168.2.1.
  3. Start the guest OS.
  4. From within the guest OS, give a static address to the HIF, say, 192.168.2.2.
  5. From host OS, make sure you can ping 192.168.2.2
  6. From the guest OS, make sure you can ping 192.168.2.1

This establishes a private network between the host and the guest. The guest is perceived as another node in the network hosting a Samba share.

VirtualBox: Accessing Samba share on Linux guest on Windows host

Environment: VirtualBox 1.6.4 (latest as of 2008-08-14) running on Windows XP SP3. Guest is a Debian GNU/Linux.

The goal is to have the host Windows able to mount a Samba share provided by the guest as long as the Samba instance is running. To accomplish that, we are going to create a loopback adapter interface on the host, use VirtualBox's HIF on the guest, and bridge the two interfaces together.

Steps:

  1. Add a Microsoft Loopback Adapter device (through ControlPanel->Add Hardware).
  2. Create a VirtualBox's HIF and attach it to the VM.
  3. Go to Control Panel->Network Connections.
  4. Highlight the loopback device and the HIF, and right-click 'Create Bridge'.
  5. Go to the newly created bridge's property and set its IP address to, say, 192.168.2.1. The guest OS will be able to contact the host OS with this address.
  6. Start the guest OS.
  7. From within the guest OS, give a static address to the HIF, say, 192.168.2.2.
  8. From host OS, make sure you can ping 192.168.2.2
  9. From the guest OS, make sure you can ping 192.168.2.1
At this point, from the host Windows, you should be able to do this:

net use e: \\192.168.2.2\the_share_name "password_for_share" /user:username_for_share /persistent:no


Update 2008-08-14: You don't have to create a bridge. There's a simpler method.

2008-05-02

XP hanging when opening files

XP seems to hang when opening files. It does not actually hang; it is just doing file browsing very slowly because of certain settings. Below are the settings you can change to make file browsing faster.


From http://forums.pcpitstop.com/lofiversion/index.php/t121312.html

Go to Start - Run
type gpedit.msc
hit enter

ENABLE User Configuration select Administrative Templates - Start Menu and Taskbar-"Do not use the search-based method when resolving shell shortcuts"
ENABLE User Configuration select Administrative Templates - Start Menu and Taskbar-"Do not use the tracking-based method when resolving shell shortcuts."
ENABLE User Configuration - Administrative Templates - Windows Components - Windows Explorer-"Do not track Shell shortcuts while roaming"



From http://www.ss64.com/nt/slow_browsing.html

Removing all shortcuts from 'My Network Places' will return the system response to normal.
Prevent XP from placing shortcuts under 'My Network Places' by changing registry HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoRecentDocsNetHood to 1.


More information http://support.microsoft.com/?kbid=841978

2008-04-26

An actual restoration from Drive Snapshot backup

I had to restore a disk encrypted with PGP Whole Disk Encryption from a DriveSnapshot backup. I posted about the general idea, but the following are the steps of a real one:

# /dev/sda is the drive I needed to restore
# /dev/sdb1 contained the backup files and fullcd.iso

mount /dev/shm
mount -o ro /dev/sdb1 /media/sdb1
qemu -hda /dev/sdb -hdb /dev/sda -cdrom /media/sdb1/fdfullcd.iso -boot d
snapshot show hd2
snapshot show file.sna
snapshot restore hd2 mbrall file.sna
snapshot restore hd2 auto file.sna

xfdisk -> install boot manager (overriding pgp bootloader) -> create new menu entry pointing to the partition.

reboot.

2008-03-19

Accessing USB printer under OpenVZ VE

To access USB printer from within OpenVZ Virtual Environment (VE), you need to allow the device to be visible and accessible by doing the following from the Host Environment (HE):
vzctl set 999 --devices usb/lp0:rw

cat /proc/vz/devperms
#Version: 2.7
# 0 b 016 *:*
# 0 c 006 *:*
# 999 c 006 180:0


If there is any trouble with printer access from within VE, verify that there is none from HE .

In my case, CUPS within VE correctly detected my printer at ``usb://Samsung/ML-1740``. Yet it couldn't push any job to the printer. I spent hours trying to get it work to no avail. What I should have done was to verify if CUPS in HE could do it successfully. It couldn't. But CUPS-in-VE in another machine could push the job successfully. The problem, then, probably was with the hardware.

So, I settled with specifying the printer location (DeviceURI) at ``file:/dev/usb/lp0``. It works, except that it can't read printer status because it requires two-way communication which ``file`` protocol does not support.

2008-03-11

qmail in resource-constrained environment

An important thing to note when using virtualised environment
such as OpenVZ is that resources are artificially constrained. This can cause various funny and head-scratching behaviours.

My OpenVZ VE (plan VZ 128) from quantact.com, runs apache2 and qmail (as spooler).
I had to adjust tcpserver connection limit to 3 (tcpserver -c 3), and qmail-send's concurrencyremote to 1 (echo 1 > /var/qmail/control/concurrencyremote).

Each incoming SMTP request triggers an RBL lookup and may trigger a spamassassin check. The default tcpserver's incoming connection limit is 40 and there just isn't enough resources to support 40 spamassassin instances (1 spamd with 40 spamc processes). Instances will fail with various puzzling error messages. The only clear indication that they are failing because of resource constraint is by comparing the content of /proc/user_beancounters before and after failures.

Furthermore, if the remote host, where the real mail server is, is down for a period such that enough mails are queued up, when the remote host is up again, qmail-send will start 20 qmail-remote processes (the default) to send the mails all at the same time. Each process will send email to the real mail server through a stunnel connection. But there just aren't enough resources to support 20 qmail-remote processes along with 20 stunnel connections. Again, the only way to know this for certain is by comparing the content of /proc/user_beancounters before and after failures. Otherwise, all you are getting are error messages like below which could have been caused by various things like network or firewall problem:

2008-03-11T06:53:02.78164 2008.03.11 02:53:02 LOG3[11407:3058117552]: SSL_accept: Peer suddenly disconnected


Once the concurrency level is brought down, force qmail to resend the queue:

qmail-qstat; qmail-tcpok; pkill -ALRM qmail-send; qmail-qstat

OpenSSH: Hashed Known Hosts

Read more at https://itso.iu.edu/Hashing_the_OpenSSH_known__hosts_File.

To hash every user's known_hosts files and delete the known_hosts.old:

for username in `cut -f 1 -d : /etc/passwd`; do echo $username; sudo -u $username ssh-keygen -H; rm `sh -c "echo ~$username/.ssh/known_hosts.old"`; done

2008-03-08

Restoring Drive SnapShot from Linux

I use Drive Snapshot to archive our Windows machines. It is a Windows backup/disk imaging tool that does not require you to interrupt your other work in other applications. It is a good tool and has repaid its cost (US$ 57.56 in 2007 May) many times over.

Compared to other similar tools at the time, it was really the quickest and simplest one. However, its main downside was that it required DOS or Windows for restoring from scratch. DOS is troublesome to setup. There may be special drivers needed to be able to access the harddrive to be restored and also the backup files themselves. Restoring from Windows is slightly better, but only if you have another Windows machine and go through the hassle of hooking up the target drive to that machine.

Here is a method that I find easy enough for in-situ restoration. You need Live-CD Linux, QEMU and FreeDOS ISO image. I use Knoppix 5.11 since it includes QEMU.

  1. Boot Knoppix to GUI mode for QEMU UI.
  2. Make sure FreeDOS ISO image is accessible on a different partition/disk than the Snapshot image files (.SNA).
  3. The SNA and snapshot.exe filesmust be in a FAT32 volume
  4. qemu -cdrom freedos.iso -hda /dev/${fat32-partition-containing-sna-files} -hdb /dev/${target-harddrive} -boot d
  5. Follow the DOS restoration instruction. For example: snapshot.exe restore HD2 MBR image.sna which restores the MBR record from the image.sna (the CWD is assumed to be C:\ which corresponds to the fat32-partition-containing-sna-files device) to HD2 (the QEMU's hdb device which is the target-harddrive).

Hope this helps.


20080904 UPDATE: A step-by-step instruction
http://gnomicnotes.blogspot.com/2008/04/actual-restoration-from-drive-snapshot.html

2008-03-07

ntpd in openvz ve

ntpd needs to change the system time. In OpenVZ, VEs share the host's system time. The VE running ntpd needs to be given the CAP_SYS_TIME capability:
vzctl set 101 --capability sys_time:on --save



2008-02-20

Disabling LKM in Debian GNU/Linux

This instruction is applicable to Etch (4.x).
You may want to do this on your public servers to help keep off LKM trojan.


apt-get install lcap
lcap -c CAP_SYS_MODULE


There are more tips at Taking Advantage of Linux Capabilities.

What is in a machine name?

As I started to play with OpenVZ, it dawned on me that the cost of
machines are cheap. It is very cheap to have a specific (virtual)
machine for a specific purpose.

Already, I had several specific functionalities I wanted to have
implemented: intranet-wide (read: home) file server, intranet-wide
access to scanner, public-facing web server, public-facing mail
server, fresh OS base to test installation procedures on, etc.

Now they can each be implemented in its own machine. There will be
enough machines for me to justify entertaining some
system-administration practices, like impersonal machine naming.

I had always been naming my machines by the name of people I liked,
had crushes with, or dated. I cannot continue with that schema without
jeopardizing my marriage and lying to myself as I cannot start liking
someone just because I need to name a new machine.

A machine naming convention that I've always liked is one that encodes
the purpose and asset ID into the name. For example: WWW001 is a web
server machine, MAIL001 is a mail server machine, and WS001 is a
workstation machine. Some even go further by including physical
location information: DC06MAIL001 could be a mail server in data
center #6 in Washington DC.

My need for my simple system is simple. I choose the simple prefix "M"
which stands for machine. The names will be M01, M02, M03, and so on.
Reaching M99 is a strong indication that the system is no longer
simple and is a justification to use a more sophisticated naming
convention.

The machine name forms the basis for the canonical DNS name. Machines
with a single IP have similarly named DNS entries under the 'machine'
subdomain, e.g.: m01.machine.example.com.

Multi-Homed machines (having multiple IPs) also have similarly-named
DNS entries pointing to each of its interface. The entry names should
be descriptive enough to identify the interface, e.g.:
m01-internet.machine.example.com and m01-lan.machine.example.com if
m01 is an Internet-facing firewall machine.

Each interface may be assigned additional alias DNS name (CNAME
records). For example, if m01.machine.example.com is originally a
machine in LAN and is being upgraded to serve as an Internet-facing
firewall machine, then m01.machine.example.com then cease becoming
the canonical name. It may be dropped or added as an alias.

Publicly-Accessible servers also benefit from having an alias DNS
name, e.g.: www.example.com may be an alias for
m54.machine.example.com.

Publish Post

LKM in my server. Rootkitted.


From: root@example.com (Cron Daemon)
Subject: Cron test -x /usr/sbin/anacron || ( cd / && run-parts
--report /etc/cron.daily )
To: root@example.com
Date: Sun, 27 Jan 2008 09:25:10 -0500

You have 1 process hidden for readdir command
You have 1 process hidden for ps command
chkproc: Warning: Possible LKM Trojan installed

When I received that email from one of my public servers, two
questions popped up: did I just get rootkited again?

I had been rootkitted about three years ago. At that time the only
network-accessible services on the computer was a stock apache 1.3
serving static pages and an unpatched qmail. I didn't have tripwire
setup and ended up reinstalling the system from scratch because I
didn't know which files had been compromised.

This time, I had tripwire (AIDE, actually) setup and was able to
identify the infected files. Yet I still ended up reinstalling the
system from scratch partly because things were too easy for me and
mostly because I just found the excuse I needed.

Firstly, the compromiser didn't take out the regular chkrootkit
report. Secondly, subsequent chkrootkit report didn't report any
warning. Did the chkrootkit itself was compromised? Later verification
with an uncompromised AIDE data file showed that it was not, but
still, you wouldn't know that then. Thirdly, the same question for the
AIDE binary itself. Fourthly, it was really painful trying to do an
off-line verification on a remote system. Fifthly, was it apache 1.3
again?

One thing I discovered was that Linux allows you to disable loadable
kernel module (LKM) which supposedly makes it impervious to LKM
Trojan, like the one I had. No use crying over spilt milk.

The server was a Xen virtual machine hosted by quantact.com. It was
setup two years ago. This break-in gave me an excuse to reorganize my
hosting choices. Around last year, they started offering a cheaper
hosting option on OpenVZ. So I tried it and found that I liked it. I
liked it so much I installed one at home.

OpenVZ does not allow virtual machines to load kernel modules. I hope
that is enough to circumvent the same attack vector.


2006-11-17

DebianAMD64 and Samsung ML1740 (or othere printers)

Today, M. Aurélien Croc, the author of Splix, informed me that a new version of Splix, 0.0.2, is now usable in 64-bit.

Of course I am happy because now I am no longer limited to submitting 4294967296 documents to the spooler; now I can submit 18446744073709551616 documents at a time. I mean why else would you even bother running a spooler in a 64-bit environment? (I kid).

Packages needed:

libcupsys2-dev
libcupsimage2-dev



/tmp/splix-0.0.2 $ make
make[1]: Entering directory `/tmp/splix-0.0.2/src'
g++ -O2 `cups-config --cflags` -I../include -c -o rastertospl2.o rastertospl2.cpp
g++ -O2 `cups-config --cflags` -I../include -c -o raster.o raster.cpp
g++ `cups-config --ldflags` -lcups -lcupsimage -o rastertospl2 spl2.o printer.o band.o compress.o rastertospl2.o raster.o
make[1]: Leaving directory `/tmp/splix-0.0.2/src'
make[1]: Entering directory `/tmp/splix-0.0.2/ppd'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/tmp/splix-0.0.2/ppd'


/tmp/splix-0.0.2 $ sudo make install
make[1]: Entering directory `/tmp/splix-0.0.2/src'
install -m 755 -s rastertospl2 `cups-config --serverbin`/filter
make[1]: Leaving directory `/tmp/splix-0.0.2/src'
make[1]: Entering directory `/tmp/splix-0.0.2/ppd'
install -d -m 755 `cups-config --datadir`/model/samsung
for filename in ml1510 ml1520 ml1610 ml1710 ml1740 ml1750 ml2010 ml2150 ml2250 ml2550; do \
install -m 644 $filename.ppd `cups-config --datadir`/model/samsung;\
for lang in fr it de; do \
install -m 644 $filename$lang.ppd `cups-config --datadir`/model/samsung;\
done; \
done \

make[1]: Leaving directory `/tmp/splix-0.0.2/ppd'

--- Everything is done! Have fun ---





The files installed are:


/usr/lib/cups/filter/rastertospl2
/usr/share/cups/model/samsung/*.ppd (among them is ml1740.ppd)


We can add the printer from cups's web interface (typically found at http://localhost:631). When prompted for printer model, just provide the ppd (in my case it is /usr/share/cups/model/samsung/ml1740.ppd).


(originally from http://microjet.ath.cx/WebWiki/2006.11.17_DebianAMD64_and_SamsungML1740_Part2.html)

2005-08-23

pvmove problem

I am using LVM2 with linux 2.6.11. One of the drive in the volume is going bad. I could hear screeching noise while the platters were spinning.

That is bad. Not a problem, though, as I can just vacate the data from that drive using pvmove.
 The bad drive is /dev/bad. /dev/avail is a volume with some free space.
 
# pvdisplay /dev/bad /dev/avail
  --- Physical volume ---
  PV Name               /dev/bad
VG Name               vg0
  PV Size               148.09 GB / not usable 0
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              37911
  Free PE               25111
  Allocated PE          12800
  PV UUID               e5EvaO-0oo5-Zenl-KzkY-wFf7-EkQX-di1mXt

  --- Physical volume ---
  PV Name               /dev/avail
VG Name               vg0
  PV Size               186.30 GB / not usable 0
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              47694
  Free PE               20658
  Allocated PE          27036
  PV UUID               HLtCMK-751U-IFAW-5Aj3-FQ3w-5tqO-8svvwt


Let's move it to the only drive with available space, /dev/avail. /dev/bad has 12800 allocated PE while /dev/avail has 20658 free PE. I was not expecting any problem fitting the data in /dev/bad into /dev/avail.
 
# pvmove -i 5 -v /dev/bad
Finding volume group "vg0"
    Archiving volume group "vg0" metadata.
    Creating logical volume pvmove0
    Moving 0 extents of logical volume vg0/lv0
Insufficient contiguous allocatable extents (1777) for logical
    volume pvmove0: 12800 required
  Unable to allocate temporary LV for pvmove.

Urk? It needs to be contiguous? What to do now?

Searching through the lvm mailing list shows that pvmove is dumb. It only sees the first free PE (physical extent). OK, let's work around this.
 
# vgcfgbackup

# grep pv0 /etc/lvm/backup/vg0
                pv0 {
                                        "pv0", 30720
                                        "pv0", 0
                                        "pv0", 17920

pv0 is the physical volume corresponding to /dev/bad. From this, we see that there are three segments residing in pv0. The first starts at PE 30720.

Let's try to fill that 1777 free PE on the dest drive, /dev/avail. That means, we'll be moving PE 30720 to (30720+1777-1=32496) from pv0.


# pvmove -i 5 -v /dev/bad:30720-32496
    Finding volume group "vg0"
    Archiving volume group "vg0" metadata.
    Creating logical volume pvmove0
    Moving 0 extents of logical volume vg0/lv0
Moving 1777 extents of logical volume vg0/lv1
    Moving 0 extents of logical volume vg0/lv2
Moving 0 extents of logical volume vg0/lv3
    Found volume group "vg0"
    Updating volume group metadata
    Creating volume group backup "/etc/lvm/backup/vg0"
    Found volume group "vg0"
    Found volume group "vg0"
    Loading vg0-pvmove0
    Found volume group "vg0"
    Loading vg0-lv1
Checking progress every 5 seconds
  /dev/hdf2: Moved: 7.7%
  /dev/hdf2: Moved: 14.4%
  /dev/hdf2: Moved: 22.6%
  /dev/hdf2: Moved: 29.7%
  /dev/hdf2: Moved: 37.4%
  /dev/hdf2: Moved: 44.6%
  /dev/hdf2: Moved: 52.3%
  /dev/hdf2: Moved: 60.0%
  /dev/hdf2: Moved: 67.7%
  /dev/hdf2: Moved: 75.4%
  /dev/hdf2: Moved: 83.1%
  /dev/hdf2: Moved: 90.3%
  /dev/hdf2: Moved: 97.4%
  /dev/hdf2: Moved: 100.0%
    Found volume group "vg0"
    Found volume group "vg0"
    Found volume group "vg0"
    Loading vg0-pvmove0
    Found volume group "vg0"
    Loading vg0-lv1
    Found volume group "vg0"
    Found volume group "vg0"
    Removing temporary pvmove LV
    Writing out final volume group after pvmove
    Creating volume group backup "/etc/lvm/backup/vg0"

Finally, after repeating the above process for the remaining segments, /dev/bad, aka pv0, is free of data and is safe to take down.

# vgreduce vg0 /dev/bad
 
Toss it in the garbage bin.


(originally from http://microjet.ath.cx/WebWiki/pvmove%20problem.html)