Partitioning and cfdisk how-to and how to ungoof your MBR
Of course we first need to get the standard disclaimer out of the way: If you through the use of this document bork your hardware, software, dog, girlfriends goldfish or otherwise don't come crying to me! As always- BACK UP YOUR DATA FIRST!! Especially if you're considering repartitioning your hard drive.
Also- this really belongs in the wiki but since I don't have time, patience or otherwise it would be fantastic if some kind soul could take the time to put it there.
On with the show...........
There is no great science to disc partitioning. A hard drive is actually two discs, one above the other with a gap of apporximately 1/4" seperating them. The 'heads' are little arms that move across all four disc surfaces from outer edge to inner edge and back. They write data to and read data from the disc in 'blocks'. Of course it's a little more complicated than that but that's enough for our intent. When you install windows it automatically makes a partition the size of the entire first hard drive and also formats the drive. Back when a big hard drive was less than 1 gigabyte that was ok- now they are comparatively huge and we can make much better use of disc space by partitioning.
When you partition the disc you are dividing it into sections. Remember how vinyl LP's look? Cmon' now I know I'm not the only one who remembers LP's! :D You could see where each song started and stopped. This is much the same as hard drive partitions except that we must use a graphical representation of the partitions since we cannot physically see the partitions. For all practical intents and purposes you may think of partitions as seperate discs in and of themselves. They will be used as such. There are any number of partitioning programs out there. They all do the same thing. Some are easier than others. I would recommend using qtparted as it is a very easy to understand proram that graphically represents how your disc is partitioned and it is included with Knoppix.
*NOTE*I have heard all sorts of stories about working w/ NTFS from Linux ranging from good to bad. Beware.
Open a root terminal and do this:
qtparted
OR- open any terminal and do this:
sudo qtparted
This should open up qtparted. Go ahead and have a look- you won't hurt anything (just don't 'write' anything). It should show you all of your hard drives and how they are partitioned.
*NOTE* There is still some question as to whether or not qtparted will work for resizing Reiser formatted partitions.
There are several ways that Linux refers to drives. Fortunately this is slowly changing to one standard format called the device file system but we aren't there yet. Your drives are usually referred to like this:
Primary Master- /dev/hda
Primary Slave- /dev/hdb
Secondary Master- /dev/hdc
Secondary Slave- /dev/hdd
Your first drive /dev/hda is usually a hard drive (except for diskless machines!). It is where the Master Boot Record is stored. The MBR contains quite a bit of info- specifically your bootloader which actually has two stages- primary and secondary. The primary bootloader does nothing more than start the secondary boot loader. The secondary boot loader boots the partition with your operating system on it. If you only have one bootable partition then that's fairly straightforward. However, if you wish to dual-boot then you will need a menu from which you can choose the partition you'd like to boot. While ntldr is capable of this it is not very user friendly to configure. LILO and GRUB (the most common Linux bootloaders) while functionally quite different from each other are both fairly easy to configure once you understand the basics-that is another how-to though.
Partitioning:
Each individual partition is numbered. First the disc name '/dev/hda' then the partition number '1,2,3' etc. This gives you /dev/hda1, (first hard drive first partition) /dev/hda2, etc. Another example: /dev/hdc5 (3rd drive 5th partition).
The first four partitions of each disc are usually Primary partitions. Partitions 5-? are usually logical partitions. You could for example create two primary partitions. The first partition ( /dev/hda1 for example) does not need to be very large. 50Mb should do it. It will be a primary partition. Partition number two /dev/hda2
can be any size you wish. Let's say we use the rest of the disc for this partition. We'll assume a total disc of 5000Mb (5Gigabytes) total space. /dev/hda2 will then be approx. 4950Mb (remember that the sizes won't be exact).
*NOTE* Hopefully this does not confuse matters for you. If you only have two partitions, both will be primary. If you then create logical drives or extended partitions inside of partition #2 that partition will then change from #2 to #4. Why? Because partition #4 is the one that is usually used for logical drives.
Logical Drives (extended partitions).
Inside of /dev/hda2 (our second partition on the first hard drive) we will now create two Logical Drives. They will begin with?..../dev/hda5, dev/hda6, etc. Why? See the above paragraphs. You can make them any size you want as long as they fit inside the primary partition. Lets make our first logical drive 3000Mb. This is where we will install the /root directory.
The second logical drive we will make 500Mb. This will be our swap partition.
The 3rd logical drive we will make 1500Mb. This one could be used for our /home partition (refer to the Knoppix docs for a how-to on moving your /home partition).
I personally prefer to use cfdisk to view, create and delete partitions. It is also used during the Knoppix install script so if you intend to install Knoppix it might be a good idea to familiarize yourself with cfdisk.
You may use the above examples and sizes for a Knoppix hd-install. They should work just fine.
Here is another example of a partitioned 20G drive:
#: cfdisk /dev/hda
Code:
cfdisk 2.11z
Disk Drive: /dev/hda
Size: 20490559488 bytes, 20.4 GB
Heads: 255 Sectors per Track: 63 Cylinders: 2491
Name Flags Part Type FS Type [Label] Size (MB
hda1 Boot Primary Linux ext2 65.81
hda5 Logical Linux ReiserFS 1003.49
hda6 Logical Linux swap 1497.01
hda7 Logical Linux ReiserFS 1998.75
hda8 Logical Linux ReiserFS 1998.75
hda9 Logical Linux ReiserFS 3002.23
hda10 Logical Linux ReiserFS 3002.23
hda11 Logical Linux ReiserFS 5872.85
[Bootable] [ Delete ] [ Help ] [Maximize] [ Print ]
[ Quit ] [ Type ] [ Units ] [ Write ]
Use the arrow keys to navigate through cfdisk. The options at the bottom are fairly self-explainatory but I'll give a brief description of each one:
[Bootable]- marks a partition as 'bootable'. Note that only the first partition needs to be labeled as bootable IF YOUR BIOS CANNOT BOOT FROM BEYOND THE 1024 CYLINDER LIMIT OR YOU ARE USING NTLDR.
[Delete]- just as it implies it will delete- without question any partition you choose.
[Help]- take a guess.
[Maximize]- An option to maximize the usage of the partition. You will likely never need to use this option.
[Print]Not literally "send to printer" but print to file OR- for those of you that are curious print to screen-you can even choose the format. The following is [Print] [Sectors] to screen.
Code:
Partition Table for /dev/hda
First Last
# Type Sector Sector Offset Length Filesystem Type (ID) Flags
-- ------- -------- --------- ------ --------- ---------------------- ---------
1 Primary 0 128519 63 128520 Linux (83) Boot (80)
2 Primary 128520 4128704 0 4000185 Linux (83) None (00)
4 Primary 4128705 40017914 0 35889210 Extended (05) None (00)
5 Logical 4128705 6088634 63 1959930 Linux (83) None (00)
6 Logical 6088635 9012464 63 2923830 Linux swap (82) None (00)
7 Logical 9012465 12916259 63 3903795 Linux (83) None (00)
8 Logical 12916260 16820054 63 3903795 Linux (83) None (00)
9 Logical 16820055 22683779 63 5863725 Linux (83) None (00)
10 Logical 22683780 28547504 63 5863725 Linux (83) None (00)
11 Logical 28547505 40017914 63 11470410 Linux (83) None (00)
[Quit]Just as it implies.
[Type]With this option you can MARK any partition as a certain format type. THIS DOES NOT FORMAT THE PARTITION!! That is a seperate process to be completed later AFTER writing your partition table AND confirming the re-read of your partition table which may involve a reboot.
[Units]Changes the format which your partitions are displayed. Your choices are Megabytes, Sectors or Cylinders. Stick with Megabytes unless you know what you are doing. It's much simpler.
*NOTE* A Megabyte is 1024 Kilobytes. Therefor, in the above example /dev/hda10 is 3000 Mb OR 3Gigabytes.
[Write]- Commits your new partition table to the hard drive.
*REMEMBER* If you do not [Write] the partition table to disc nothing will be changed. When you do invoke the [Write] option cfdisk will tell you if it wrote successfully or not and if it succeeded in re-reading the partition table AFTER writing. If it fails to re-read the table you will need to reboot for the changes to take effect. If it successfully re-reads the partition table you should not need to reboot but if it makes you feel better by all means go ahead.
So what are you waiting for? Go ahead, start cfdisk, create and destroy partitions at will- JUST DON'T WRITE ANYTHING! and you'll be fine-just [Quit] cfdisk. Learn your way around the program, what it can and cannot do and how it does it. When you're happy with your partitions you've created then go a head and write the partition table to disc.
*REMEMBER* If cfdisk "failed re-reading partition table" then you MUST reboot before trying to format a partition!!
"I goofed my MBR and now I can't boot windows!"
Two things that are reported to work:
1)Boot w/ win98 boot floppy, at the a: propmt enter:
fdisk /mbr
2)Boot w/ XP or WIN2k cd into recovery mode and run:
fixmbr
Re: Partitioning and cfdisk how-to and how to ungoof your MB
Quote:
Two things that are reported to work:
1)Boot w/ win98 boot floppy, at the a: propmt enter:
fdisk /mbr
2)Boot w/ XP or WIN2k cd into recovery mode and run:
fixmbr
Yes, those will restore your original MBR... and sometimes the mapping from the MBR to the boot sector is messed up, too, so these two commands also help:
Addition to #1: sys C:
Addition to #2: fixboot
Fixing the Windows MBR from Linux
If you have separate hard drives for Linux and Windows, you can fix the Windows MBR from within Linux.
First, read Little White Dog's excellent how-tos for making a dual-boot Linux system. http://www.littlewhitedog.com/reviews_other_00011.asp
http://www.littlewhitedog.com/reviews_other_00011b.asp
Then (heresy here) burn/buy/borrow the first disk of Mandrake Linux (9.x) and follow these instructions:
1. Boot from the Mandrake Linux installation CD.
2. When the installation screen comes up, press [F1] to get to the repair options screen.
3. Type "rescue" and press[Enter].
One of the options will be to restore your Windows MBR.
Choose it and follow instructions.
4. Exit and reboot.
Re: windows say unmountable
Quote:
Originally Posted by Facteur
I used ntfsresize and cfdisk to resize XP Pro on my 450MHzP3 with 6G HD, and create new partitions for Linux.
I didn't use qtparted because, I thought it was poor, although nice to look at.
Fdisk gave me wild info about my HD, saying that it already had four partitions (hda1p1, hda1p2, hda1p3 and hda1p4). Cfdisk appeared the most serious of the tools.
I followed all the available instructions and everything was went fairly smoothly, except when I tried to boot back in XPPro under the newly partitioned HD. The splash screen holds for about a second and then I get a blue screen of death with error type "unmountable_boot_volume". After that, I feared the worst. But I was able to see my original NTFS volume with Knoppix OK and even read some of the files.
Unfortunately cfdisk is the worst choise. Apparently it rounds down to cylinder boundary opposed to fdisk and QTParted thus you made the end of your partition in the middle of your NTFS filesystem. You can confirm this if you run 'ntfsresize -fi partition', ntfsresize will complain (I managed to do this once before). I just recreated the partition to be bigger and everything worked fine.
Other possibilities are you did't set the partition type to 7 or missed the set the partition's bootable.
Also if your partition wasn't /dev/hda1 then it might be renumbered and NTLDR can't find the right partition because BOOT.INI has the old value. This is also fixable.
QTParted takes care about these annoying details thus why I prefer using it :)
For anyone having problems restoring the MBR or Windows:
Just a bit of clarification for restoring Windows 95/98/ME/2000/XP/2003
If you are using Windows 95/98/ME (or DOS):
1. Boot from the CD that came with Windows OR get a Windows 98 bootdisk www.bootdisk.com
2. Select "Start Computer with CD Support" (you can select anything except Starting Setup and this will work)
3. If you're not in the partition where Windows is installed navigate to it. Type C: will take to the C: drive, ect.
4. Type fdisk /mbr to fix the Master Boot Record. (NOTE: You will no longer be able to boot Linux).
5. This step shouldn't be neccessary, and you should only do it if your using a boot disk/cd from your version of Windows, but if you think you need to, navigate to your CD/floppy (type A: or D:) and type sys C: (or whatever drive Windows is on).
If you are using Windows 2000/XP/2003
1. Insert the CD that came with Windows. (If the CD won't boot, you can get a bootable floppy (which may or may not require the CD anyway) from www.bootdisk.com , or there should be an image on the CD itself)
2. When prompted whether to install Windows or Repair Windows, select repair. (R)
3. Select Repair Console (C).
4. If Windows is still readable by the CD, it will prompt you for a password (if you're not prompted, Windows may need to be reinstalled).
5. If you're not in the partition where Windows is installed navigate to it. Typing C: will take you to the C: drive, etc.
6. Type fixmbr (Note: you will no longer be able to run Linux).
7. Linux generally won't touch the Boot Sector (it only changes the MBR), but just to be on the safe side, you should type fixboot.
After the above steps, your system should run Windows. If you have any problems with these instructions, post a reply or email me at: geekandy(nospam)[email protected] (be sure to include the dash)
Replacing existing RH9 in GRUB dual boot (w/ W2k) w/Knoppix
Hi all--
I'm a little bit of a noobie at this, although I've been working with RH off & on since 2002 (v 7.2, v 8.0, v9).
I've been less satisfied with RH with each newer incarnation (they seem to be migrating in a M$FT-like direction), and would like to replace the existing installation with a Knoppix HDD install, as the Knoppix CD boots my computer perfectly, finds all the hardware perfectly (including the USB HDD and memory stick I use), where RH does not.
Here's the scenario:
I have three HDDs:
one (27G, 7200RPM) for W2k (the first)
one for data storage (60G, 7200RPM) and swap files (four partitions--W2k swap, data 1, data 2, Linux swap),
one for Linux (10G, 5400RPM--the original HDD from the computer that preceded this one...) with '/boot' (generously allocated 100MB :wink:), '/', and '/home' partitions formatted ext3, and a 750k vfat partition specifically for compiling files while preparing CDs for burning
I'm hoping I can keep the Linux partitions as they are, empty them (I've backed up the /home to the W2k "G:" (data 2) partition), and install Knoppix in them.
I've read the how-tos and FAQs and none of them address this scenario specifically, i.e., loading into pre-existing dual-boot in place of a different Linux distribution. Most of the "I have windows and want to add Knoppix as my second OS" and "I have Knoppix and want to add windows as my second OS" scenarios are well documented, but none answer my big question, which is: Does the Knoppix install routine 'knx-hdinstall' offer GRUB as an option (the McNab article suggests using it, which I'm happy to do, as I'm used to it, but fails to mention if it's part of the normal knx-hdinstall setup or something I'd have to kludge on later), and will it freak out over the fact that the MBR on the first HDD (I installed Windows first and Linux second, so GRUB is on the first HDD) is already GRUB-ed and working quite well as dual-boot?
Has anyone else tried the same thing?
Thanks in advance for any ideas or advice you can give. I'm diving into this this w/e.... If it is successful, I'll post a description of the resulting process, in case anyone else is in a similar boat....
Thanks!
C ya,
Dutch
PS:to richenbacherus--
you play guitar? hang out at ampage.org or the yahoo strat, rigtips, or tubefex groups? your handle sounds familiar....
Re: Replacing existing RH9 in GRUB dual boot (w/ W2k) w/Knop
Quote:
Originally Posted by joe_bfstplk
Here's the scenario:
I have three HDDs:
one (27G, 7200RPM) for W2k (the first)
one for data storage (60G, 7200RPM) and swap files (four partitions--W2k swap, data 1, data 2, Linux swap),
1) Point the intaller to your exisitng Linux swap (it should find it on its own however).
2)If you want data1 & data2 partitions mounted automatically on boot simply edit /etc/fstab AFTER the install as there in no capacity for this as of yet.
Quote:
one for Linux (10G, 5400RPM--the original HDD from the computer that preceded this one...) with '/boot' (generously allocated 100MB :wink:), '/', and '/home' partitions formatted ext3, and a 750k vfat partition specifically for compiling files while preparing CDs for burning
/boot is unnecessary but doesn't hurt anything. Just realize that if you want your kernel on its own partition you'll have to move it yourself. I would advise against it.
Quote:
I'm hoping I can keep the Linux partitions as they are, empty them (I've backed up the /home to the W2k "G:" (data 2) partition), and install Knoppix in them.
Just reformat your existing partitions. For ext3:
mke2fs -j /dev/hdx?
What size are / and /home? That will be the determining factor. Realize however that the installer is incapable of installing to multiple partitions without a bit of editing on the part of the user. Fear not as it's quite simple to do:
Quote:
Does the Knoppix install routine 'knx-hdinstall' offer GRUB as an option (the McNab article suggests using it, which I'm happy to do, as I'm used to it, but fails to mention if it's part of the normal knx-hdinstall setup or something I'd have to kludge on later), and will it freak out over the fact that the MBR on the first HDD (I installed Windows first and Linux second, so GRUB is on the first HDD) is already GRUB-ed and working quite well as dual-boot?
1)Simply intall lilo to /root and not mbr. Then just edit menu.lst so that it points to your kernel.
2)Don't use knx-hdinstall. Use knoppix-installer instead.
3)Better yet, get Kanotix It is built w/ sid and makes for a great install cd. Knoppix is really more of a live cd. The installer was created at the request of the users AFAIK.
Boot Kanotix.Make your partitions. Format them as ext3 (or whatever you like). Currently the installer can only format /root. Start the installer:
1)sudo kanotix-installer
2)Configure
3)Quit.
4)Save config? YES
5)sudo xedit /root/.knofig
6)Edit HD_MAP=""
(example)
7) HD_MAP="/dev/hda3:/home /dev/hda6:/tmp /dev/hda7:/var /dev/hda14:/usr"
8)Save
9)sudo kanotix-installer
Review your configuration.
10) In another terminal: mount
You should see your partitions mounted on their respective mount points.
You do not have to move all directories listed in my example to other partitions. Selecting / and /home is suficient. Make sure that / is at least 2G. I'd recommend larger.
Perhaps moving this to its own thread would also get you more visibility.
Quote:
PS:to richenbacherus--
you play guitar? hang out at ampage.org or the yahoo strat, rigtips, or tubefex groups? your handle sounds familiar....
Yes I play- quite poorly at that. :)
Re: Replacing existing RH9 in GRUB dual boot (w/ W2k) w/Knop
Quote:
Originally Posted by rickenbacherus
1) Point the intaller to your exisitng Linux swap (it should find it on its own however).
2)If you want data1 & data2 partitions mounted automatically on boot simply edit /etc/fstab AFTER the install as there in no capacity for this as of yet.
Thanks! This worked out pretty well, although the installer had to be told which physical drive to look on, it found the existing swap once I'd done so.
Quote:
/boot is unnecessary but doesn't hurt anything. Just realize that if you want your kernel on its own partition you'll have to move it yourself. I would advise against it.
I ended up doing exactly as you advise--nixing the /boot. I didn't feel comfortable with moving the Kernel around and such. I stumbled across, er..., found (yeah, that's the ticket) a thread started by jdong also that provided a step-by-step for getting the bootloader set up, which was my main problem after installing. I could see and boot into Win2k, but not into Knoppix.
Quote:
What size are / and /home? That will be the determining factor. Realize however that the installer is incapable of installing to multiple partitions without a bit of editing on the part of the user. Fear not as it's quite simple to do:
1)Simply intall lilo to /root and not mbr.
That's what I did the last time, after trying and failing with LILO in the MBR (it didn't even show up on the MBR--maybe it put it in the MBR of hd2?). Then I followed (sort-of) jdong's instructions about the boot.ini file in Win2k to get it to boot. My / is about 4.2G, and /CD_PREP is about 750M, leaving 5G for /home. I need to make an ext3 file system on the new /home partition, as I've not done that yet, but then I'll be transferring all the home directories to that partition and wiping out the standard knoppix user in favor of my own account....
Quote:
Perhaps moving this to its own thread would also get you more visibility.
I think that's a good idea, as it may help someone else in a similar situation (already set up for dual-boot, switching from another distro, etc.). I'll try to get that going tomorrow, after I get done with setup here and installing my new DVD-R/RW drive.... javascript:emoticon(':D')
Quote:
Yes I play- quite poorly at that. :)
Don't knock yourself, a lot of famous players aren't "all that" either. If you have fun doing it and small furry animals don't spontaneously die upon hearing you play, it's cool. Drop on over to ampage.org if you have any amp/gear related questions. It's a great resource. I hang out there a lot, as I like to build tube amps.... I also enjoy the irony of using advanced technological means (such as computer and internet) to communicate about vacuum tubes.... javascript:emoticon(':lol:')
Thanks again!
C ya,
Dutch
Re: Partitioning and cfdisk how-to and how to ungoof your MB
Hi, after HD install I also could not run win(winxp).
I had several partitions on hda:
1 ntfs for winxp bootable
1 reiserfs for linux
1 swap
1 fat32 for read/write from both os
I looked around when booted with a diskette into knoppix.
I found a command:
install-mbr
Read the help file(manual?) and tried it.
I took the option to boot from hda1 and hda2.
Rebooted straight into winxp.
I boot to linux with my diskette.
Maybe I better put lilo to do the first loading?
Have to work on that.
Greetings from Belgium.
adding notes:
dd.june2005: now I use GRUB, LILO or XOSL to do the booting.
LILO tips for those new to this....
Here's some of our notes from a knoppix hd install...
If you put LILO on your windows MBR and later want it off,
you can remove it by booting to your knoppix hd install, open a console then type
lilo -u
reboot and windows will boot as normal.
The boot floopy made by knoppix-installer will still boot linux.
----------
A good way to install knoppix is to put it on the 2nd HD, then install lilo to the partition. Then use mbrwiz a free windows tool, to set that partition active. Now you can use your bios to select the HD to boot from.
If you have the linux drive booting you will get the LILO menu and can boot linux or windows. If you set your bios to boot from the windows HD all will be normal, no LILO menu.
Re: Windows died. Now what?
Quote:
Originally Posted by Celebwath
I have a slight problem: my girlfriends computer has been dual booting between Knoppix and WinXP. However some time ago the windows kernel died while patching the system. I can still get to all the files on hda1 (where the XP was installed) from linux, but it cannot be booted. I do not think that there is any way of repairing it, and that is where the problem comes: if I have understood it correctly, re-installing windows will rewrite the mbr and prevent booting into linux.
So the questions is there a way to install XP so that it will allow booting into Knoppix directly, or a way of "fixing" the mbr after the installation? There's quite a lot of data that should be saved and the easiest way would be to just transfer it to the linux partitions and re-transfer it after the installation (there are 2 fat32 partitions for linux-windows interaction on the hd), not to mention that there's quite enough to do configuring and patching the windows side of things.
Any advice?
I don't know about XP. I once accidentally managed to install Windows 2000 Pro - which I've heard is similar to XP - after I installed Linux. I had already created and formatted a NTFS partition in an attempt to install W2KPro, which wouldn't go. In the desperate attempt to get something to work, after I figured out the problem I happened to install (Mandrake) Linux, which left the NTFS partition blank. Then I stuck the Windows 2000 Pro installation CD in, and it installed Windows to the pre-formatted NTFS partition without messing up the MBR or LILO or Mandrake Linux. So I recommend that you stick the XP installation CD in and see what happens. That's my story and I'm sticking to it.
How to write logical partitions ???
Okay, I have been spending my afternoon with cfdisk, I understand how it works, but one thing:
I have decided to have the following partitions on my system:
- a swap partition
- a partition for /
- a partition for /usr
- a partition for /usr/local
- a partition for /tmp
- a partition for /var
- a partition for /var/mail
- a partition for /home
that makes a total of 8 partitions, I understand that I can only do 4 partitions, but if one of those is logical I can then create other partitions inside that same one, so:
How can I do this ? I seem to be able to create 4 partitions but I can't do more than that even if one is logical, or cfdisk can't do this ?? Please explain me how I do my 8 partitions.
Alex