Re: Adding and formatting a new partition on a second harddrive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 10 Nov 2003, Linda L?fdahl wrote:
> Mkpart won?t work for me. Can someone give me a simple 1, 2, 3 of what I
> should do to add and format a new partition on my second harddrive (no
> existing partitions).

Cookbook procedure.  You will be using fdisk, mkfs.ext3, and editing
/etc/fstab.  You will create mount points, and mount the new partitions.

FIRST: read the man pages for fdisk , mkfs.ext3 , ln, and mount.  You
will need to work as "root".   You will need to know how to use a text
editor like "vi".

SECOND: Make sure you know which drive you will be formatting: 
/dev/hdb, /dev/hdc, /dev/sda?  You can find out more with "dmesg"
and by reading /var/log/messages.  You will NOT be formatting /dev/hda ;
if that is available, it will probably be your boot drive.  /dev/sda
is often the boot drive on a SCSI system, though it is my second drive.

THIRD:  Use fdisk to make partitions.  For example, I will now use
fdisk on a 30GB drive on /dev/sda, making a 10GB partition named "fred"
and a 20GB partition named "cheese".  I will start by looking at the
available commands with the fdisk "?" command, then at what is on
the disk with the fdisk "p" command, then I will zero out the
table with the "o" command, then I will use the "n" command twice
to create two partitions.  I will use the "p" command to print the
result, then write the partition table out with "w":

  REMEMBER, your second disk may not be /dev/sda but something else.
  Replace instances of /dev/sda* below with the path to you drive.
  CHECK THIS!!!!!!

Example:
---------------------------------------------------------------------
[root@gate root]# fdisk /dev/sda
                                                                                
The number of cylinders for this disk is set to 28629.
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): ?
?: unknown command
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
                                                                                
Command (m for help): p
                                                                                
Disk /dev/sda: 30.0 GB, 30020272128 bytes
64 heads, 32 sectors/track, 28629 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
                                                                                
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1     10000  10239984    b  Win95 FAT32
/dev/sda2         10001     20002  10242048    b  Win95 FAT32
/dev/sda3         20003     28629   8834048    b  Win95 FAT32
                                                                                
Command (m for help): o
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
                                                                                
                                                                                
The number of cylinders for this disk is set to 28629.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-28629, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-28629, default 28629): +10000M
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (9539-28629, default 9539):<cr>
Using default value 9539
Last cylinder or +size or +sizeM or +sizeK (9539-28629, default 28629):<cr>
Using default value 28629
 
Command (m for help): p
 
Disk /dev/sda: 30.0 GB, 30020272128 bytes
64 heads, 32 sectors/track, 28629 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
 
   Device Boot    Start       End    Blocks   Id  System
/dev/sda1             1      9538   9766896   83  Linux
/dev/sda2          9539     28629  19549184   83  Linux
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
[root@gate root]#
---------------------------------------------------------------------------
We just made two regular Linux partitions.  Note that we could have made
a swap partition, or a bootable partition, or lots of extended partitions;
I will avoid those complications for this simple example.

Now we make EXT3 file systems on the partitions:
---------------------------------------------------------------------------
[root@gate root]# mkfs.ext3 /dev/sda1
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1221600 inodes, 2441724 blocks
122086 blocks (5.00%) reserved for the super user
First data block=0
75 block groups
32768 blocks per group, 32768 fragments per group
16288 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
                                                                                
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
                                                                                
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@gate root]# mkfs.ext3 /dev/sda2
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2448000 inodes, 4887296 blocks
244364 blocks (5.00%) reserved for the super user
First data block=0
150 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000
                                                                                
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
                                                                                
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@gate root]#
---------------------------------------------------------------------------
Now we have two EXT3 file systems.   There are other kinds of Linux file
systems, but EXT3 will work.  This means the file systems are similar to
standard EXT2 file systems, with journalling.  Journalling means that the
data is somewhat better protected from sudden system crashes and such.

The new file systems don't have names yet, and they actually never will
have names;  that is all a matter of where you mount them and what is
in /etc/fstab . 

Make some mount points, and then mount the new partitions on them, then
check that they got mounted:
---------------------------------------------------------------------------
[root@gate root]# mkdir /fred /cheese
[root@gate root]# mount /dev/sda1 /fred
[root@gate root]# mount /dev/sda2 /cheese
[root@gate root]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda1              1007960    245372    711384  26% /
/dev/hda5             10079324   4687004   4880308  49% /usr
none                    256888         0    256888   0% /dev/shm
/dev/sda1              9613524     32828   9092352   1% /fred
/dev/sda2             19241852     32828  18231568   1% /cheese
[root@gate root]#
---------------------------------------------------------------------------
You now have two usable partitions!  However, the next time you reboot they
will not be mounted automatically.  So you need to edit /etc/fstab, and
add two lines:
---------------------------------------------------------------------------
/dev/hda1      /                       ext3    defaults        1 1
/dev/hda5      /usr                    ext3    defaults        1 2

<add these two lines:>
/dev/sda1      /fred                   ext3    defaults        1 2
/dev/sda2      /cheese                 ext3    defaults        1 2
---------------------------------------------------------------------------
You are done!  Except for filling the file systems with your own data, of
course.  These new file systems will belong to root.  You will probably
want to add subdirectories to these, and use symbolic links ( ln -s ) to
connect the subdirectories to directories in your home directory or elsewhere.

Again, a reminder:  Make sure you are doing this to the correct disk drive.
fdisk and mkfs are power tools, and can make lots of damage very quickly
if used on the wrong drive.  

Good luck!

Keith

-- 
Keith Lofstrom           keithl@xxxxxxxx         Voice (503)-520-1993
KLIC --- Keith Lofstrom Integrated Circuits --- "Your Ideas in Silicon"
Design Contracting in Bipolar and CMOS - Analog, Digital, and Scan ICs




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux