Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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?
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
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.
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???
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
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.
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?!
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.
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
Original Poster
Rep:
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.