LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 09-26-2005, 09:42 AM   #1
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,440

Rep: Reputation: 80
adding a harddrive for extra space


I have got another harddrive from someone. It had Win 98/95 on it, and I think I set all the numbers to 0 on it. I am using Ubuntu 5.04. How could I use this harddrive as extra space and mount it for programs installed on Ubuntu to use? It needs to be formatted as ext3 unless there is something better. Is there software for all of this? This is probably easy for most people.
 
Old 09-26-2005, 10:06 AM   #2
debianmike
Member
 
Registered: Sep 2005
Posts: 115

Rep: Reputation: 15
I wrote this doc a while ago

Configuring drive space on a Linux box

This document walks through creating new drive space on a Linux box using either physical drives or SAN LUN's.

Step one is to physically connect the new drive to the server. Since there are several ways of doing so, this document will assume this is already complete.

NOTE: everything that you have to type at the command line is italicized and bold for reference.

Following the general rule, all drives will show up as /dev/controller/device.
For example: /dev/cciss/c0d0 would be the first drive (d0) on the first controller (c0) on the controller labeled “cciss”.
Other examples would be:
/dev/hda, /dev/hdb for the first and second IDE drives.
/dev/sda, /dev/sdb for the first and second SCSI drives. This is where SAN LUN's appear.

NOTE: these are drive assignments, not partitions--sda refers to the entire drive. Partitions are refered to with numbers as sda1, sda2, etc.

NOTE: This document does not address permissioning of this new space.

Read each Scenario carefully as you will most likely need only one set of instructions.

Scenario 1: This will be to simply mount the entire contents of the new drive (/dev/sdb) to a mount point (/newdrive). This is also the method for mounting only a portion of the drive...simply create partitions of the correct size and mount them as follows, remembering that each partition will be labeled /dev/sdb1, sdb2, sdb3, etc., etc.

NOTE: in this scenario, we will assume our new drive is /dev/sdb.

NOTE: you can only have 4 primary partitions! You can have additional partitions but they will be extended partitions. If you create extended partitions, there is normally no partition 4, since partition 4 will contain all the extended partitions, but itself is not addressable. This partition number (4) can actually be 1,2,3 or 4, but is typically 4.

Using your favorite partitioning tool, create your partitions. Here we use fdisk:

# fdisk /dev/sdb

From the partitioning menu's, create a new partition of whatever size you need (in our case the full amount).

Change the partitions system ID from its default to 83 (a simple Linux partition).

Save and exit the fdisk utility by pressing w.

There are some situations that require a reboot for the partition table to be updated. Exiting the fdisk utility will let you know if you need to reboot.

Now we need to format the new partition. There are several ways to do this, depending on the type of file system you want (ext3, ext2, Rieser, etc). We will use the mke2fs command, using the -j option to make an ext3 file system.

# mke2fs -j /dev/sdb1 Note here we format the partition sdb1, not the drive sdb.

There are many options to the mke2fs command, but the above line is all we usually need.
Now that the partition is formatted, we can mount that to our newly created folder:

# mkdir /newdrive
# mount -t ext3 /dev/sdb1 /newdrive

To mount it at boot time, edit the /etc/fstab file as follows:

/dev/sdb1 /newdrive ext3 default 0 0

and enjoy your new space!

NOTE: Since we are not covering permissoins, you will need additional information to allow others to read/write to this space.

Scenario 2: In this scenario, we will create logical volumes out of our new drive. This will give us the flexibility to grow or shrink these volumes in the future. It will also limit any one folder from filling up the entire drive.

Again, connect your new drive as before. In this example, we will use /dev/cciss/c0d1 as our new device, and assume that it is a 72Gig drive. We will create 2 volumes for practice.

Create a partition on the new drive

# fdisk /dev/cciss/c0d1

From the partitioning menu's, create a new partition spanning the entire drive.

Change the partitions system ID from its default to 8e (a Linux LV).

Save and exit the fdisk utility by pressing w.

Now we need to create a physical volume on that partition

# pvcreate -v /dev/cciss/c0d1p1

This prepares the new partition for logical volumes.

Now we will create a volume group, that later we can add additional drives to.

NOTE: in the following example, I use vg01, assuming that vg00 is being used by the system (the OS). vg01 would be the next logical name, and is my standard, however, any name is technically acceptable.

# vgcreate vg01 -v /dev/cciss/c0d1p1

This creates vg01 and adds our new partition to it.

Type vgdisplay vg01 at the # prompt and make note of the Alloc PE / Size and Free PE / Size values.

Next we start creating logical volumes. These are similar to partitions, but offers resizing abilities since they are not tied to physical mappings on the drive.

NOTE: again, we are building a logical volume out of a piece of vg01, which we created earlier. In the example, we are creating a 20Gig volume and calling it lvsales, and will assign this to the /sales folder. We will also create a 50Gig volume for our mp3s.

# lvcreate vg01 -v -L 20G -n lvsales
# lvcreate vg01 -v -L 50G -n lvmp3s

Type vgdisplay vg01 again and compare the values to the previous output. Do you see about 70Gigs missing from the Free PE / Size entry?

Now that we have our 2 logical volumes, we need to format them as we would any new partition:

# mke2fs -j /dev/vg01/lvsales
# mke2fs -j /dev/vg01/lvmp3s

Notice the path to the new volume? /dev/volumegroupname/logicalvolumename

Create our new folders and mount our new space to them:

# mkdir /sales
# mkdir /mp3s
# mount /dev/vg01/lvsales /sales
# mount /dev/vg01/lvmp3s /mp3s

A verbose vgdisplay will give you all the info about your volume groups and logical volumes:

# vgdisplay -v vg01 (you may have to scroll up to see all the info)


Scenario 3: As is the norm, the sales department has outgrown their space, so in this example, we will add a new drive, and then grow the now existing lvsales logical volume by 20Gigs.

NOTE: This process is sometimes destructive!! Always perform quality backups prior to any changes to volumes or partition sizes!!!

Again, we add the new drives or LUN's per other documentation and boot up our server. We will assume we have added an additional 72Gig drive, as the first 72Gig drive was carved up into a sales volume and an mp3 volume and is now full. This will populate at /dev/cciss/c0d2 (NOTE the 2!)

We cannot resize a mounted partition, so we first unmount the sales folder, which will obviously take the data offline during this process. It is sometimes possible to extend these volumes without unmounting them, but that is not covered here.

# umount /sales

Now, lets walk through creating the new space:

Create a partition on the new drive

# fdisk /dev/cciss/c0d2

From the partitioning menu's, create a new partition spanning the entire drive.

Change the partitions system ID from its default to 8e (a Linux LV).

Save and exit the fdisk utility by pressing w.

Now we need to create a physical volume on that partition

# pvcreate -v /dev/cciss/c0d2p1

This prepares the new partition for logical volumes.

Here is the deviation from the previous scenario:

We need to extend the existing volume group (vg01) to include this new physical volume.

# vgextend -v vg01 /dev/cciss/c0d2p1

A vgdipslay -v vg01 command should now show a lot more Free PE / Size to it. Since we max’d out vg01 in the previous scenario, there should be around 72Gigs free since that is the size of the space we just added.

We now need to stretch our filesystem over our new space:

(we are sometimes forced to check out the filesystem first. Do so with:
# e2fsck –f /dev/vg01/lvsales)

Now that our vg01 contains more formated free space, let’s extend the lvsales volume by another 20Gigs.

# lvextend -v -L +20G /dev/vg01/lvsales

Now that the logical volume has been extended, we need to stretch filesystem (or format) across the new space:

# resize2fs /dev/vg01/lvsales

The above command has some options to it, however, with non indicated, resize2fs assume’s the entire space.

A quick vgdisplay –v command will show you the new space assigned to lvsales.

# mount -a will remount all the file systems in the /etc/fstab, including our /sales folder.

# df -h will list all the directory size's and free space. Our sales folder should now be 40Gigs in size and have 20Gigs free.

# vgdisplay –v vg01 should also report 20Gigs missing out of vg01, leaving around 50Gigs available (or Free).
 
Old 09-30-2005, 07:45 PM   #3
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,440

Original Poster
Rep: Reputation: 80
I have the second harddrive plugged into the same cable as the first one, so it is a primary slave. It looks like fdisk found it but the mke2fs -j /dev/hdb1 did not. What did I do wrong? I was following the directions from the first scenario.

Code:
chris@ubuntu:/usr/lib/mozilla-firefox$ sudo fdisk /dev/hdb

The number of cylinders for this disk is set to 1654.
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): help
h: 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): d
No partition is defined yet!

Command (m for help): t
No partition is defined yet!

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

Command (m for help): m
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): t
Selected partition 2
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): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
chris@ubuntu:/usr/lib/mozilla-firefox$
chris@ubuntu:/usr/lib/mozilla-firefox$ mke2fs -j /dev/hdb1
mke2fs 1.35 (28-Feb-2004)
Could not stat /dev/hdb1 --- No such file or directory

The device apparently does not exist; did you specify it correctly?
chris@ubuntu:/usr/lib/mozilla-firefox$ sudo mke2fs -j /dev/hdb1
mke2fs 1.35 (28-Feb-2004)
Could not stat /dev/hdb1 --- No such file or directory

The device apparently does not exist; did you specify it correctly?
chris@ubuntu:/usr/lib/mozilla-firefox$
 
Old 09-30-2005, 11:25 PM   #4
WhatsHisName
Senior Member
 
Registered: Oct 2003
Location: /earth/usa/nj (UTC-5)
Distribution: RHL9;F1-10; CentOS4-5; DebianSarge-Squeeze
Posts: 1,151

Rep: Reputation: 46
You created hdb2, not hdb1. To see the partition using fdisk, run:

fdisk -l

The command to make ext3 would be:

mke2fs -j /dev/hdb2
 
Old 10-01-2005, 10:41 AM   #5
debianmike
Member
 
Registered: Sep 2005
Posts: 115

Rep: Reputation: 15
yes, Whatshisname is correct. You created a second primary partition on the drive when you gave it a partition number of 2, not 1.

You can have primary partitions on 2 different drives. The partition tables for each drive are independant of each other. I suspect you assumed that the original drive would be the primary partition...this is incorrect.
 
Old 10-02-2005, 08:39 PM   #6
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,440

Original Poster
Rep: Reputation: 80
I did not know what I was doing. I thought since this is the second primary partition I will have, it needs to be 2. I understand now what I did wrong. First I mounted it to /home/chris/ then my computer had serious problems, and I had to reboot. Then I made a folder called space and mounted the new partition to it /home/chris/space, and that worked. It has a locked, so I need root for it. What is the chmod option to give everyone permissions to it?
 
  


Reply


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
installing with extra windows space Patters Linux - Newbie 2 01-31-2005 02:33 PM
need to mount extra / space Geist3 Slackware 5 01-17-2005 08:31 PM
easiest way to add an extra harddrive for /home bigfatdud Linux - Newbie 8 10-27-2004 02:32 AM
Install XP in extra space jdmml Linux - Newbie 4 08-31-2004 01:42 PM
extra hd space? adam_boz Linux - Newbie 2 10-24-2002 02:08 AM


All times are GMT -5. The time now is 07:21 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration