Ubuntu Disk Utilities

These are directions I had to find through the web to format new disks that I install to an existing system.

This will show you all of the attached drives on the system
fdisk -l

fdisk utility

First, you will need to run the fdisk command in order to partition the disk. For this example, I only want to create one ext3 partition. Here is an example session:
fdisk /dev/hdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

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 4865.
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): n
Command action
   e   extended
   p   primary partition (1-4)


Partition number (1-4): 1
First cylinder (1-4865, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-4865, default 4865): 4865

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 83

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.</pre>
<strong>Create ext3 File System</strong>
The next step is to create an ext3 file system on the new partition. Provided with the distribution is a script named /sbin/mkfs.ext3. Here is an example session of using the mkfs.ext3 script:
<pre>mkfs.ext3 -b 4096 /dev/hdb1

mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
4889248 inodes, 9769520 blocks
488476 blocks (5.00%) reserved for the super user
First data block=0
299 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Mounting the File System
Now that the new drive(s) are partitioned and formatted, the last step is to mount the new drive(s). Typically on Ubuntu they will be in the /mnt directory.
I create a folder to mount the drives in the /mnt directory: mkdir nfs or mkdir right_raid

Below is the output from the /etc/fstab file note the entries I made:
# /etc/fstab: static file system information.

proc            /proc           proc    defaults        0       0
# /dev/sda1
UUID=9856bbea-a089-475f-ab29-1b976a666869 /               ext3    relatime,errors=remount-ro 0       1
# /dev/sda5
UUID=2ad62d1d-e91f-4d48-8830-c5f32c8a5c56 none            swap    sw              0       0
/dev/scd1       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0
/dev/scd0       /media/cdrom1   udf,iso9660 user,noauto,exec,utf8 0       0
#Xserve RAID
#/dev/sdc1      /mnt/left_raid  ext3    defaults        0       0
#/dev/sdb1      /mnt/right_raid ext3    defaults        0       0
/dev/sdb1       /mnt/nfs        ext3    defaults        0       0
/dev/sdg1       /mnt/right_raid ext3    defaults        0       0

After making the entry in the /etc/fstab file, it is now just a matter of mounting the disk:
mount /db

df -k

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda3             37191660  11016692  24285724  32% /
/dev/hda1               101089     12130     83740  13% /boot
none                    515524         0    515524   0% /dev/shm
/dev/hdb1             38464340     32828  36477608   1% /db
Mount drive, You might want to create the actual mkdir you want to attach the drive to like creating a drive letter name
mount /dev/sdc1 /mnt/right_raid -t ext3

Thanks to a friend of mine for the information about CFDISK which is a semi graphical utility to partition drives.
cfdisk /dev/sdf


Popular posts from this blog

Console over SSH (ONTAP)

Brocade Zone Setup

OpenSolaris ZFS Setup