LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to resize the partition? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-resize-the-partition-4175459730/)

PhillipHuang 04-26-2013 08:45 PM

How to resize the partition?
 
Hello folks,

I use an old 80G HDD(/dev/sdb1) as following:
Code:

# mkfs.ext3 /dev/sdb1
# mount /dev/sdb1 /mnt/c


Now I installed another 2T SATA HDD(/dev/sdc), and I want '/mnt/c' would contains /dev/sdb1 and /dev/sdc. I dont want to remove the data of former /dev/sdb1, is there any method to do this?

Thanks,

Phillip

Erik_FL 04-26-2013 11:28 PM

The simple answer is no. You cannot easily combine a large second hard disk with a smaller existing formatted hard disk.

You can do something like this.

Code:

mount /dev/sdb1 /mnt/c
mount /dev/sdc1 /mnt/c/largedisk

Or you can do this.

Code:

mount /dev/sdc1 /mnt/c
mount /dev/sdb1 /mnt/c/smalldisk

You can also make any folders of the large disk appear on the small disk like this.

Code:

mount /dev/sdb1 /mnt/c
mount /dev/sdc1 /mnt/d
mount --bind /mnt/d/afolder /mnt/c/afolder
mount --bind /mnt/d/folder1 /mnt/c/folder2/folder3

In the above example, the folder "/mnt/c/afolder" will actually store files in the folder "afolder" on "/dev/sdc1". The folder "/mnt/c/folder2/folder3" will actually store files in the folder "folder1" on "/dev/sdc1". The problem with this approach is that you have to add these "bind" mounts in the "/etc/fstab" file or type the commands in after every boot.

If you are willing to reformat /dev/sdb1 and /dev/scd1 then you can use the Logical Volume Manager to combine the two disks and make them appear as one larger disk. I don't recommend doing that because it makes data recovery difficult if one of the drives fails.

You are better off to just copy the data from the smaller drive to the larger drive and re-use the smaller drive.

Code:

mount /dev/sdc1 /mnt/c
mount /dev/sdb1 /mnt/hd
cp -a /mnt/hd/* /mnt/c
umount /mnt/hd

That will give you a larger "/mnt/c" file-system. You can reformat the 80G HDD after copying the files to the larger disk.

The "mount" command can mount a hard disk or folder anywhere, not just under the "/mnt" directory. You have to create an empty directory (mount point) ahead of time.

Code:

mkdir /mydisk
mount /dev/sdc1 /mydisk
mkdir /home/phillip/smalldisk
mount /dev/sdb1 /home/phillip/smalldisk

Usually you want to add these kinds of mounted disks to "/etc/fstab" so that they are always mounted on boot. The "/mnt" directory is usually for temporarily mounted file-systems.


All times are GMT -5. The time now is 12:55 AM.