Skip to topic | Skip to bottom
Search:
Home

Chris and Janet's website

Home


Start of topic | Skip to actions
Linux tcp tuning: http://www-didc.lbl.gov/TCP-tuning/linux.html


Generate random numbers on linux:

dd if=/dev/urandom bs=1 count=128 | od -x


Solaris: psrinfo -v lists the processors on a box


Re-format external USB hard drive (Debian)

Motive: I wanted a backup solution that preserved file permissions when using rsync with the -a option.

My backup drive, a Western Digital usb hard drive, had a vfat file system - which I found didn't preserve file permissions.

The following describes how to convert from vfat to an ext3 file system. Remember, if you follow these instructions all your existing data will be erased. Be sure, be very sure you want to re-format your existing drive.

Here goes...

When you plug the drive in check dmesg to find out which /dev device it's been mapped to. I found mine under /dev/sda1.

Then you'll need to partition the disk:

fdisk /dev/sda1

This will give you a command prompt interface. Type p to get a list of the current partitions.

I had 4 partitions, so I deleted them all using the d command.

Then create your partition(s). I created one great big extended partition using the n command. It asks you a few questions about block sizes etc, I chose the defaults.

Then I typed w to write the partition data to the disk. Then I quit fdisk.

Then I created the filesystem:

mkfs.ext3 /dev/sda1

It asked me a few questions, I excepted all the defaults.

Then you're ready to mount the device:

mount /dev/sda1 /mnt/usbdrive

You'll have to create the folder /mnt/usbdrive yourself.

So that the disk gets mounted on reboot add the following line to /etc/fstab:

/dev/sda1 /mnt/usbdrive ext3 defaults 0 0

This also means you can simply type:

mount /dev/sda1

when mounting the disk from the command line.

This link was useful.


Recovering a screwed NTFS disk

I created an image file from the corrupt disk using dd -> dd if=/dev/hdd of=imagename.img conv=noerror

I wanted to use an image file so that I could mess around without harming the data on the original corrupt disk.

I used testdisk to restore the image file's partition information (follow interactive menu system).

I was then able to mount the disk:

mount -t ntfs imagename.img /mnt/restoredntfs -o loop,offset=32256

Becasue I was mounting from an image file, I had to mount to a loop device. Thanks NASA, apparently.

According to testdisk my partition was situated at the 63rd cylinder -> 63 * 512 (assuming 512 bytes per block) = 32256 bytes.
to top


You are here: Home > WebLeftBar > TechStuff > UnixStuff

to top