• Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding new disk drive  RSS feed

 
himanshu patel
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am having 40GB disk drive. Now it is full and i want to add
one new hard disk drive. I want to allocate half disk space
of new drive to existing /home area and rest half space to existing
/usr area without affecting data.
Can someone guide me how i can do it.
I am having Redhat 8.0.
Thanks
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Last time I checked, linux does not allow a partition to span more than one disk natively. The only way I can think of is by using LVM (logical volume manager).
 
Tim Holloway
Saloon Keeper
Posts: 18800
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LVM is a way to expand disk space transparently, but it's also possible to farm out most of the filesystem as well using softlinks.
For example, if you're created a volume and mounted it under /diskb:
mv -ar /home /diskb/ ;# move the /home directories under /diskb
ln -s /diskb/home /home ;# link /home to their new, um, "home"
This is best done while in single-user mode logged in as root. Backing up first ih HIGHLY recommended!
 
himanshu patel
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I configure LVM anytime or I have to configure at Installation time only? If I just add one new hard disk and reboot the server, will linux
recognize it? Do i need to modify /etc/fstab ?
 
himanshu patel
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could not find command lvm? Does it mean that LVM is not installed?
How can i installed now ? However, I found these commands,
lvmchange
lvmcreate_initrd
lvmdiskscan
lvmsadc
lvmsar
 
Alton Hernandez
Ranch Hand
Posts: 443
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've been in this situation before a few times. My machine have drives with small capacity. And everytime they are full, I keep on adding new ones. Now, I have 5 of them. Everytime this happens, I keep on moving directories and partitions around.
Anyway, I would suggest the following actions:
1. Create the 2 partitions in your new drive.
2. Mount them in a temporary directory, usually, under /mnt:
e.g. (assuming your new drive is in hdb)
mount /dev/hdb1 /mnt/drv1
mount /dev/hdb2 /mnt/drv2
3. Copy your files from /home and /usr to these directories
e.g.
cp -a /home/* /mnt/drv1
cp -a /usr/* /mnt/drv2
I would not suggest moving (mv) the files.
4. Rename your /home and /usr to another name
e.g.
mv /home /home.bak
mv /usr /usr.bak
5. Mount your new partitions to these two directories. Make sure you create them first. (You also need to modify your /etc/fstab)
mkdir /home
mount /dev/hdb1 /home
mkdir /usr
mount /dev/hdb2 /usr
6. If everything else is OK, you can then delete your /home.bak and /usr.bak. Then that would freeup your old drive for more space.
Hope this helps.
[ March 25, 2004: Message edited by: Alton Hernandez ]
 
himanshu patel
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Alton,
It would definately help me.Can i ask you for little more guidance?
I understood all the steps you mentioned .However I need little more help from you.

1) How to reach step 1?
If i simply add new disk and reboot, will system recognize automatically as hdb)?
How can i create the partion on new drive? I guess i have to use fdisk.
2)During this process , is there any risk of lossing data?
3)At step 5, what i should modify in fstab?
I have this in fstab.
LABEL=/home /home ext3 defaults 1 2
LABEL=/usr /usr ext3 defaults 1 2
Thanks again.
 
Alton Hernandez
Ranch Hand
Posts: 443
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) How to reach step 1?

First of all, you have to physically connect your hard drive. If I am not mistaken, the way linux identifies your drive depends on which controller you connect your drive (I am assuming IDE drives here). So for 'IDE1' master drive, it is hda, 'IDE1' slave drive, it's hdb and so on. So assuming that you only have one drive now that is connected to 'IDE1', and your new drive will be connected to 'IDE1' slave, then it will be called hdb.
If i simply add new disk and reboot, will system recognize automatically as hdb)?

Linux should be able to recognize it automatically. Check your log files to see if it did
How can i create the partion on new drive? I guess i have to use fdisk.

Yes, you use fdisk to partition your drive but I actually like using cfdisk instead because its menu driven. However, RH8 may not have it. To get it, I have to modify and rebuild the util-linux package from which fdisk. It is actually there but they commented it. But that is another story. I guest in your case you are stuck with fdisk
MAKE SURE THAT WHEN YOU USE fdisk THAT YOU ARE POINTING TO THE RIGHT DRIVE
Also, don't forget to initialize your filesystem using mkfs. In fdisk, you can specify what will be the file system of your partition but that doesn't mean the structure will be created once you exit. So that is why you need to call mkfs or whatever utilities that will create a filesystem.
At this point, you may want to experiment with other filesystems like ext3 or reiserfs.
2)During this process , is there any risk of lossing data?

NO risk. You are just mounting your new partitions to an empty directory. It would not even erase your data if you mount it on a directory that contain files.
3)At step 5, what i should modify in fstab?

You can put this in your /etc/fstab assuming your filesystem is ext2.

Lastly, I would suggest that you TEST your system first before you delete your backups (/home.bak & /usr.bak)
Hope this helps.
[ March 26, 2004: Message edited by: Alton Hernandez ]
 
Tim Holloway
Saloon Keeper
Posts: 18800
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by himanshu patel:

2)During this process , is there any risk of lossing data?
Thanks again.

Yes. If you're as sloppy as I am, sooner otr later you'll mis-type something and accidently clobber /dev/hdb1 when you meant /dev/hbc1 or something like that.
Which is why it's important to have external backups!
As long as you type everything exactly correct, the only data you'll lose is whatever garbage was in the disk partition before you began to create a new, clean filesystem.
Of course, I'm assuming you think what was there before was garbage. If it was important, it should have been backed up first.
 
Alton Hernandez
Ranch Hand
Posts: 443
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by himanshu patel:
Thanks a lot Alton,
2)During this process , is there any risk of lossing data?

Ok, I misread this statement. I thought you are talking about Step 2 and not the whole process.
So YES, there is always a danger when you move/delete files or initialize hard drives.
[ March 26, 2004: Message edited by: Alton Hernandez ]
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think fdisk is very easy to use. Should not scare anybody.
After you cable up the new disk, power up, then do:
fdisk -l /dev/hdb
This will give you a very fast indication of the drive status (could be /dev/hdc or /dev/hdd, depends on cabling/jumpers/BIOS).
Guy
 
himanshu patel
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much all buddies for your all valuable step by step guidance. Now i feel very comfortable to add disk. Thanks again.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!