Difference between pages "Welcome" and "Partitioning in Action, Part 1"

(Difference between pages)
 
 
Line 1: Line 1:
<div class="container" style="font-family: Open Sans; font-size: 14px; line-height: 20px;"><div class="row"><div class="col-xs-12 col-md-8 col-lg-8">
+
{{Article
{{Slideshow}}
+
|Subtitle=Moving /home
Want to submit a screenshot? [http://forums.funtoo.org/index.php?/topic/180-screenshots/ See here.]
+
|Summary=In this new series of tips, Daniel Robbins shows you how to change partition layout on a running system. He'll also cover several tricks of the trade to minimize downtime and avoid making costly mistakes. In this particular tip, he'll show you how to move /home to another partition.
</div><div class="col-xs-12 col-md-4 col-lg-4">
+
|Author=Drobbins
'''Funtoo Linux''' is a Linux-based operating system that is a variant of [http://www.gentoo.org Gentoo Linux], led by [[User:Drobbins|Daniel Robbins]], the creator and former Chief Architect of [http://en.wikipedia.org/wiki/Gentoo_Linux Gentoo Linux], who serves as benevolent dictator for life (BDFL) of the project. ''Funtoo Linux is optimized for the best possible performance, supporting Intel Core i7, AMD FX Processors, and others.''  [[Subarches|See what we support.]] See [[#Distinctives|Distinctives]], below, for more information about what makes Funtoo Linux special.
+
|Next in Series=Partitioning in Action, Part 2
 +
}}
 +
== Introduction ==
  
<div class="bs-callout bs-callout-warning">
+
The partition /home is one of the most-often-moved partitions. Sometimes, all the space in /home becomes exhausted, and an additional hard drive is required. Other times, /home is set up as part of the root partition, and it may need to be moved to improve performance or facilitate backup. Whatever the case, I'll show you how to move /home safely and efficiently.
[[Support Funtoo]] to help us grow! '''Donate $15 per month and get a free [[Funtoo Hosting|Funtoo Virtual Container]].'''
+
</div>
+
=== News ===
+
{{NewsList|1}}
+
[[News|View More News...]]
+
</div>
+
</div><div class="row">
+
<div class="col-xs-12 col-md-4 col-lg-4">
+
=== Resources ===
+
'''View the [[Funtoo Linux FAQ]] for answers to common questions.'''
+
  
{{#ask: [[Category:People]] [[Gravatar MD5::+]]
+
{{Warning|The following technique describes how to move a partition(s). Although this technique is designed so that you can "back out" of a failed partition move, it doesn't protect against user error. In other words, any time that you format partitions or copy large numbers of files, there's a possibility that you will type the wrong thing, causing lots of data to be destroyed. For this reason, it's highly recommended that you take appropriate steps to back up all critical files before proceeding.}}
| limit=22
+
| order=random
+
| format=template
+
| template=GravatarDisplay
+
| link=none
+
| searchlabel=
+
}}
+
  
Join us - {{CreateAccount}}, and then add yourself to our [[Usermap]]!
+
Now that you're prepared, we're ready to start moving /home. The exact steps you will take depend on whether /home currently resides on its own separate partition, or whether it is located on the root partition. Keep this in mind as we go through the steps (I'll make notes where necessary). Right now, if you are moving /home to a new hard drive, it should be physically installed in your system.
  
'''Our resources:''' -- also see the <code>Go</code> menu:
+
If you are moving /home to an existing partition (it doesn't need to be ext2, as long as the target primary or extended partition exists), skip this step.
* '''{{CreateAccount}}''' ([[Funtoo Authentication FAQ|Auth FAQ]])
+
* '''[http://forums.funtoo.org forums.funtoo.org]''' - our new forums!
+
* '''[http://bugs.funtoo.org bugs.funtoo.org]''', our bug tracker ([[Reporting Bugs|Instructions]]).
+
* [http://larrythecow.org larrythecow.org], Gentoo blog service.
+
* [http://kernel-seeds.org kernel-seeds.org], kernel build help.
+
* [http://git.funtoo.org git.funtoo.org], our cgit repository browser.
+
* '''[[Support Funtoo]]''' to help our project grow.
+
* '''[[Funtoo Hosting|Get a Funtoo Virtual Container]]'''.
+
  
'''Ebuild pages recently updated:''' {{#ask: [[Category:Ebuilds]]
+
== Create a new partition, if necessary ==
| order=descending
+
| sort=Modification date
+
| format=list
+
| limit=10
+
| searchlabel=more...
+
}}
+
</div><div class="col-sm-12 col-xs-12 col-md-4 col-lg-4">
+
=== Getting Started ===
+
  
We encourage you to '''[[Funtoo Linux Installation|install Funtoo Linux]]''', and get involved in our user community. Get to know fellow Funtoo Linux users on our '''[http://forums.funtoo.org forums]'''. If you have any improvements or find any bugs in Funtoo Linux, you are strongly encouraged to report them on our '''[http://bugs.funtoo.org bug tracker]'''. We take all bugs seriously, and all work performed on Funtoo Linux is tracked on our bug tracker, for purposes of transparency.
+
If the new partition doesn't exist yet, you'll need to create it using cfdisk (preferred) or fdisk. If the partition doesn't reside on your first drive, remember to specify the name of the device as the first argument to cfdisk or fdisk. After creating the appropriate primary or extended partition, you should reboot so that the partition table can be reread correctly. This is the only time you will need to reboot the system.
  
Funtoo Linux has a very active [http://en.wikipedia.org/wiki/IRC IRC] community on Freenode, in the <code>#funtoo</code> channel, and you are encouraged to hang out online with us.
+
==  Create a filesystem on the new partition ==
  
=== Expand the wiki! ===
+
To create a filesystem on the new partition, first make sure you know the exact device name for the new partition (for example, /dev/sda5). If you're not sure of the exact device name, stop now and double-check! Then type the following, as root:
  
The [[:Help:Funtoo_Editing_Guidelines | How to 'wiki']] will help get you started on wiki editing. Have a look at [[Requested-Documents]] and [[:Category:Needs_Updates | pages that need to be updated.]]
+
<console>
 +
# ##i##mkfs.ext2 /dev/???
 +
</console>
  
See [[:Category:Ebuilds|Ebuilds]] for a list of all ebuild pages, and [[Adding an Ebuild to the Wiki]] for information on how to add one.
+
In the above and following code samples, ??? should be replaced with the target partition name. After executing this command, the target partition will contain an empty ext2 filesystem.
  
</div><div class="col-sm-12 col-xs-12 col-md-4 col-lg-4">
+
== Mount the new filesystem in /mnt ==
=== Distinctives ===
+
  
Funtoo Linux is a meta-distribution, which means it is built (fully automatically) with the functionality and optimizations that ''you'' want, not what some distro maintainer thought was best for you. Funtoo Linux packages are installed directly from source code, thanks to the [http://en.wikipedia.org/wiki/Portage_(software) Portage ports system], inspired by the FreeBSD ports system, written in Python and with full advanced package management functionality.
+
Create a directory called /mnt/newpart, and then mount the new partition there:
  
''Benefits for desktops'': leaner, optimized, faster system. ''Additional benefits for servers'': enable only what you actually need to reduce attack surface, thus improving security.
+
<console>
 +
# ##i##mount /dev/??? /mnt/newpart
 +
</console>
  
We use [http://en.wikipedia.org/wiki/Git_(software) Git] for all our development, and we also use Git to deliver our ports tree to you.
+
==  Drop to single-user mode ==
  
In contrast to Gentoo Linux, we offer a number of innovations, including our extensive use of git, [[Funtoo 1.0 Profile|our profile system]], [[Package:Boot-Update|boot-update]] boot management tool, our incredibly flexible [[Funtoo Linux Networking|template-based networking scripts]], [[Metro Quick Start Tutorial|Metro]] distribution build system, support of Debian, RHEL and other kernels, [[Creating_Python-related_Ebuilds|enhanced Python support]], Portage mini-manifests, user-centric distribution model, and a large number of community infrastructure improvements.
+
I delayed this step as long as possible to maximize system availability, but we now must drop into single-user mode, and copy files from /home to /mnt/newpart. You shouldn't have any files open in /home, and entering single-user mode eliminates this possibility:
</div></div></div>
+
  
__NOTITLE__
+
<console>
__NOEDITSECTION__
+
# ##i##init 1
{{#subobject:|slideIndex=0|slideCaption=
+
</console>
<h4> [[User:Drobbins|drobbins]] </h4>
+
  
[[GNOME First Steps|GNOME 3.12]]
+
==  Change directories to /home and copy files ==
([[Funtoo_Linux_FAQ#Do_you_support_systemd.3F|without systemd]], because that's how we roll.)
+
  
Note: Badgers optional.
+
Type the following:
|slideImage=File:gnome3122.jpg|slideLink=GNOME First Steps}}
+
{{#subobject:|slideIndex=1|slideCaption=
+
<h4>[[User:Anak1n|anak1n]] </h4>
+
  
flux box
+
<console>
|slideImage=File:fluxbox-09.02.14.jpg}}
+
# ##i##cd /home
{{#subobject:|slideIndex=2|slideCaption=
+
# ##i##cp -ax * /mnt/newpart
<h4>spectromas</h4>
+
</console>
  
[[Package:Awesome_(Window_Manager)|Awesome WM]]
+
The cp -ax command recursively copies the contents of /home to /mnt/newpart, preserving all file attributes, and not crossing any mount points. After this command finishes, /mnt/newpart will contain an exact copy of all the files and directories currently in /home. If the old /home was on its own separate partition (listed on a separate line in /etc/fstab), go to step 6a. Otherwise, proceed to step 6b.
|slideImage=File:awesome.jpg|slideLink=Package:Awesome (Window Manager)}}
+
{{#subobject:|slideIndex=3|slideCaption=
+
<h4> [[User:Anak1n|anak1n]] </h4>
+
  
KDE
+
==  Use the new partition ==
|slideImage=File:anak1n-kde.jpg}}
+
 
{{#seo:
+
=== /home on its own partition ===
|title=Funtoo Linux
+
 
|keywords=funtoo,linux,gentoo,Daniel Robbins
+
{{Note|These instructions are for systems where the old /home is already on its own dedicated partition. If this isn't the case, see the next section.}}
|description=Funtoo Linux is a Gentoo-based Linux distribution that uses Portage
+
 
}}
+
Unmount the old partition by typing:
 +
 
 +
<console>
 +
# ##i##cd /
 +
# ##i##umount /home
 +
</console>
 +
 
 +
Then, unmount and remount the new partition:
 +
 
 +
<console>
 +
# ##i##umount /mnt/newpart
 +
# ##i##mount /dev/??? /home
 +
</console>
 +
 
 +
Now, the new partition is available at /home and is ready to be used. We can perform the last few steps in multiuser mode. Exit single-user mode, so that the system is back up and running, by pressing CTRL-D.
 +
 
 +
Important: After the system starts up normally, log in as root and edit /etc/fstab so that /dev/??? is now mounted automatically at /home instead of your old partition. For example, change this line:
 +
 
 +
<pre>
 +
/dev/hda3  /home  ext2  defaults  1  2
 +
</pre>
 +
 
 +
to this line:
 +
 
 +
<pre>
 +
/dev/???  /home  ext2  defaults  1  2
 +
</pre>
 +
 
 +
=== /home on a shared partition ===
 +
 
 +
{{Note|These instructions are for systems where the old /home is on a shared partition.}}
 +
 
 +
<console>
 +
# ##i##cd /
 +
# ##i##mv /home /home.old
 +
# ##i##mkdir /home
 +
# ##i##mount /dev/??? /home
 +
</console>
 +
 
 +
Now, leave single user mode by pressing CTRL-D. When the system is back up and running, edit /etc/fstab and add a line like the following:
 +
 
 +
<pre>
 +
/dev/???  /home  ext2  defaults  1  2
 +
</pre>
 +
 
 +
That way, your new partition will get mounted correctly the next time the system is rebooted.
 +
 
 +
==  Finishing up ==
 +
 
 +
We deliberately left the old /home directory/partition behind, just in case there were problems copying files. After verifying that the system is running smoothly, you can either use your old /home partition for something else, or remove the /home.old directory.
 +
 
 +
Congratulations, you've just moved /home! In my next tip, we'll reconfigure a system so that /tmp and /var are on their own shared partition. See you then.
 +
{{ArticleFooter}}

Revision as of 20:26, January 1, 2015

Moving /home

In this new series of tips, Daniel Robbins shows you how to change partition layout on a running system. He'll also cover several tricks of the trade to minimize downtime and avoid making costly mistakes. In this particular tip, he'll show you how to move /home to another partition.


Next in series: Partitioning in Action, Part 2

Support Funtoo and help us grow! Donate $15 per month and get a free SSD-based Funtoo Virtual Container.

Introduction

The partition /home is one of the most-often-moved partitions. Sometimes, all the space in /home becomes exhausted, and an additional hard drive is required. Other times, /home is set up as part of the root partition, and it may need to be moved to improve performance or facilitate backup. Whatever the case, I'll show you how to move /home safely and efficiently.

Warning

The following technique describes how to move a partition(s). Although this technique is designed so that you can "back out" of a failed partition move, it doesn't protect against user error. In other words, any time that you format partitions or copy large numbers of files, there's a possibility that you will type the wrong thing, causing lots of data to be destroyed. For this reason, it's highly recommended that you take appropriate steps to back up all critical files before proceeding.

Now that you're prepared, we're ready to start moving /home. The exact steps you will take depend on whether /home currently resides on its own separate partition, or whether it is located on the root partition. Keep this in mind as we go through the steps (I'll make notes where necessary). Right now, if you are moving /home to a new hard drive, it should be physically installed in your system.

If you are moving /home to an existing partition (it doesn't need to be ext2, as long as the target primary or extended partition exists), skip this step.

Create a new partition, if necessary

If the new partition doesn't exist yet, you'll need to create it using cfdisk (preferred) or fdisk. If the partition doesn't reside on your first drive, remember to specify the name of the device as the first argument to cfdisk or fdisk. After creating the appropriate primary or extended partition, you should reboot so that the partition table can be reread correctly. This is the only time you will need to reboot the system.

Create a filesystem on the new partition

To create a filesystem on the new partition, first make sure you know the exact device name for the new partition (for example, /dev/sda5). If you're not sure of the exact device name, stop now and double-check! Then type the following, as root:

# mkfs.ext2 /dev/???

In the above and following code samples, ??? should be replaced with the target partition name. After executing this command, the target partition will contain an empty ext2 filesystem.

Mount the new filesystem in /mnt

Create a directory called /mnt/newpart, and then mount the new partition there:

# mount /dev/??? /mnt/newpart

Drop to single-user mode

I delayed this step as long as possible to maximize system availability, but we now must drop into single-user mode, and copy files from /home to /mnt/newpart. You shouldn't have any files open in /home, and entering single-user mode eliminates this possibility:

# init 1

Change directories to /home and copy files

Type the following:

# cd /home
# cp -ax * /mnt/newpart

The cp -ax command recursively copies the contents of /home to /mnt/newpart, preserving all file attributes, and not crossing any mount points. After this command finishes, /mnt/newpart will contain an exact copy of all the files and directories currently in /home. If the old /home was on its own separate partition (listed on a separate line in /etc/fstab), go to step 6a. Otherwise, proceed to step 6b.

Use the new partition

/home on its own partition

Note

These instructions are for systems where the old /home is already on its own dedicated partition. If this isn't the case, see the next section.

Unmount the old partition by typing:

# cd /
# umount /home

Then, unmount and remount the new partition:

# umount /mnt/newpart
# mount /dev/??? /home

Now, the new partition is available at /home and is ready to be used. We can perform the last few steps in multiuser mode. Exit single-user mode, so that the system is back up and running, by pressing CTRL-D.

Important: After the system starts up normally, log in as root and edit /etc/fstab so that /dev/??? is now mounted automatically at /home instead of your old partition. For example, change this line:

/dev/hda3   /home   ext2   defaults   1   2

to this line:

/dev/???   /home   ext2   defaults   1   2

/home on a shared partition

Note

These instructions are for systems where the old /home is on a shared partition.

# cd /
# mv /home /home.old
# mkdir /home
# mount /dev/??? /home

Now, leave single user mode by pressing CTRL-D. When the system is back up and running, edit /etc/fstab and add a line like the following:

/dev/???   /home   ext2   defaults   1   2

That way, your new partition will get mounted correctly the next time the system is rebooted.

Finishing up

We deliberately left the old /home directory/partition behind, just in case there were problems copying files. After verifying that the system is running smoothly, you can either use your old /home partition for something else, or remove the /home.old directory.

Congratulations, you've just moved /home! In my next tip, we'll reconfigure a system so that /tmp and /var are on their own shared partition. See you then.

Next >>>

Read the next article in this series: Partitioning in Action, Part 2

Support Funtoo and help us grow! Donate $15 per month and get a free SSD-based Funtoo Virtual Container.

About the Author

Daniel Robbins is best known as the creator of Gentoo Linux and author of many IBM developerWorks articles about Linux. Daniel currently serves as Benevolent Dictator for Life (BDFL) of Funtoo Linux. Funtoo Linux is a Gentoo-based distribution and continuation of Daniel's original Gentoo vision.

Got Funtoo?

Have you installed Funtoo Linux yet? Discover the power of a from-source meta-distribution optimized for your hardware! See our installation instructions and browse our CPU-optimized builds.

Funtoo News

Drobbins

RSS/Atom Support

You can now follow this news feed at http://www.funtoo.org/news/atom.xml .
10 February 2015 by Drobbins
Drobbins

Creating a Friendly Funtoo Culture

This news item details some recent steps that have been taken to help ensure that Funtoo is a friendly and welcoming place for our users.
2 February 2015 by Drobbins
Mgorny

CPU FLAGS X86

CPU_FLAGS_X86 are being introduced to group together USE flags managing CPU instruction sets.
31 January 2015 by Mgorny
View More News...

More Articles

Browse all our Linux-related articles, below:

A

B

F

G

K

L

M

O

P

S

T

W

X

Z