LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 06-14-2006, 10:06 AM   #1
lowebb
Member
 
Registered: Aug 2005
Location: Ireland
Distribution: Ubuntu, Ubuntu, Ubuntu
Posts: 119

Rep: Reputation: 15
fdisk paritioning help


Hi folks,

I'm running ubuntu drake and kinda messed up the partitioning of a second hard drive when recently installing ubuntu. Rather than reinstalling the system I'm trying to figure out how to do it using fdisk, any help would be great.

The drive is 40G in size and is at /dev/hdb. I'm not even sure how to about installing fdisk (does it come preinstalled) and the command I would need to run, though I dont think it would be difficult, I'm looking for a simple 'ext3' single primary drive mounted to say..... /media/home

Thanks for any help
 
Old 06-14-2006, 10:12 AM   #2
jeelliso
Member
 
Registered: Oct 2005
Location: Knoxville, Tn (USA)
Distribution: OpenSUSE, Ubuntu
Posts: 250

Rep: Reputation: 30
Well, fdisk should already be installed. Run "whereis fdisk" to make sure (it will probably be in /sbin or similar). I'm not exactly sure what you are trying to do though. So you have two hard drives: /dev/hda for Ubuntu that is already installed and /dev/hdb that you want to make a single ext3 partition? Is that right?
 
Old 06-14-2006, 11:00 AM   #3
lowebb
Member
 
Registered: Aug 2005
Location: Ireland
Distribution: Ubuntu, Ubuntu, Ubuntu
Posts: 119

Original Poster
Rep: Reputation: 15
Yeah so when I install ubuntu I installed it on hda but had a second hard drive which I messed up and patitioned as an 'extended partition' and so cant get to it within ubuntu, so I want to repartition it as a primary drive mounted at /media/home
 
Old 06-14-2006, 11:08 AM   #4
jeelliso
Member
 
Registered: Oct 2005
Location: Knoxville, Tn (USA)
Distribution: OpenSUSE, Ubuntu
Posts: 250

Rep: Reputation: 30
Okay, thats no problem. As long as your hard drive is connected correctly you should be able to run
Code:
fdisk /dev/hdb
to enter the fdisk environment. You can use "p" (thats just p on a line by itself) to list the current setup on that drive. The first thing you will want to do is use "d" to delete the existing partitions. Then you will want to use "n" to create a new partition using the default starting and ending blocks. This will give you one partition that consumes the entire drive. Once created you will need to use "t" to change the ID for that partition. You can use "l" to list all the available IDs. It will probably default to the correct ID though, 83. When you are done you can use "w" to write the changes to your disc. I simiulated the process on my pc so here it is:
Code:
root@marXubuntu:~# fdisk /dev/hda

The number of cylinders for this disk is set to 4864.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

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

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1          65      522081   83  Linux
/dev/hda2              66        4733    37495710   83  Linux
/dev/hda3            4734        4864     1052257+  82  Linux swap / Solaris

Command (m for help): d
Partition number (1-4): 1

Command (m for help): d
Partition number (1-4): 2

Command (m for help): d
Selected partition 3

Command (m for help): p

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

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-4864, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-4864, default 4864): 
Using default value 4864

Command (m for help): p

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

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        4864    39070048+  83  Linux

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): l

 0  Empty           1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot   
 1  FAT12           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 2  XENIX root      39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 5  Extended        41  PPC PReP Boot   85  Linux extended  c7  Syrinx         
 6  FAT16           42  SFS             86  NTFS volume set da  Non-FS data    
 7  HPFS/NTFS       4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 8  AIX             4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility   
 9  AIX bootable    4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt         
 a  OS/2 Boot Manag 50  OnTrack DM      93  Amoeba          e1  DOS access     
 b  W95 FAT32       51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O        
 c  W95 FAT32 (LBA) 52  CP/M            9f  BSD/OS          e4  SpeedStor      
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs        
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  EFI GPT        
10  OPUS            55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       a9  NetBSD          f4  SpeedStor      
16  Hidden FAT16    63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary  
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fd  Linux raid auto
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fe  LANstep        
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid ff  BBT            
1c  Hidden W95 FAT3 75  PC/IX          
Hex code (type L to list codes): 83

Command (m for help): p

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

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1               1        4864    39070048+  83  Linux

Command (m for help):
keep in mind that you will use "/dev/hdb" instead of "/dev/hdb"

Once the partition is in place you will need to use mke2fs to format the partiton. Run
Code:
mke2fs -j /dev/hdb1
Once the partition is in place you will need to add a line to your /etc/fstab that will automatically mount this drive when you boot. Add the follwing line (or something similar):
Code:
/dev/hdb1       /media/home               ext3    defaults,errors=remount-ro 0       1
And good luck.

~Justin
 
Old 06-30-2006, 03:06 AM   #5
somewhiteguy05
LQ Newbie
 
Registered: Nov 2005
Location: SA, Tx, USA
Distribution: Mandrivia 2006, Fedora Core 5, Knoppix
Posts: 29

Rep: Reputation: 15
this was very helpful, i tried to dd an image of mac os to a spare hard drive to try to get it to work, but it failed misrably (i had a .iso instead of a .img) i have a hard drive with mandriva and xp, a hard drive with just data, and that spare hard drive, i wanted to install slack on the spare but the slack installation wasn't seeing the hard drive, now that i formatted it into a linux partition, it worked, thanks
 
  


Reply

Tags
fdisk


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
weird fdisk problem (Fdisk unable to see winxp partitions) khidot Slackware - Installation 5 04-07-2007 09:26 PM
Paritioning advice on XP machine for Red Hat and SuSe vdogvictor Linux - Newbie 2 03-01-2004 03:37 AM
paritioning for linux? fire2501 Linux - Newbie 12 01-09-2004 09:46 PM
Paritioning using Kickstart yaswanth Red Hat 1 11-20-2003 10:36 AM
Paritioning (Mandrake 9.1/Diskdrake) infidel Linux - Newbie 1 06-20-2003 04:21 PM

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

All times are GMT -5. The time now is 09:27 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