LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-26-2006, 04:29 AM   #181
Copy
LQ Newbie
 
Registered: Jun 2006
Posts: 9

Rep: Reputation: 0

Quote:
Originally Posted by AwesomeMachine
Dd actually does copy all the zeroes even without conv=notrunc.

Oh... Oh well. Thanks a million for all your time, effort, and consideration, Awesome. I appreciate it.

Cbeers!
 
Old 07-27-2006, 04:09 AM   #182
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,591

Original Poster
Rep: Reputation: 162Reputation: 162
Smile Thanks

Quote:
Originally Posted by bangoram
Its really a very good contribution!! I found it very usefull, any just now I have started working on this, I will be back whenever I have queries..
Thank you for saying so, Bangoram!! :-)
 
Old 08-17-2006, 08:49 AM   #183
swdamle
LQ Newbie
 
Registered: Dec 2004
Location: pune,India
Posts: 4

Rep: Reputation: 0
Hello Sir,

This has reference to the web page: "Learn The DD Command Revised"


> "Make an iso image of a CD"

Done every thing as under,

-------------------------------------------------------------------------------------------------------------------------------------------
knoppix@localhost:~$ su
Password:
root@localhost:/home/knoppix# dd if=/dev/cdrom of=mycd.iso bs=2048 conv=notrunc
358254+0 records in
358254+0 records out
733704192 bytes transferred in 354.825077 seconds (2067791 bytes/sec)
root@localhost:/home/knoppix#

mycd.iso has permissions-rw-r--r--)to chage the permissions:
root@localhost:/home/knoppix# chmod a+rwx mycd.iso
root@localhost:/home/knoppix#
Now mycd.iso has permissions-rwxrwxrwx)

to mount the image,
root@localhost:/home/knoppix#mkdir /mnt/mycd
root@localhost:/home/knoppix#

root@localhost:/home/knoppix#kedit /etc/fstab
added the line /home/knoppix/mycd.iso /mnt/mycd iso9660 rw, user, noauto 0 0 and saved it.

root@localhost:/home/knoppix# mount -o loop /mnt/mycd
root@localhost:/home/knoppix#

The file system IS available as files & directories.
---------------------------------------------------------------------------------------------------------------------------------------------

however sorry to inform you that,

can NOT edit "mycd.iso" as it gets mounted with "-r-xr-xr-x" permissions!

Prof S W Damle

Email : swdamle@sancharnet.in
 
Old 08-17-2006, 05:01 PM   #184
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,591

Original Poster
Rep: Reputation: 162Reputation: 162
You are correct. I don't believe the post states the image can be edited this way.

Last edited by AwesomeMachine; 08-17-2006 at 05:05 PM.
 
Old 08-17-2006, 11:28 PM   #185
bruse
Member
 
Registered: Feb 2005
Location: internet
Distribution: Debian
Posts: 821

Rep: Reputation: 30
The images are not writable back when doing the things with mount point right.I believe it.But is there any other method that do the same Awesomemachine?

In practice,mounting the image somewhere,then edit the mount point likely to change the *image* also.is that possible?
 
Old 08-19-2006, 12:02 AM   #186
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,591

Original Poster
Rep: Reputation: 162Reputation: 162
Smile Hacking cd image files

Quote:
Originally Posted by bruse
The images are not writable back when doing the things with mount point right.I believe it.But is there any other method that do the same Awesomemachine?

In practice,mounting the image somewhere,then edit the mount point likely to change the *image* also.is that possible?
There are ways to hack iso9660 images, and make modified CD's; for a distribution CD, or live CD; for instance. This type of hacking covers a broad range of possibilities and methods, but there are few common points in all. The contents of the CD image file must be copied from the loop device to an actual working file system. Changes must be made in ext3, reiserfs, etc.. Mkisofs is a powerful tool for creating CD image files, which can later be burned to a CD, out of a directory on a hard drive. One possible reason for editing an iso image file is to customize a linux distribution for certain hardware it won't currently install on. This involves changing /boot/initrd on the CD. There are other reasons, such as making a live CD, or customizing Knoppix. These subjects, and more, are covered in http://www.google.com . If you have a web browser, which you must if you are reading this, the answers you seek can be found on google. Maybe I'll make a post on hacking CD image files in the future. The dd tutorial is quite steady work, but if I see enough requests for CD image file information I'll eventually put something together and make a new thread.
 
Old 08-20-2006, 11:58 AM   #187
cruiserparts
Member
 
Registered: Jun 2005
Posts: 31

Rep: Reputation: 15
Quote:
Originally Posted by AwesomeMachine
You are quite welcome



Leave notrunc out of the command. If it still won't work, fill the free space with zeros

dd if=/dev/zero > /home/sam/bigfile.file

When dd says no more room left on device

rm /home/sam/bigfile.file

then dd without notrunc Notrunc writes all the free space. Leaving out notrunc compresses zeroed sectors.
Hi,

I am back on this after a break (got busy with other stuff. I still got the no more room on device error when I left out notrunc.


Before I go further, I want to clarify. Am I filling the free space with zeros on the hda drive (which is the drive that is currently running the machine) or the sda drive (the, new smaller drive)? Before or after I do the dd if=/dev/hda of=/dev/sdd.....?

>>dd if=/dev/zero > /home/sam/bigfile.file<<<

on this command, I am confused, how does it know which drive to do the /zero? meaning is if=/dev/zero shorthand for something like if=/dev/hda/zero or if=/dev/sdd/zero???

Thanks.
jon
 
Old 08-20-2006, 07:36 PM   #188
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,591

Original Poster
Rep: Reputation: 162Reputation: 162
Read back a few posts for the real story on notrunc. The device /dev/zero is the zero device. Whenever the system needs zeroes it gets them from the zero device, /dev/zero. There is also a random device, /dev/random, and a null device, /dev/null. Computers of all types use zeroes, nulls, and random data; and one of the things an operating system needs to do as part of its routine is provide these. Linux provides them with device files, making them manually accessible.
 
Old 08-21-2006, 03:53 AM   #189
kniwor
Member
 
Registered: Aug 2005
Distribution: Slackware 12
Posts: 106

Rep: Reputation: 15
wonderful post mate, although i might never us the command to it's full extent, it is a really useful thing.
 
Old 08-22-2006, 10:06 PM   #190
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,591

Original Poster
Rep: Reputation: 162Reputation: 162
Glad you ran into it, kniwor
 
Old 08-30-2006, 12:00 PM   #191
NapalmD
LQ Newbie
 
Registered: Apr 2006
Location: Portugal
Distribution: lots
Posts: 21

Rep: Reputation: 15
Hi.
Excelent post here.

I have copied a debian system runing in a vmware to a physical system using dd.
don't remember the command i typed... but it runed succesefully...
the VM disk was 16GB, the real one 40GB

it is now like this:
Code:
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda1             15946992   6155508   8981408  41% /
tmpfs                   258272         0    258272   0% /dev/shm
i only did dd on the hda1 not whole hda, cause i had already made the partitions...
if i run fdisk:

Code:
Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        4673    37535841   83  Linux
/dev/hda2            4674        4865     1542240    5  Extended
/dev/hda5            4674        4865     1542208+  82  Linux swap / Solaris
so partition table is correct, why df shows only 16gb?!

thanks
 
Old 08-30-2006, 02:49 PM   #192
kniwor
Member
 
Registered: Aug 2005
Distribution: Slackware 12
Posts: 106

Rep: Reputation: 15
actually i will very much also like to know what has caused this, it will help me understand things a lot, and can someone point me to a tutorial telling what sectors of HDD is partitioning table/boot file etc...etc...etc.. in modern HDD's or how to query all this for a HDD, i read some tutorials but they seemed a bit old, for conventional old small sized (7.8G) HDD's. thanks in advance.
 
Old 09-02-2006, 12:53 PM   #193
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,591

Original Poster
Rep: Reputation: 162Reputation: 162
The way fdisk and df work is slightly different. Fdisk is a lower level utility, and more accurate. What I would do is this, in /etc, as root:

dd if=/dev/zero > /etc/bigfile.file

and fill the all free space with a big file. Dd will tell you when there is no space left on /dev/hd1. Then run df and fdisk, also run:

rm /etc/bigfile.file

to remove the big file. This method also works to overwrite all the free space on a partition, to avoid recovery of deleted files.
 
Old 09-02-2006, 01:22 PM   #194
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,591

Original Poster
Rep: Reputation: 162Reputation: 162
Smile HDD tools

Quote:
Originally Posted by kniwor
actually i will very much also like to know what has caused this, it will help me understand things a lot, and can someone point me to a tutorial telling what sectors of HDD is partitioning table/boot file etc...etc...etc.. in modern HDD's or how to query all this for a HDD, i read some tutorials but they seemed a bit old, for conventional old small sized (7.8G) HDD's. thanks in advance.
Although this is shortly to change, the partition table is in sector 1 on a HDD. The boot sector is sector 64, and data begins after the boot sector. There is metadata, which explains things about files, such as permissions, which is all grouped together in modern file systems. To get information about a HDD hardware you use:

hdparm

If you want to read the different parts of the disk you do something like:

dd if=/dev/sda count=1 | hexdump -C

Will show you sector 1, MBR, on the terminal screen. If you want to see the boot sector:

dd if=/dev/sda skip=63 | hexdump -C | less

will bring you to the beginning of the boot sector. You can use the space bar to scroll down. But, it isn't very interesting to most people to just look at. If you want to find valuable parts of the drive you can search for the magic signature, "55 AA" like this:

dd if=/dev/sda | hexdump -C | grep '55 AA'

The resulting output will give you a byte offset where each instance of "55 AA" is located. You then need to convert this offset to decimal from hexidecimal, divide it by 512, and use this number, minus 1, without fractional parts, as your skip= parameter.

Say you found "55 AA" at 4fb18000h. That's 5,632,000,000d, with any of the many calculators that come with linux. h and d stand for hexidecimal and decimal. So, divide 5,632,000,000 by 512 = 11,000,000. So:

dd if=/dev/sda skip=10999999 | hexdump -C | less

should take you to the sector where "55 AA" is located. You might find some interesting stuff, like the phantom MBR MS Windows puts at the end of the HDD, which never gets overwritten. You can find every partition and MBR by looking for "55 AA". Please note: 55 AA is hexidecimal. When passing hexidecimal to grep there must be a space between each byte: 55<space>AA, like that, but don't actually type it out or use less than and greater than signs. Use an actual space.
 
Old 09-04-2006, 03:19 AM   #195
NapalmD
LQ Newbie
 
Registered: Apr 2006
Location: Portugal
Distribution: lots
Posts: 21

Rep: Reputation: 15
Quote:
Originally Posted by AwesomeMachine
The way fdisk and df work is slightly different. Fdisk is a lower level utility, and more accurate. What I would do is this, in /etc, as root:

dd if=/dev/zero > /etc/bigfile.file

and fill the all free space with a big file. Dd will tell you when there is no space left on /dev/hd1. Then run df and fdisk, also run:

rm /etc/bigfile.file

to remove the big file. This method also works to overwrite all the free space on a partition, to avoid recovery of deleted files.
thanks for that tip...
i've made that but things remain the same

Code:
Backups:/etc# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1              16G   16G     0 100% /
tmpfs                 253M     0  253M   0% /dev/shm
Backups:/etc# fdisk -l

Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        4673    37535841   83  Linux
/dev/hda2            4674        4865     1542240    5  Extended
/dev/hda5            4674        4865     1542208+  82  Linux swap / Solaris
it seems that in the partition table it is marked as 37GB cause I partition that before dd, then i only made dd to the hda1, did you understand?

but didn't these 37535841 mean 37GB?

thanks for answering
 
  


Reply

Tags
backup, best, clonezilla, cloning, command, data, dd, disk, drive, duplicate, erase, explanation, formatting, ghost, hard, image, iso, memory, ping, popular, recover, recovery, rescue, search, security, stick, upgrade, usb, wipe


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
Learn The DD command AwesomeMachine Linux - Newbie 17 08-17-2006 04:22 AM
The best way to learn? iz3r Programming 7 02-06-2005 11:00 PM
Best way to learn Linux from the command line patpawlowski Linux - General 2 03-01-2004 03:37 PM
I want to learn C. KptnKrill Programming 14 12-18-2003 01:03 PM
Best way to learn.... InEeDhElPlInUx Linux - Newbie 5 10-11-2003 01:02 AM


All times are GMT -5. The time now is 05:25 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration