[kwlug-disc] Adding (setting up) 2nd disk.

john at netdirect.ca john at netdirect.ca
Tue Jan 26 10:46:04 EST 2010

kwlug-disc-bounces at kwlug.org wrote on 01/26/2010 08:39:14 AM:

> I'm setting up a kubuntu 9.10 box, 3 partitions: OS, swap, data.
> I would like /home and other good stuff, say /data, to be on the 
> second disk.
> How do I do this / what are the magic google terms?
> mount the 2nd disk as /disk2, and create /home and /data and link them 
> to /home and /data on the 2nd disk?
> Normally, one would make an entire partition as /something, like 
> /home. Here I want multiple /somethings on the second disk.
> Are there other good things that should be there too? I presume /etc 
> is right out, probably /usr too. /var?
> Good reference doc appreciated - "linux partitioning" drowns me as a 
> search term.

It a fairly subtle task and might not be searchable.

On a new install you would choose an advanced disk set up and set up 
partitions and mount points manually.

If you are retro-fitting a disk then you could do a short set of simple 
commands (assuming /dev/sdb)

1. fdisk /dev/sdb # Create partitions, if they don't already exist. Keep 
in mind any data on the disk will be lost.
2. mke2fs -j /dev/sdb1; mke2fs -j /dev/sdb2 # Create file systems.
3. Edit /etc/fstab to add the new file systems, mount then on the proper 
destinations (i.e. /home and /data)
4. mount /home; mount /data # Mount the file systems. This command will 
ensure that you fstab entries are correct.

A side task might be to temporarily mount the file systems (mkdir -p 
/mnt/tmp; mount /dev/sdb1 /mnt/tmp) and move over the data from the 
existing folder (mv /home/* /mnt/tmp). Then umount and mount on the right 
mount point (umount /mnt/tmp; mount /home) 

You might also consider using LVM instead of raw partitions. LVM allows 
you to expand file systems easily and add disks as needed. This is a 
little more complicated:

1. fdisk /dev/sdb # create one partition
2. pvcreate /dev/sdb1 # Initialize the partition as a LVM Physical Volume
3. vgcreate MyData /dev/sdb1 # Create the Volume Group named MyData
4. lvcreate -L 20G -n home MyData # Create a 20GB volume group named 
5. lvcreate -L 60G -n data MyData #Create a 60GB volume named "data"
6. mke2fs -j /dev/MyData/home; mke2fs -j /dev/MyData/data # Create file 
systems on the LVs
7. Edit /etc/fstab and add the file systems.
8. mount /home; mount /data # Mount the file systems.

When creating LVs you might want to consider leaving unallocated space. In 
other words don't assign all the disk space to LVs. Then as you use the 
file systems you will see where you need more space and you can 
re-allocate then. It's easy to add disk to an LV, it's harder to take it 

John Van Ostrand
Net Direct Inc.
564 Weber St. N. Unit 12
Waterloo, ON N2L 5C6
john at netdirect.ca
Ph: 866-883-1172
Linux Solutions / IBM Hardware
Fx: 519-883-8533

More information about the kwlug-disc mailing list