Книга: Fedora™ Unleashed, 2008 edition

Mounting the New Partition and Populating It with the Relocated Files

Mounting the New Partition and Populating It with the Relocated Files

For the example that follows, it is assumed that /home was a directory that was part of the partition mounted at /, not a separate partition to begin with.

Here, we create a temporary mount point and mount the new partition:

# mkdir /mnt/newpartition
# mount -t ext3 /dev/hdb1 /mnt/newpartition

It is now time to copy all the files from /home to /mnt/newpartition. It is important that we preserve the time and date stamps for the files and the permissions. We're copying entire directories and subdirectories, so we use the one of three basic copying methods (tar, cpio, or cp) that best accommodates this:

# cp -a /home/* /mnt/newpartition

We need to modify /etc/fstab so that the new ext3 partition will be mounted correctly:

/dev/hdb1 /home ext3 defaults 1 2

Here, we have chosen to use the default mount options for the ext3 partition. The defaults are identical to those for the ext2 file system, and additionally selects the default data=ordered journaling mode.

Anytime we reboot, the new partition containing the copied files will automatically be mounted at /home. But before we do that, we must cd to /home and enter this:

# touch thisistheoldhomepartition

Now we can mount the new partition:

# umount /mnt/newpartition
# mount /dev/hdb1 /home

Note that if you enter:

# ls -al /home

you will not see the thisistheoldhomepartition file we created with the touch command. So, what happened to the old files? They are still there, but just hidden because we mounted a directory "over" them. When we are satisfied that all is well, we can unmount the newly created home partition and delete the files in the partition that contains the thisistheoldhomepartition file.

TIP

You can use the previously explained technique as a placeholder or warning for any temporarily mounted file system so that you do not mistakenly think that the file system is mounted when it is not.

Оглавление книги


Генерация: 1.244. Запросов К БД/Cache: 3 / 1
поделиться
Вверх Вниз