LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-04-2007, 01:30 PM   #1
onedingo
Member
 
Registered: Jan 2006
Location: Pittsburgh, PA, US
Distribution: Arch
Posts: 69

Rep: Reputation: 20
Need to trim some bytes off the end of a file


So I am trying to install Slackware 12.0 and it's locking up hard at the keyboard selection during boot. I am going to assume a bad burn to dvd.

Here is the run down:

1. Downloaded the iso via torrent.
2. Checked the .iso against the .md5 (not that it's needed using torrents)
3. # growisofs -dvd-compat -speed=4 -Z /dev/dvd=slackware-12.0-install-dvd.iso
4. {several failed install attempts}
5. dd if=/dev/dvd of=rip.iso bs=1M

This results in rip.iso being slightly larger than slackware-12.0-install-dvd.iso, most likely due to the use of -dvd-compat during growisofs.

So I need something to trim rip.iso to the same size as slackware-12.0-install-dvd.iso and then check the md5sum to determine a good burn.

I am currently trying to dd rip.iso to another file using bs=1 and count={exact size of slackware-12.0-install-dvd.iso} but it is painfully slow.

Is there something to trim the end of a file?
 
Old 07-04-2007, 03:09 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I think that dvds use block sizes of either 1024 or 2048. The problem was probably caused but using 1M as the block size.

Use split to break up the file into parts. Use the length of the slackware-12.0-install-dvd.iso as the slice size. Then delete the excess.

There is a truncate function in C but I don't know how you would access it unless you created a program to do it. Maybe a perl library function exists.

Last edited by jschiwal; 07-04-2007 at 03:11 PM.
 
Old 07-04-2007, 03:30 PM   #3
onedingo
Member
 
Registered: Jan 2006
Location: Pittsburgh, PA, US
Distribution: Arch
Posts: 69

Original Poster
Rep: Reputation: 20
Split!
I knew there was something to do it.
man -k trim & google linux+trim+file were useless.

I thought dd would just give up on the last read block (writing the part it had) if it couldn't fill the whole blocksize. I guess there is only one way to find out though.

Thanks.
 
Old 07-04-2007, 05:02 PM   #4
onedingo
Member
 
Registered: Jan 2006
Location: Pittsburgh, PA, US
Distribution: Arch
Posts: 69

Original Poster
Rep: Reputation: 20
OK. The dvd image verified so I'm off to see what went wrong during the install.

For the record, using a bs=2048 or bs=1M made no difference in the rip.iso size as without count=xxx it means nothing. Except that 1M rips faster.
 
Old 07-04-2007, 05:59 PM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
After burning the DVD, you could have used the md5sum program on the device (as root) instead of copying the disk to a file. Alternately you could use dd to copy from the device and pipe the output into "md5sum --"
 
Old 07-04-2007, 06:13 PM   #6
onedingo
Member
 
Registered: Jan 2006
Location: Pittsburgh, PA, US
Distribution: Arch
Posts: 69

Original Poster
Rep: Reputation: 20
Nope.

It always fails and I believe it's the -dvd-compat option causing it. Probably does something similar to cdrecord -pad. Larger file should never have the same md5.

I guess the obvious answer is to not use the -dvd-compat flag then md5sum /dev/dvd would actually work.

BTW, here is the results of the dd rip from earlier:

Code:
root@amd1200:~# dd if=/dev/dvd of=a bs=1M
3714+1 records in
3714+1 records out
3894542336 bytes (3.9 GB) copied, 512.879 seconds, 7.6 MB/s
root@amd1200:~# dd if=/dev/dvd of=b bs=2048
1901632+0 records in
1901632+0 records out
3894542336 bytes (3.9 GB) copied, 513.959 seconds, 7.6 MB/s

Last edited by onedingo; 07-13-2007 at 08:35 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
trim lines based on other file. hepburnenthorpe Linux - Newbie 1 04-02-2007 10:07 PM
"Extra bytes at the end of class file" when installing WTK2.2 eikeland Linux - Software 1 03-06-2007 08:59 PM
How to add some bytes to a binary file? kornerr Linux - General 6 02-28-2006 11:23 AM
How To Trim A File fpfernando Programming 11 01-05-2006 08:04 AM
vim: mark end-of-line? trim blank lines? prell Linux - Software 3 09-20-2004 11:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration