Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

moving /home to second drive

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
interior.ocean
Posts: 22
Joined: 2010-12-18 10:40

moving /home to second drive

#1 Post by interior.ocean »

Hi. I recently installed Debian (*former Windows user*) with xfce and I only aligned one partition. I have a 80gb SSD where I have the OS and apps. I just now installed a hard drive which I'm going to use for documents, pictures, music etc., but I haven't mounted it yet. I'd like to move /home to it's own partition on the second drive, and I'd like the desktop to be on the HDD also, but I don't really have any idea how to do this and haven't found any information about this (that's why I haven't mounted the HDD yet either). I'd like to keep the SSD purely as a drive for OS and apps so if there's anything else I should consider or if there's a better approach for this, please tell me as I'm a little lost right now.
Last edited by interior.ocean on 2010-12-21 09:03, edited 1 time in total.

Revenger
Posts: 382
Joined: 2010-11-16 11:47

Re: moving /home to second partition

#2 Post by Revenger »

That is not going to be hard. First, you will need to create partition dedicated to /home. (You can use gparted (gnome), kpartx (kde), fdisk + e2fstools or some other tools (if you would not like to use ext3/4 filesystem, but remember to put correct filesystem type in /etc/fstab) (console))

Do these steps as root via console.

Move old home to some other place, eg mv /home /home.old
Create empty /home directory, mkdir /home
Mount partition you intended to use as /home to its mountpoint mount /dev/sdxy /home (It may be /dev/hdxy, if using Lenny and ATA Drive).
Move all contents from /home.old to /home with mv /home.old/* /home
Add a line to /etc/fstab (nano /etc/fstab) to auto mount your new partition

Code: Select all

/dev/sdxy /home <fstype> defaults 0 0
* <fstype> is type of filesystem you created on your partition

Remove empty /home.old directory rmdir /home.old
And at last do mount -a, if there are no errors, you are good and can reboot.

And that should be it.
Next time someone says 'Go to hell' to me, I come right here.

Do you need bad help?

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: moving /home to second partition

#3 Post by llivv »

Take it one step at a time and it will be a lot easier than trying to do it all at once....
It's easy once you know how to do it, but not so easy the first time you try....

what version of debian are you using? Lenny? Squeeze?

1: see if you have gparted installed.
if it's installed, run it and tell us the device names for your hard disk and you ssd...(upper right hand corner) ie: /dev/sda
If gparted is not installed, that is the one I'd recommend with Xfce...
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

interior.ocean
Posts: 22
Joined: 2010-12-18 10:40

Re: moving /home to second drive

#4 Post by interior.ocean »

I'm using lenny (installed the latest stable version few days ago). Downloaded gparted just now. At which point should I mount the drive and add it to fstab? Right now?

/dev/hda, filesystem is ext2 (considering the purpose of this drive, is this reasonable, or should I change it to ext3?). It shows size as 465.76gb though it should be 500gb, why is this?

/dev/sda 74.53gb. Here are two partitions sda1 243.13mib (33.92 used), flags 'boot', and sda2 74.29gb flags 'lvm'. Filesystem for sda1 is ext2, for sda2 'unknown' and it gives a warning "Unable to detect filesystem". At last shut down I also notices red text that said something about logical volumes and lvm. How can I fix this?

Here's what 'fdisk -l' says:
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00068a3e

Device Boot Start End Blocks Id System
/dev/sda1 * 1 31 248976 83 Linux
/dev/sda2 32 9729 77899185 8e Linux LVM

Disk /dev/hda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2ceebebf

Device Boot Start End Blocks Id System
/dev/hda1 1 60801 488384001 83 Linux

Disk /dev/dm-0: 76.4 GB, 76470550528 bytes
255 heads, 63 sectors/track, 9297 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 3296 MB, 3296722944 bytes
255 heads, 63 sectors/track, 400 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-1 doesn't contain a valid partition table

User avatar
BioTube
Posts: 7520
Joined: 2007-06-01 04:34

Re: moving /home to second drive

#5 Post by BioTube »

It's expected that the reported size is less than the advertised size; manufacturers use powers of ten to determine sizes while software uses powers of two(eg, a gigabyte is 1000 megabytes according to the box, but 1024 to software).
Image
Ludwig von Mises wrote:The elite should be supreme by virtue of persuasion, not by the assistance of firing squads.

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: moving /home to second drive

#6 Post by llivv »

You now have a choice...
Do you still want to mount the new disk .
Or do you want to fix the LVM issue first...
If you want to work on the LVM issue first, I'd recommend starting a new thread for it.
You could come back to this one after you fix the other issue...
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

interior.ocean
Posts: 22
Joined: 2010-12-18 10:40

Re: moving /home to second drive

#7 Post by interior.ocean »

I'm ready to mount the disk and move home there. How should I go about doing it?

User avatar
saulgoode
Posts: 1445
Joined: 2007-10-22 11:34
Been thanked: 4 times

Re: moving /home to second partition

#8 Post by saulgoode »

Revenger wrote:That is not going to be hard. First, you will need to create partition dedicated to /home. (You can use gparted (gnome), kpartx (kde), fdisk + e2fstools or some other tools (if you would not like to use ext3/4 filesystem, but remember to put correct filesystem type in /etc/fstab) (console))

Do these steps as root via console.

Move old home to some other place, eg mv /home /home.old
Create empty /home directory, mkdir /home
Mount partition you intended to use as /home to its mountpoint mount /dev/sdxy /home (It may be /dev/hdxy, if using Lenny and ATA Drive).
Move all contents from /home.old to /home with mv /home.old/* /home
Add a line to /etc/fstab (nano /etc/fstab) to auto mount your new partition
This is basically a sound advice, however, the manner in which you've chosen to move the old contents to the new location (shown in italics) will ignore hidden files in the topmost directory (/home.old). This should not be a problem in this case because /home doesn't typically contain any hidden files or subdirectories (and hidden files in the users' directories will be properly moved).

Nonetheless, one way to be sure that hidden files are handled in the topmost directory (should they exist) would be to use 'tar':
  • cd /home.old
    tar c . | tar xC /home
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan

interior.ocean
Posts: 22
Joined: 2010-12-18 10:40

Re: moving /home to second drive

#9 Post by interior.ocean »

I've partitioned and formatted the HDD already, but I haven't mounted it yet. In this case should I just do it like Revenger instructed or should I mount the drive first, and are there anything else I should do? And should I just remove the home.old afterwards? I'm not familiar with these things as I'm new to Linux and I've never installed new drives before.

User avatar
saulgoode
Posts: 1445
Joined: 2007-10-22 11:34
Been thanked: 4 times

Re: moving /home to second drive

#10 Post by saulgoode »

interior.ocean wrote:I've partitioned and formatted the HDD already, but I haven't mounted it yet. In this case should I just do it like Revenger instructed or should I mount the drive first, and are there anything else I should do?
GNU/Linux offers a great deal of flexibility in configuring your filesystem setup, and everyone has there own ideas of what approach is best. As for me, I would not partition a 500Gb HDD as a single partition, but instead divide it into four different partitions.

20Gb or so for installing a second OS
300Gb for /home
180Gb for /pub -- a "public" directory for files shared between users
1Gb for SWAP

Even if you don't plan on running two OSes, having a partition available for installing a second OS can be helpful when it comes time to upgrade Debian to the next release. When I upgrade my system, I will typically install the new release onto its own partition; and retain my original system so that I can gradually migrate things over.

I use a /pub partition even though I am the only user of my machine (though I do log into different accounts for different purposes). Having the bulk of your drive split into two parts (/home and /pub) can also prove useful if you later decide to switch to a different filesystem. For example, if you want to switch /home from EXT3 to EXT4 (or, eventually, BTRFS) then you could copy all of the files to /pub and reformat the /home partition, then move them back.

You didn't mention a SWAP (or at least I missed it if you did) but I think you should include some just in case. Linux will make use of multiple swap partitions if available, doubling the speed if they are on different drives.
And should I just remove the home.old afterwards? I'm not familiar with these things as I'm new to Linux and I've never installed new drives before.
Yes. Once you have moved everything from /home.old directory to /home (remember to update /etc/fstab to mount the new partition), you can delete the /home.old directory.
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan

interior.ocean
Posts: 22
Joined: 2010-12-18 10:40

Re: moving /home to second drive

#11 Post by interior.ocean »

It's still a little unclear if I should mount the drive before doing anything else or not. Ext3 and ext4 are being mentioned a lot. Both my SSD and HDD are currently ext2. Is it ok or should I change them to ext3? And how exactly should fstab be edited?
Mount partition you intended to use as /home to its mountpoint mount /dev/sdxy /home (It may be /dev/hdxy, if using Lenny and ATA Drive).
What exactly would I be doing here? Moving home to it's own partition and mounting the hard drive (or should it be mounted earlier)? If the partition on the drive I'm going to use for /home is hda1 do I just type in "mount /dev/sdxy /home"? There are no hidden files in the home directory.

Excuse me for asking such perhaps obvious questions. I just started reading Linux/Debian beginner guides and looking for some good book so I'm still a bit clueless about all this.

User avatar
saulgoode
Posts: 1445
Joined: 2007-10-22 11:34
Been thanked: 4 times

Re: moving /home to second drive

#12 Post by saulgoode »

interior.ocean wrote:It's still a little unclear if I should mount the drive before doing anything else or not.
The sequence should be:
  • Partition your hardrive
  • Format each of the partitions. In Unix terminology, you "make a filesystem on the partition" and this is done with the 'mkfs' command for normal partitions and the 'mkswap' command for SWAP partitions.
  • Mount the filesystem.
  • Move files to the mounted filesystem.
  • Edit /etc/fstab so that the filesystem will automatically be mounted when you boot the computer.
interior.ocean wrote:Ext3 and ext4 are being mentioned a lot. Both my SSD and HDD are currently ext2. Is it ok or should I change them to ext3?
You can leave it as EXT2 for now and later convert it to EXT3 or EXT4 (without having to reformat).
interior.ocean wrote:And how exactly should fstab be edited?
You will want to add a line to fstab with something such as the following:

/dev/hda1 /home ext2 defaults,noatime 1 2

The first field is the partition, the second is the directory to mount it on, followed by the filesystem type, the mount options, and finally a couple of system options. This is all explained in greater detail in the 'man fstab' page.
interior.ocean wrote:
Mount partition you intended to use as /home to its mountpoint mount /dev/sdxy /home (It may be /dev/hdxy, if using Lenny and ATA Drive).
What exactly would I be doing here? Moving home to it's own partition and mounting the hard drive (or should it be mounted earlier)? If the partition on the drive I'm going to use for /home is hda1 do I just type in "mount /dev/sdxy /home"? There are no hidden files in the home directory.
Your understanding of Revenger's instructions seems correct. Since there are no hidden files, there is no problem with using his approach.

Just to be clear on things, just before moving the files, you will mount the partition manually. This means your files will be copied from their original folder to their new location on your new harddrive (if you didn't mount the partition, the files would just be copied to the 'home' directory on the '/' partition).

Once your /home directory (on the new partition) has all of the users' folders, you can safely log in as one of those users. Remember, up until now you have been running as 'root' and you may have noticed that root's home directory is /root, and NOT under /home/ -- this is why you could do all this manipulation while running under Debian (Gparted isn't necessary). If you tried to do this while logged in as a regular user, you could run into problems with files you are trying to move being 'in-use'.

The only thing left to take care of is to make sure that mounting /home -- which you've done manually -- is to be done automatically every time you start your computer. This is why you must edit /etc/fstab (you could boot up and log in as root, and then manually mount /home every time you use your computer; but that would quickly grow somewhat tedious :) ).
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan

interior.ocean
Posts: 22
Joined: 2010-12-18 10:40

Re: moving /home to second drive

#13 Post by interior.ocean »

This cleared up the process a lot. One more thing about mounting the drive though. According to the instructions I used to install the drive I should mount the drive like this:

Code: Select all

mkdir /new-disk
mount -t ext3 /dev/hdc1 /new-disk
So should I do that first to mount the drive? I was going to do that just now but not sure if it overlaps with Revenger's instructions somehow. What's the purpose of "mkdir /new-disk"? Does it overlap with "mkdir /home"?

EDIT: so here instead should I do:

Code: Select all

mkdir /home
mount -t ext2 /dev/hda1 /home
after moving the old home directory.

EDIT2: what got me wondering here is the 'sdxy' or 'hdxy', which I didn't really understand, but I assume I just need to type 'hda1' instead. But then that '-t' in mounting the drive goes past me. In some instructions it's included, in some it's not. I even saw one with a different letter there. What's it's purpose, really? Am doing it right if I follow Revenger's instructions otherwise, but mount the drive with "mount -t ext2 /dev/hda1 /home" as stated in the last edit?

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: moving /home to second drive

#14 Post by llivv »

interior.ocean wrote: According to the instructions I used to install the drive I should mount the drive like this:
could you give us a link to those instructions....
We are explaining things in a different way than the instructions you are reading elsewhere... I think you may have already figured that out....
interior.ocean wrote:

Code: Select all

mkdir /new-disk
mount -t ext3 /dev/hdc1 /new-disk
So should I do that first to mount the drive? I was going to do that just now but not sure if it overlaps with Revenger's instructions somehow. What's the purpose of "mkdir /new-disk"? Does it overlap with "mkdir /home"?
No, mkdir /new-disk is on your ssd - mkdir /home would fail because you already have a /home directory.. to see your current home directory use the command

Code: Select all

 ls /
You could substitute mkdir old-home instead of mkdir new-disk
interior.ocean wrote:EDIT: so here instead should I do:

Code: Select all

mkdir /home
mount -t ext2 /dev/hda1 /home
after moving the old home directory.
No, the new-partition needs to be mounted before you can move old-home onto it..
So remember,

Code: Select all

mkdir /new-disk
is where you mount new-disk (hda1) using the mount command..

Code: Select all

mount -t ext2 /dev/hda1 /new-disk
interior.ocean wrote:EDIT2: what got me wondering here is the 'sdxy' or 'hdxy', which I didn't really understand, but I assume I just need to type 'hda1' instead. But then that '-t' in mounting the drive goes past me. In some instructions it's included, in some it's not. I even saw one with a different letter there. What's it's purpose, really? Am doing it right if I follow Revenger's instructions otherwise, but mount the drive with "mount -t ext2 /dev/hda1 /home" as stated in the last edit?
sdxy is a variable describing the disk partitions
"in your case" sdxy translates to sda1
but in another case the variable could mean sda2 or sdb3
and hdxy translates "in your case" to hda1
but in another case the variable could mean hdc6 or hdd2

the -t option is the type of filesystem - in your case ext2
so
mount -t ext2
means mount filesystem type ext2

now check /etc/mtab to make sure /dev/hda1 is mounted on /new-disk directory

Code: Select all

 cat /etc/mtab
and move /home to new-disk

Code: Select all

 mv /home /new-disk
.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

interior.ocean
Posts: 22
Joined: 2010-12-18 10:40

Re: moving /home to second drive

#15 Post by interior.ocean »

The instructions I've followed until the mounting part: http://linux.justinhartman.com/Installi ... hard_drive.
llivv wrote: No, mkdir /new-disk is on your ssd - mkdir /home would fail because you already have a /home directory..
That would be after I've moved the old home directory away and created a new one, according to Revenger's instructions. Should I not follow those after all? Sorry, I'm getting a bit confused with so many different instructions. Can I move the directory to the hard drive like that without moving the old home away and creating a new home which I'd move to the hard drive and move contents of the old one to the new and remove the old one?

So is making the "new-disk" directory not making a partition called "new-disk" for the hda1? I want home partition on hda1.

So as root I should just do this:

Code: Select all

mkdir /home
mount -t ext2 /dev/hda1 /home
mv /home /new-disk
and I would have hda1 mounted and have /home partition on it?

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: moving /home to second drive

#16 Post by llivv »

Revenger wrote:First, you will need to create partition dedicated to /home. (You can use gparted (gnome), kpartx (kde), fdisk + e2fstools or some other tools (if you would not like to use ext3/4 filesystem, but remember to put correct filesystem type in /etc/fstab) (console))

Do these steps as root via console.

Move old home to some other place, eg mv /home /home.old
Create empty /home directory, mkdir /home
Mount partition you intended to use as /home to its mountpoint mount /dev/sdxy /home (It may be /dev/hdxy, if using Lenny and ATA Drive).
Move all contents from /home.old to /home with mv /home.old/* /home
Add a line to /etc/fstab (nano /etc/fstab) to auto mount your new partition

Code: Select all
/dev/sdxy /home <fstype> defaults 0 0
I wasn't paying attention...
First, you will need to create partition dedicated to /home.
You already did this it's hda1
Do these steps as root via console.

Move old home to some other place, eg mv /home /home.old
Create empty /home directory, mkdir /home
Mount partition you intended to use as /home to its mountpoint

Code: Select all

mount -t ext2 /dev/hda1 /home

Move all contents from /home.old to /home with

Code: Select all

mv /home.old/* /home
Add a line to /etc/fstab (nano /etc/fstab) to auto mount your new partition

Code: Select all

   /dev/hda1  /home  ext2    defaults     1     0 
Remove empty /home.old directory

Code: Select all

rmdir /home.old
And at last do

Code: Select all

mount -a
, if there are no errors, you are good and can reboot.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

User avatar
saulgoode
Posts: 1445
Joined: 2007-10-22 11:34
Been thanked: 4 times

Re: moving /home to second drive

#17 Post by saulgoode »

interior.ocean wrote:So is making the "new-disk" directory not making a partition called "new-disk" for the hda1? I want home partition on hda1.

So as root I should just do this:

Code: Select all

mkdir /home
mount -t ext2 /dev/hda1 /home
mv /home /new-disk
and I would have hda1 mounted and have /home partition on it?
Your wording is a little bit backwards. /home is a subdirectory on the / filesystem. You want to mount the filesystem that exists on partition /dev/hda1 onto the /home subdirectory.

This is similar to how you mount a CD-ROM. There is a subdirectory on the root filesystem called /mnt/cdrom (or perhaps /media/cdrom). That subdirectory is typically empty but when you put a CD in the drawer and mount the CD (/dev/cdrom), the filesystem on the CD will become accessible by using /mnt/cdrom. If there were already files in the /mnt/cdrom before you mounted the CD, you would not be able to access those files (until you unmounted the CD).

You could just as easily mount your hda1 partition (i.e., the filesystem that exists on hda1) onto /mnt/cdrom and access all of its files using /mnt/cdrom. Similarly, if you had a directory on your root filesystem called /pub, you could readily mount /dev/hda1 onto /pub.

The only difference with what you're doing is that you want to mount the filesystem on hda1 to the directory /home (this is called the "mount point") and /home already contains a bunch of files and subdirectories. You could actually just go ahead and mount hda1 onto /home without taking any other action but then you would not be able to access any of the files that previously exist in /home. Because you want to have those files accessible, you need to relocate them to the filesystem on /dev/hda1.

There's actually two different ways to do this (the text after the octothorpe is comments and not part of the command).

Code: Select all

mkdir /pub -p   # the -p option says to ignore the command if /pub already exists
mount /dev/hda1 /pub  # Linux will automatically detect the EXT2 filesystem
mv /home/* /pub # this will work fine since there are no hidden files in /home
umount /pub # unmount the hda1 filesystem
mount /dev/hda1 /home # mount it back to where you want it
OR (as Revenger originally described):

Code: Select all

mv /home /home.old  # basically rename the directory
mkdir /home # create a new /home (mount point)
mount /dev/hda1 /home 
mv /home.old/* /home # now the files will be copied over to the hda1 filesystem
rmdir /home.old # this directory is no longer needed
The end result is the same: all of the files and subdirectories on hda1 will be accessible through /home
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian Kernighan

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: moving /home to second drive

#18 Post by llivv »

other instructions wrote: Introduction

Installing a second hard drive is easy if you know how. I needed to do this on my server and below is the steps I followed.
Assumptions

* I assume that you have installed the hard drive in your PC, and
* That you have rebooted your machine
* In this example our primary hard drive is located at /dev/hda and our second, new hard drive is located at /dev/hdc (replace according to your system)

Installation

The first step is to check to see that your new hard drive is installed and picked up by Debian. You do this by running the following command in a shell:

fdisk -l

This will give you an output that should look something like this:

Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 9354 75135973 83 Linux
/dev/hda2 9355 9729 3012187 5 Extended
/dev/hda5 9355 9729 3012156 82 Linux swap / Solaris

Disk /dev/hdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

You can see that the 500GB disk at /dev/hdc is being picked up but there are no partitions yet for this drive.
Partitioning your new drive

Next up we need to partition our drive with the following:

cfdisk /dev/hdc

The cfdisk controller will load up and here you can create a new partition on your drive. From the menus at the bottom I selected the following:

1. New >> Primary >> Size in MB
2. Once done select Write
3. Select Quit

Your new partition has been created at /dev/hdc1
Format the new disk

Now that we have a new partition at /dev/hdc1 we need to format it for usage by the system. From a Linux shell type:

mkfs.ext3 /dev/hdc1

This will now format our partition with the ext3 filesystem which should work fine for your Debian system.
Mount your new drive

Now that we have partitioned the drive and formatted it we can now mount the drive to begin using it. From a shell run:

mkdir /new-disk
mount -t ext3 /dev/hdc1 /new-disk

The above commands create a new directory for the drive to be mounted in and then we mount the drive to this directory. To check that the drive has been mounted run the following:

ls -lsa /new-disk

You should see the following:

root@debian:/# ls -lsa /new-disk
total 24
4 drwxrwxrwt 3 root root 4096 2007-01-29 01:57 .
4 drwxr-xr-x 22 root root 4096 2007-01-29 01:58 ..
16 drwx------ 2 root root 16384 2007-01-29 01:57 lost found

Adding to fstab

Everything is now up and running however we need to add our new drive to /etc/fstab so that it will be mounted automatically when we reboot the machine.

First let's edit fstab:

vim /etc/fstab

At the end of the file add the following line:

/dev/hdc1 /new-disk ext3 defaults,errors=remount-ro 0 1

Save the file and you're done.
I'll try to condense these instructions so you can compare....
The first step is to run the following command in a shell:

Code: Select all

fdisk -l
Here's what 'fdisk -l' says:
fdisk -l wrote: Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00068a3e

Device Boot Start End Blocks Id System
/dev/sda1 * 1 31 248976 83 Linux
/dev/sda2 32 9729 77899185 8e Linux LVM

Disk /dev/hda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x2ceebebf

Device Boot Start End Blocks Id System
/dev/hda1 1 60801 488384001 83 Linux

Disk /dev/dm-0: 76.4 GB, 76470550528 bytes
255 heads, 63 sectors/track, 9297 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 3296 MB, 3296722944 bytes
255 heads, 63 sectors/track, 400 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-1 doesn't contain a valid partition table
Next up we need to partition our drive with the following:
already done...
Your new partition has been created at /dev/hda1
Format the new disk
already done

Edit
Now that we have partitioned the drive and formatted it we can now mount the drive to begin using it.
Instructions for moving /home to new hard disk belong here.
Now that we have partitioned the drive and formatted it (Edit: "and moved the /home directory to the new disk: ) we can now mount the (Edit: "new disk at the /home mountpoint":) and begin using it:.
From a shell run:

Code: Select all

mkdir /home

Code: Select all

mount -t ext2 /dev/hda1 /home
The above commands create a new directory for the drive to be mounted in and then we mount the drive to this directory. To check that the drive has been mounted run the following:

Code: Select all

ls -lsa /home
You should see the following:

Code: Select all

root@debian:/# ls -lsa /home
total 24
 4 drwxrwxrwt  3 root root  4096 2007-01-29 01:57 .
 4 drwxr-xr-x 22 root root  4096 2007-01-29 01:58 ..
16 drwx------  2 root root 16384 2007-01-29 01:57 lost found 
Adding to fstab:
Everything is now up and running however we need to add our new drive to /etc/fstab so that it will be mounted automatically when we reboot the machine.
First let's edit fstab:

Code: Select all

vim /etc/fstab
At the end of the file add the following line:

Code: Select all

/dev/hda1       /home            ext2    defaults,errors=remount-ro 0       1

Save the file and you're done.
Last edited by llivv on 2010-12-24 11:30, edited 1 time in total.
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: moving /home to second drive

#19 Post by llivv »

I think the main reason you got confused is because you asked to have us explain how to move home to the new disk
instead of just asking us first how to add the new disk to your system... like the other instructions describe.
So you got four different sets of directions for adding the new disk to your system
and three different sets of instructions for moving your /home/directory to that new disk....
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.

interior.ocean
Posts: 22
Joined: 2010-12-18 10:40

Re: moving /home to second drive

#20 Post by interior.ocean »

You're right. Since I had so many different instructions and didn't really understand what all the commands did I just got confused. But in the end all went well and now the disk is partitioned. It didn't take this long, but I haven't had access to internet on my computer for a while I haven't been able to come here.

Thank you all for your help.

Post Reply