shanenin Posted December 19, 2005 Report Share Posted December 19, 2005 I had a corrupted partition table on my portable usb dirve. I decided I would try and zero it out using this commanddd if=/dev/zero of=/dev/sda bs=512 count=1I happen to have it plugged into my linux standalone freevo box, this contained about 150 gbs of media. I was controling the computer remotely from my main workstation. Here is where things went wrong. I used this commanddd if=/dev/zero of=/dev/hda bs=512 count=1just one letter different, I managed to corrupt my main harddrive instead of the portable drive. All is not lost, I have a second standalne box connected to our bedroom tv that I mirror all of my media to. I recently also made a tarball(compressed backup) of my system. I felt good to be able to recover from my dumb mistake pretty painlessly Quote Link to post Share on other sites
hitest Posted December 19, 2005 Report Share Posted December 19, 2005 I had a corrupted partition table on my portable usb dirve. I decided I would try and zero it out using this commanddd if=/dev/zero of=/dev/sda bs=512 count=1I happen to have it plugged into my linux standalone freevo box, this contained about 150 gbs of media. I was controling the computer remotely from my main workstation. Here is where things went wrong. I used this commanddd if=/dev/zero of=/dev/hda bs=512 count=1just one letter different, I managed to corrupt my main harddrive instead of the portable drive. All is not lost, I have a second standalne box connected to our bedroom tv that I mirror all of my media to. I recently also made a tarball(compressed backup) of my system. I felt good to be able to recover from my dumb mistake pretty painlesslyCool that you were able to recover so easily, shanenin. I'm teaching my self about virtual hosts in Apache. I've currently got my Apache server hosting my website: http://www.hitest.org/A buddy of mine said that he's able to host over 40 domains on his Apache server. I'm thinking about modifying my vhosts.conf file. I don't have another domain yet, but, it might be fun to investigate the possibility:-) Quote Link to post Share on other sites
shanenin Posted December 19, 2005 Author Report Share Posted December 19, 2005 I'm teaching my self about virtual hosts in Apache. I've currently got my Apache server hosting my website: http://www.hitest.org/A buddy of mine said that he's able to host over 40 domains on his Apache server. I'm thinking about modifying my vhosts.conf file. I don't have another domain yet, but, it might be fun to investigate the possibility:-)That is the area I would like to learn some more. I will have my domain, brighteyedcomputer.com listed in the yellow pages, so I will need to have a simple webpage up by Febraury(when it is published). I have not yet decided on making my own webserver, or paying a few dollars a month to have it hosted. I think I would really enjoy setting up my own webserver, a project is the best way to learn. Two negatives of using my cable service to serve the sight. the first would be, I am not sure if port 80 is blocked. The second reason is security. If I am running a web server, I think my home network might be exposed to to much risk. Quote Link to post Share on other sites
hitest Posted December 19, 2005 Report Share Posted December 19, 2005 I'm teaching my self about virtual hosts in Apache. I've currently got my Apache server hosting my website: http://www.hitest.org/A buddy of mine said that he's able to host over 40 domains on his Apache server. I'm thinking about modifying my vhosts.conf file. I don't have another domain yet, but, it might be fun to investigate the possibility:-)That is the area I would like to learn some more. I will have my domain, brighteyedcomputer.com listed in the yellow pages, so I will need to have a simple webpage up by Febraury(when it is published). I have not yet decided on making my own webserver, or paying a few dollars a month to have it hosted. I think I would really enjoy setting up my own webserver, a project is the best way to learn. Two negatives of using my cable service to serve the sight. the first would be, I am not sure if port 80 is blocked. The second reason is security. If I am running a web server, I think my home network might be exposed to to much risk.Yes, three years ago I ran a web server with little or no security and paid the price:-) Today I'm running a Plll 667 MHz IBM computer with 256 MB RAM and it does the job nicely. I have my web server in front of my hardware firewall so my home network isn't exposed. My server is running on one of my static IP addresses. I've got shorewall running (firewall) and have only punched a hole in the firewall to let requests in to my server. I don't have ssh enabled or ftp or sendmail, just a server. I hardly ever run the unit as root. Also, I haven't configured printing services which is a point of attack for hackers. So far so good. I rented the domain hitest.org at Yahoo for $2.99/ year. Yeah, you would need to find out from your ISP if they will let you run a home server, they might block port 80. Quote Link to post Share on other sites
naraku9333 Posted December 19, 2005 Report Share Posted December 19, 2005 doesn't dd if=/dev/zero of=/dev/hda bs=512 count=1 just zero out the mbr? Quote Link to post Share on other sites
shanenin Posted December 19, 2005 Author Report Share Posted December 19, 2005 doesn't dd if=/dev/zero of=/dev/hda bs=512 count=1 just zero out the mbr?I am pretty sure it does the whole drive, including the mbr. I made a gentoo cd with a tarball and this script to automate installing freevo as standalone divx players#!/bin/bashecho "this script will erase and partition your full drive"echo "enter 'yes' and return to continue"read answerif [ ${answer} != "yes" ]; then exit; fiecho "the script will now partition your drive"sleep 3dd if=/dev/zero of=/dev/hda bs=512 count=1 &&parted -s /dev/hda mklabel msdos &&parted -s /dev/hda mkpart primary ext2 0.0 200.0 &&parted -s /dev/hda mkpart primary linux-swap 200.0 400.0 &&parted -s /dev/hda mkpart primary ext2 400.0 3400.0 &&parted -s -- /dev/hda mkpart primary ext2 3400.0 -0 &&echoecho "the script is finished partitioning, now creating file sysstems"killall udevd &&udevstart &&sleep 3mke2fs /dev/hda1 &&mke2fs -j -m 2 /dev/hda3 &&mke2fs -j -m 1 /dev/hda4 &&echoecho "the script is now mounting all filesystems" &&sleep 3mkswap /dev/hda2 &&swapon /dev/hda2 &&mount -t ext3 /dev/hda3 /mnt/gentoo &&mkdir /mnt/gentoo/boot &&mount /dev/hda1 /mnt/gentoo/boot &&echoecho "the script is now untarring the system"sleep 3tar -xvjpf /mnt/cdrom/extras/freevo-3j.tar.bz2 -C /mnt/gentoo &&mount -t proc proc /mnt/gentoo/proc &&cp -L /etc/resolv.conf /mnt/gentoo/etc/resolv.conf &&echo "`lsmod`" > /mnt/gentoo/tmp/lsmodchroot /mnt/gentoo /root/install-grub Quote Link to post Share on other sites
jcl Posted December 19, 2005 Report Share Posted December 19, 2005 doesn't dd if=/dev/zero of=/dev/hda bs=512 count=1 just zero out the mbr?Yup. Quote Link to post Share on other sites
shanenin Posted December 20, 2005 Author Report Share Posted December 20, 2005 (edited) doesn't dd if=/dev/zero of=/dev/hda bs=512 count=1 just zero out the mbr?Yup.I am pretty sure it will knock out all of the partitions, at least it has in practice. In the script I used above, I use that to wipe the whole drive clean, then parted is able to set up new partitions. If it was only clearing away the mbr parted would not work.edit added later//count=1 does that mean it will do one block? what you guys are saying, seems correct, but... In practice, I always rember this command wiping the whole drive. Edited December 20, 2005 by shanenin Quote Link to post Share on other sites
jcl Posted December 20, 2005 Report Share Posted December 20, 2005 I am pretty sure it will knock out all of the partitions, at least it has in practice. In the script I used above, I use that to wipe the whole drive clean, then parted is able to set up new partitions. If it was only clearing away the mbr parted would not work.The MBR contains the partition table.count=1 does that mean it will do one block?Yup. Quote Link to post Share on other sites
shanenin Posted December 20, 2005 Author Report Share Posted December 20, 2005 (edited) The MBR contains the partition table.does that mean by just zeroing the mbr, I am clearing out all of my partitions? Edited December 20, 2005 by shanenin Quote Link to post Share on other sites
jcl Posted December 20, 2005 Report Share Posted December 20, 2005 (edited) does that mean by just zeroing the mbr, I am clearing out all of my partitions?Altering the partition table doesn't affect the partitions. The MBR partition table only contains the information required to identify the partitions: the starting and ending sectors and blocks, the sizes of the partitions, the partition types, and flags that indicate whether the partition is active. Everything else is stored in tables within each partition. As you said, in practice blowing away the partition table will blow away the partitions, but if you restore the table everything will be as you left it. Edited December 20, 2005 by jcl Quote Link to post Share on other sites
shanenin Posted December 20, 2005 Author Report Share Posted December 20, 2005 (edited) if I wanted to try and fix my mbr(partition table), would that have been a pretty involved process? If I did not have a backup, I may have tried to do that.edit added later//I have not been able to find this with a quick google. is the mbr exactly 512 bytes? bs=512 count=1is that the exact size of my mbr? Edited December 20, 2005 by shanenin Quote Link to post Share on other sites
jcl Posted December 20, 2005 Report Share Posted December 20, 2005 if I wanted to try and fix my mbr(partition table), would that have been a pretty involved process?Probably. I have not been able to find this with a quick google. is the mbr exactly 512 bytes?Yup. Quote Link to post Share on other sites
shanenin Posted December 20, 2005 Author Report Share Posted December 20, 2005 (edited) if one block contains 512 bytes, that seems small to contain all of the info:the partition table. and grub infoedit added later//I am assumbing 512 bytes means 512 1s or 0s Edited December 20, 2005 by shanenin Quote Link to post Share on other sites
jcl Posted December 20, 2005 Report Share Posted December 20, 2005 (edited) if one block contains 512 bytes, that seems small to contain all of the info:You can do a lot with 512 bytes. The partition table is only 64 bytes.I am assumbing 512 bytes means 512 1s or 0s512 bytes = 512 octets = 4096 bits.Edit: To clarify, the partition table consists of four 16 byte entries, one for each primary partition. Each entry has six fields describing the partition. Here's an example, with the fields labelled:Active CHS start Type CHS end First sector Length00 010100 82 fe3f79 3f000000 bbe71d0080 00017a 83 feffff fae71d00 3df7c60400 000000 00 000000 00000000 0000000000 feffff 85 feffff 37dfe404 8a581409Active is 0x80 if the partition is active (bootable) and otherwise is ignoredCHS start is the beginning of the partition in cylinder-head-sector format. AFAIK this is ignored by Linux.Type is the partition type. 82 = Linux swap, 83 = Linux primary, 85 = Linux extendedCHS end is the end of the partition is CHS format. Also ignored.First sector is the first sector of the partition. (This value is little-endian, so the first sector of partition 0 is actually 0x3f = 63.Length is the length of the partition in sectors. (Also little-endian.)So here we have three partitions (part2 is unused). The first partition is a Linux swap partition of 1,959,867 sectors = ~956 MiB (hooray for dubious rounding by partitioning tools), the second is a bootable regular primary partition of 80,148,285 sectors = ~38 GiB, and the last is an extended partition of 152,328,330 sectors = ~72 GiB (that happens to contain two logical partitions of about equal size). Edited December 21, 2005 by jcl Quote Link to post Share on other sites
shanenin Posted December 21, 2005 Author Report Share Posted December 21, 2005 512 bytes = 512 octets = 4096 bits.I always get bit and bytes mixed up, that is 8 times more ones and zeros then I was thinking. Quote Link to post Share on other sites
shanenin Posted December 21, 2005 Author Report Share Posted December 21, 2005 thanks for the nice explanation :-) Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.