Filed under General Life, Linux by Chris Ganderton
Another nifty thing I figured out a while ago, whilst having to upload a script written by one of the guys we support, in a windows editor, was how to check quickley and easily with cat(1)whether it had silly windows CR/LF’s :
cat -ev /path/to/file
Would output something like the following if the file had silly line endings…
This is some text written in windaz^M$
And another line edited in windaz, woo^M$
cat suffixes the end of line with a $ and shows any special characters that have been inserted, in our case here ^M is the windows special character for new line, so all you need to do is remove that, which is again pretty easy:
sed -i.bak -sed -e "s/r//g" /path/to/file
Should remove the windaz file endings from the file, copying the file with a .bak suffi as a backup.
Tags:
geek,
Linux,
unix
geek,
Linux,
unix
April 3, 2007 at 9:56 pm Comments (0)
Filed under Linux by Chris Ganderton
So today I had to basically clone a hard disk from a failing disk, to a new disk Sun had sent for one of the v20z’s at work… Haven’t not had to mess about with partition tables and other such things outside of the installer in linux for some time (last time I did this kind of messing about was with freebsd which uses slices->partitions, unlike linux and it’s mad idea of partitions and extended partitions), so I had to take stock for a short while while I figured out the best way to go ahead. Here’s what I started with :
/dev/sda – main scsi hard disk at scsi id 0
/dev/sdb – new replacement disk at scsi id 1
Saving and restorring the partition table to the sdb was as easy as:
sfdisk -d /dev/sda > /tmp/sda-parttable.out
and then:
cat /tmp/sda-parttable.out | sdisk /dev/sdb
I’d never realised sfdisk could do easy things like that, which saved me some time having to input partition boundries by hand
What next was a bit of a pain was getting files over to the new filesystems (obviously once I had created new filesystems on them and mounted them somewhere easy to use – /mnt/newroot). I had looked at possibly using cpio to do this, and considered dd.
It seemed the best in the end, to create tar archives of the data, so that if I made a mess of the new disk I could at least quickly extract the backups again without too much faff, to do this I simply archived up each partition using something along the lines of:
tar --preserve --one-file-system -vcf /mnt/newroot/root.tar /
this archived the root into /mnt/newroot/root.tar, but diddn’t traverse into new directories, –one-file-system is a pretty handy feature of tar and I’m sure it’ll come in useful again sometime in the future. Tomorrow I’ll update with how easy it was to install the new mbr to sdb and how removing the origional disk and moving sdb to sda’s slot, goes
Tags:
geek,
Linux,
unix
geek,
Linux,
unix
April 3, 2007 at 9:41 pm Comments (0)
Filed under General Life by Chris Ganderton
I’m 24, based in Manchester and work as a UNIX sysadmin.
I listen to all kinds of music and am generally interested in art. I paticularly like rock music and go to as many gigs as I can get to.
I like photography, I’m not that good; but still try, my attempts are up at deviantart (see the links to the right).
This blog is mainly to help me remember random things I’ve done; but if it helps other folks then that’s alright
Tags:
gigs,
Music,
Photography,
unix
gigs,
Music,
Photography,
unix
April 23, 2006 at 7:21 pm Comments (2)