SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2013-12-20 07:14:11

superwow
#! Member
From: rlyeh
Registered: 2013-08-23
Posts: 58

[SOLVED] Best method to change home directory?

Today I borked my computer and had to reinstall #! (was intending to reinstall MSW and sell this computer). My laptop has a 500 gb HDD (sda) and a 32 gb SSD (sdb). My previous install had home, boot, and swap on the 500 gb drive. This means all of my files are there (and it is where I want them to stay). On the reinstall, I wanted #! on the 32 gb drive, AND to leave my files where they are, on the 500 gb directory, which I also want as my home directory.

After all the install scripts have finished running, I realize I have chosen poorly. Thunar shows me that my home is now in the 32 gb directory. And Gparted shows me that boot is on the 500 gb directory. Razzlefrazzle dagnabbit. I searched and have found a few different methods to change my home directory to the different drive. Can anyone provide experienced advice as to which of the following is better?

1. usermod (this feels to me like the most straightforward way)

usermod -d /home/your_home_directory USERNAME
chown -R USERNAME /new_location/your_home_directory

2. modify fstab (if I do this, how should I comment the old home?)

sudo cp /etc/fstab /etc/fstab.bak
gksu geany /etc/fstab

and add a line to place my home directory there like so:

#/dev/sda1   
UUID=<UUID of sda1> /home               ext4    errors=remount-ro 0       1

3. mkdir / mount / umount combo (seems overly complex compared to usermod)

mkdir /mnt/newhome
mount /dev/sdb1 /mnt/newhome
cp -a /home/* /mnt/newhome/

log out as your user and switch to a terminal (Ctrl + Alt + F1 or similar)

mv /home /home.old
umount /mnt/newhome
mkdir /home
mount /dev/sdb1 /home

4. make a symlink (my intuition is not to do this though)

cp -R /home/whatever /path/to/destination
mv /home/whatever /home/whatever.orig
ln -s /path/to/destionation /home/whatever 
rm -rf /home/whatever.orig 

Thanks to everyone for reading and anyone for advice.

Last edited by superwow (2013-12-24 22:00:29)

Offline

Help fund CrunchBang, donate to the project!

#2 2013-12-20 08:04:09

ohnonot
#! Die Hard
Registered: 2012-05-22
Posts: 558

Re: [SOLVED] Best method to change home directory?

you have provided a lot of possible solutions, but haven't described the state of your hard disks properly.
how are they partitioned right now, what is installed where, and what exactly are you trying to achieve (without already suggesting solutions)?

Offline

#3 2013-12-20 08:26:25

superwow
#! Member
From: rlyeh
Registered: 2013-08-23
Posts: 58

Re: [SOLVED] Best method to change home directory?

@ohnonot sorry about that. Output from CLI

fdisk -l

gives

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   960397311   480197632   83  Linux
/dev/sda2       960399358   976771071     8185857    5  Extended
Partition 2 does not start on physical sector boundary.
/dev/sda5       960399360   976771071     8185856   82  Linux swap / Solaris

Disk /dev/sdb: 32.0 GB, 32017047552 bytes
255 heads, 63 sectors/track, 3892 cylinders, total 62533296 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000544ab

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    59895807    29946880   83  Linux
/dev/sdb2        59897854    62531583     1316865    5  Extended
/dev/sdb5        59897856    62531583     1316864   82  Linux swap / Solaris

I want #! and boot on 32 gb drive, and home directory on the 500 gb drive (which contains all my files from the previous install).

Does that help?

Offline

#4 2013-12-20 15:03:17

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 2,161

Re: [SOLVED] Best method to change home directory?

symlink for me smile My setup is install to one partition, and symlink the directories in /home to ones in a separate data partition. eg /Documents -> /media/data/documents. Then you can share your data with a different distro, and it makes reinstalling easy.


Artwork at deviantArt;  Iceweasel Personas;  SLiM #! Themes;  Openbox themes

Offline

#5 2013-12-20 17:07:59

ratcheer
#! CrunchBanger
Registered: 2013-07-23
Posts: 162

Re: [SOLVED] Best method to change home directory?

I always tar the home directory, rename it to /oldhome, create the new home the way I want it, and extract the tar file back into the new home directory. If everything succeeds, I delete the oldhome or keep it as a backup.

Tim

Offline

#6 2013-12-20 19:09:15

superwow
#! Member
From: rlyeh
Registered: 2013-08-23
Posts: 58

Re: [SOLVED] Best method to change home directory?

@damo thanks for the suggestion. A few questions for you:
1. Once the symlink is made, do both graphical and CLI programs both follow the link? I am wondering what will happen when I log in after symlinking and there are config files in both folders.
2. Are you symlinking your username folder? (I mean, /damo?) or symlinking each of the folders inside /damo? (documents, .config, etc)?
3. Is this better than modifying fstab? or the usermod option?

@ratcheer, thanks. How do you create the home? by writing to fstab or using symlinks or some other method?

It seems like with each of the above methods people on other forums have problems. I guess I am looking for the most error free version. Sorry for all the questions but thanks for the advice.

Last edited by superwow (2013-12-20 19:09:50)

Offline

#7 2013-12-20 19:20:39

ratcheer
#! CrunchBanger
Registered: 2013-07-23
Posts: 162

Re: [SOLVED] Best method to change home directory?

"How do you create the home...?"

Ummm, however you want to. But, I assume you are doing this to get it to a new partition instead of being part of the root partition. So, first you would use a partition editor (there are many) to add a new Linux partition to your disk drive. This assumes that you have some unpartitioned space remaining. If not, that is "a whole 'nother" exercise.

Next, you would create a filesystem on the new partition, normally using the mkfs program. Forgive me, but I do most of these kinds of things from the CLI. The next step would be to mount the new filesystem (and add a new entry for it to /etc/fstab). Then mkdir /home on the new filesystem (assuming your old home directory has been renamed). Finally, extract your tarfile to the new /home. Ensure that all the subdirectories went to their proper level in the subdirectories hierarchy. If everything looks, good, reboot.

Tim

Offline

#8 2013-12-20 19:34:05

superwow
#! Member
From: rlyeh
Registered: 2013-08-23
Posts: 58

Re: [SOLVED] Best method to change home directory?

@Ratcheer, I just want home to be on the larger drive and don't want to overwrite the files I already have on that larger drive. It used to be my home drive on a previous (#!) install. I believe I must have misread the partitioning step instructions on this new install; I thought at the time I was choosing the options which would place the OS on the small sdd and home on the larger hdd.

I may wind up editing the fstab as you suggested (mkfs / mkdir / mount). Also, I appreciate CLI advice (better than GUI usually imo).

Offline

#9 2013-12-20 19:40:20

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 2,161

Re: [SOLVED] Best method to change home directory?

If starting from scratch, my process is..

1: Partition - eg #! on /dev/sda1; data on /dev/sda2

2: Remove the directories in /home I want to have on data, and replace with symlinks eg

mkdir /media/data
mount /dev/sda2 /media/data
mkdir /media/data/documents   (I hate it when dirs have uppercase!)
rm ~/Documents
ln -s /media/data/documents documents

repeat as necessary

In thunar the folder icons will now have an arrow to show they are links

3: I leave the dotfiles alone, and anything particular for that distro. So after installing something else, or reinstalling #!, I just repeat the above and never have to worry about exporting/importing my /home files. Any distros I have can all link to the same docs/images/music etc

It sounds a pain but it only needs doing once, and you could script it easily enough. GUI/cli access is no different - the symlinks act the same as all the others on your system. Symlinking /home/user would defeat the whole object of keeping distro-specific files apart, so just link the data directories you want to share.

An added bonus is that the / partition can be quite small, especially if you link eg /tmp to somewhere else. I've used this system for several years now, and find it the easiest and safest way. But as they say - YMMV smile


Artwork at deviantArt;  Iceweasel Personas;  SLiM #! Themes;  Openbox themes

Offline

#10 2013-12-20 22:20:01

ohnonot
#! Die Hard
Registered: 2012-05-22
Posts: 558

Re: [SOLVED] Best method to change home directory?

i have not read all of the ongoing conversation.
going back to posts 1 - 3.

Thunar shows me that my home is now in the 32 gb directory. And Gparted shows me that boot is on the 500 gb directory. Razzlefrazzle dagnabbit.

this sounds really weird.
and this looks really weird:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   960397311   480197632   83  Linux
/dev/sda2       960399358   976771071     8185857    5  Extended
Partition 2 does not start on physical sector boundary.
/dev/sda5       960399360   976771071     8185856   82  Linux swap / Solaris
...
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    59895807    29946880   83  Linux
/dev/sdb2        59897854    62531583     1316865    5  Extended
/dev/sdb5        59897856    62531583     1316864   82  Linux swap / Solaris

it seems you have been using extended partitions the wrong way.
i suggest you inform yourself what primary, extended and logical partitions are,
then start the installation from scratch and install the whole operating system to one partition.
everything else you can do afterwards, the whole home directory stuff.

but it looks like you're going to have to do some repairing first.
can you post fdisk -l again, marking out which partition/hd contains the data you don't want to lose, and where you want to install the system?

Offline

#11 2013-12-21 01:17:54

superwow
#! Member
From: rlyeh
Registered: 2013-08-23
Posts: 58

Re: [SOLVED] Best method to change home directory?

Here is the IO of:

sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   960397311   480197632   83  Linux
/dev/sda2       960399358   976771071     8185857    5  Extended
Partition 2 does not start on physical sector boundary.
/dev/sda5       960399360   976771071     8185856   82  Linux swap / Solaris

Disk /dev/sdb: 32.0 GB, 32017047552 bytes
255 heads, 63 sectors/track, 3892 cylinders, total 62533296 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000544ab

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    59895807    29946880   83  Linux
/dev/sdb2        59897854    62531583     1316865    5  Extended
/dev/sdb5        59897856    62531583     1316864   82  Linux swap / Solaris

@ohnonot, both drives have seen multiple installs, which is why they look 'weird', that and I believe because I must have chosen poorly on install.

But your comment harkens to my own personal suspicions that I will have to format both drives and reinstall, as there are a few other issues with the system now. So on to that now, and then will try @damo's symlink suggestion I think.

Offline

#12 2013-12-23 08:29:41

superwow
#! Member
From: rlyeh
Registered: 2013-08-23
Posts: 58

Re: [SOLVED] Best method to change home directory?

@damo, thanks for the detailed description. It looks like lots of folks use and prefer the symlink method. I am still curious about what would make one method better or more/less efficient/preferred. @Ratcheer & @ohnonot, thanks for your help also.

I finally had a few hours between holiday events to format the drive and reinstall, this time preemptively partitioning the larger drive with gparted before reinstalling. I chose the guided encrypted LVN option. I have not had this type of setup on this particular laptop before but did have LVM on a previous single drive netbook, so it seemed a decent option. In the install process, I got messages from LVM regarding preparing each of the two drives (32 & 500 gb). I mention this because it may affect things.

I installed / and home to the 32 gb drive. Boot still appears on the 500 gb drive, yet the drive itself, which shows in Thunar but Thunar cannot perform operations on it, I have to use sudo in order to get into it and do stuff, and in fstab the drive appears not to be LV mapped. Here are relevant outputs again.

superwow@rlyeh:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/rlyeh-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sdb1 during installation
UUID=bd83b222-421a-4303-9eea-e09f9f8babd0 /boot           ext2    defaults        0       2
/dev/mapper/rlyeh-home /home           ext4    defaults        0       2
/dev/mapper/rlyeh-swap_1 none            swap    sw              0       0
#/dev/sdc1       /media/usb0     auto    rw,user,noauto  0       0
superwow@rlyeh:~$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00032414

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   976771071   488384512   83  Linux

Disk /dev/sdb: 32.0 GB, 32017047552 bytes
255 heads, 63 sectors/track, 3892 cylinders, total 62533296 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00087d03

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      499711      248832   83  Linux
/dev/sdb2          501758    62531583    31014913    5  Extended
/dev/sdb5          501760    62531583    31014912   83  Linux

Disk /dev/mapper/sdb5_crypt: 31.8 GB, 31757172736 bytes
255 heads, 63 sectors/track, 3860 cylinders, total 62025728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/sdb5_crypt doesn't contain a valid partition table

Disk /dev/mapper/rlyeh-root: 8019 MB, 8019509248 bytes
255 heads, 63 sectors/track, 974 cylinders, total 15663104 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/rlyeh-root doesn't contain a valid partition table

Disk /dev/mapper/rlyeh-swap_1: 1023 MB, 1023410176 bytes
255 heads, 63 sectors/track, 124 cylinders, total 1998848 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/rlyeh-swap_1 doesn't contain a valid partition table

Disk /dev/mapper/rlyeh-home: 22.7 GB, 22712156160 bytes
255 heads, 63 sectors/track, 2761 cylinders, total 44359680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/rlyeh-home doesn't contain a valid partition table
superwow@rlyeh:~$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/rlyeh/root
  LV Name                root
  VG Name                rlyeh
  LV UUID                me3SCW-6OTd-DMGW-pFJe-rNBL-ukZe-BY2hVf
  LV Write Access        read/write
  LV Creation host, time rlyeh, 2013-12-22 18:14:33 -0800
  LV Status              available
  # open                 1
  LV Size                7.47 GiB
  Current LE             1912
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1
   
  --- Logical volume ---
  LV Path                /dev/rlyeh/swap_1
  LV Name                swap_1
  VG Name                rlyeh
  LV UUID                sU53FD-ddOf-QUY3-Mnzv-qcMq-McFZ-tXdTKo
  LV Write Access        read/write
  LV Creation host, time rlyeh, 2013-12-22 18:14:33 -0800
  LV Status              available
  # open                 2
  LV Size                976.00 MiB
  Current LE             244
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:2
   
  --- Logical volume ---
  LV Path                /dev/rlyeh/home
  LV Name                home
  VG Name                rlyeh
  LV UUID                pmbYvs-7mM2-oeHr-aPRf-1VFP-1hH0-2qLlJm
  LV Write Access        read/write
  LV Creation host, time rlyeh, 2013-12-22 18:14:33 -0800
  LV Status              available
  # open                 1
  LV Size                21.15 GiB
  Current LE             5415
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:3

superwow@rlyeh:~$ blkid
/dev/sda1: UUID="a2fe459a-6b3f-4eb5-ae75-018cf6b97344" TYPE="ext4" 
/dev/sdb5: UUID="6c235dd5-c07b-4efa-9717-bfb2ac87e6d8" TYPE="crypto_LUKS" 

The 500 gb drive is shown in fstab, fdisk shows it as well though not as LVM mapped (despite LVM formatting it in the install process), and lvdisplay does not see it.

Questions:
1. Could a previously installed MBR (for MSW) be causing this?

2. Or do I just need to manually remove the boot item from dev/sda1 in fstab, try remapping with LVN, and manually adding a mountpoint? If so, why wasn't LVM able to do all this during install?

Currently reading through @El_Koraco's Monumental LVM guide (a great set of guides btw) to figure out why the drive is not LV mapped. But again, any help is welcome - and thanks.

Last edited by superwow (2013-12-23 08:44:51)

Offline

#13 2013-12-23 10:54:06

ohnonot
#! Die Hard
Registered: 2012-05-22
Posts: 558

Re: [SOLVED] Best method to change home directory?

superwow wrote:

I am still curious about what would make one method better or more/less efficient/preferred.

you mean creating symlinks, as opposed to mounting a previously used /home partition?
imo, the partition method (TPM) maybe useful for certain scenarios (server? no gui?) but for a normal desktop user it creates more trouble than convenience, especially if you are also switching desktop environments or even distros. it's too much to list in detail. also you are very likely to drag useless ballast with you (configs and caches of apps no longer used...).
the symlink method (TSM) allows you to keep the kind of data that is not affected by software changes (media files mostly - they also take the most space) across setups.

with your encryption problems i cannot help.
it might be advisable to start a new thread for that.

Last edited by ohnonot (2013-12-23 10:54:49)

Offline

#14 2013-12-23 14:08:32

ratcheer
#! CrunchBanger
Registered: 2013-07-23
Posts: 162

Re: [SOLVED] Best method to change home directory?

superwow wrote:

@Ratcheer, I just want home to be on the larger drive and don't want to overwrite the files I already have on that larger drive. It used to be my home drive on a previous (#!) install. I believe I must have misread the partitioning step instructions on this new install; I thought at the time I was choosing the options which would place the OS on the small sdd and home on the larger hdd.

I may wind up editing the fstab as you suggested (mkfs / mkdir / mount). Also, I appreciate CLI advice (better than GUI usually imo).

The procedures are the same. Just make a new partition on the other hard drive and go from there.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo