3

Context

I recently migrated Windows 10 and Gentoo to 2 separate 250 GB SSD's and left my old traditional SATA HDD Drives in to use for Storage.

  1. I put Users on a HDD for Windows during a new install.
  2. I used a GParted LiveCD to shrink my root file system, and copied it to the new drive, rebooted, and then deleted the old root I'm leaving /home and a swap partition on my HDD Drive. This all works great, as I'm booting using the UUID's.

Since I'm on Gentoo, I need to move just the /usr directory from the SSD back to the original HDD I copied it from, so that the Portage Tree doesn't hog the small SSD space during updates. I'm not tagging this with gentoo until now(See Update Heading), because this question is related to the proper command options needed for rsync For a bit of context, the portage tree is Gentoo's package repository. The entire repository is downloaded to the user's local machine before updating. Downloading it to the SSD would cause needless wear, as the tree is updated daily.

Issue

I found the following two questions related to what I'm trying to accomplish:

  1. ServerFault: Mount /usr on different partition
  2. AskUbuntu: How to move /usr to a new partition?

Now I need an answer to a few of my own questions:

  1. Can I use the rsync command to move /usr while in the Gentoo install where /usr needs to be moved? The ServerFault question hints at this.
  2. If #1 isn't possible, and I use the GParted Live USB to issue the rsync command, do the file/directory owners change since the LiveUSB is based on a Debian distribution?
  3. What are the proper options for rsync besides -a for archive? The comments in the selected answer at AskUbuntu hint at adding -H to ensure hardlinks are followed, but then the OP contradicts the comments in his own answer.

Visual Aids

I need to move the /usr directory from the partition squared in red to the empty partition squared in blue, while the entire partition squared in red is running, or use a LiveCD to do so, without harming or changing the current permissions.

/usr is in this partition Empty Partition

Update

This question turned out to be a mountain that can be conquered, but I don't know if I conquer it:

  1. I am/was able to move /usr to a new partition using rsync -avAHPX /mnt/gentoo/usr /mnt/new_usr. I can't give credit for a partial answer as I'm still stuck.
  2. It does no good, as systemd complains that the root filesystem doesn't contain a valid init because the init system is in the partition that can't be mounted. Do you see the issue here? (Systemd is located in /usr/lib/systemd)
  3. I need early userspace mounting in order to fix the issue, but in order to do that, I'd lose my Plymouth boot screen initramfs with the initramfs it takes to mount /usr early. See also Custom Initramfs and Initramfs/Guide.
  4. Support and or other Gentoo users not complaining that "Systemd Sucks" are hard to come by (which is one of the reasons, I started contributing here). As such, if I post a question in our official resources, I get booed.

If anyone can tell me the proper tools to use that combine both a plymouth bootsplash and early /usr mounting in the initramfs/intramfd, I'd appreciate it, and I'm thinking about offering a bounty, if this question sits. Also know that since Gentoo is source based that even though I linked the Gentoo Wiki articles, that I can use the tools from other distributions.

18
  • I don't exactly understand the first part. Are you asking if you should copy /usr into a running system? If so, then no, much safer to use a live USB. I presume GParted has rsync, but if you are worried, then just use the Gentoo live USB instead. I'd use -aP at a minimum. I'm not sure if there'd be any hardlinks on /usr, but no harm doing -H if there isn't. (By the same token, you could use -AX too.)
    – Sparhawk
    Commented Sep 28, 2018 at 2:45
  • Was working on answering another question when your comment came up. I know I can issue a man rsync to read the options you posted, but do you mind explaining the reasons I should add -X or -P? And to clarify, I need to copy the /usr folder from a running system into some free space. I'll post a screen capture of GParted.
    – eyoung100
    Commented Sep 28, 2018 at 3:32
  • @Sparhawk I added screenshots if that helps.
    – eyoung100
    Commented Sep 28, 2018 at 3:59
  • 1
    Copying /usr on a live system shouldn't be a problem, /usr is (or was, originally) designed to be able to be mounted read-only, and shared between multiple systems, as its contents should only change when upgrades are done. -P is shorthand for --partial --progress which doesn't affect the final result of the rsync transffer. -X preserves extended attributes if you use those.
    – wurtel
    Commented Sep 28, 2018 at 6:37
  • Simple can suggest rsync -a --progress /usr/ /path/to/usr/ (don't forget trailing slashes otherwise you could end with folder being copied to /path/to/usr/usr Commented Nov 6, 2018 at 5:54

2 Answers 2

0
+100

May I suggest an alternative method?

  • Don't try to move entire /usr/* tree since you mentioned it broke systemd and also doesn't seem to be required to resolve your issues of intensive RW and/or large amount of wasted space (you can just move /usr/portage)

  • Copy /usr/portage to a remote HDD via rsync running from LiveCD

  • Mount HDD at startup via FSTAB to somewhere like /mnt/hdd
  • Recursively delete /usr/portage
  • Symlink ln -s /mnt/hdd/gentoo/usr/portage /usr/portage

I prefer not to modify default directories (/usr/portage is default, but I believe you can modify that) unless needed and if I want them to reside on another HDD I will just symlink them. You could just make another partition for just /usr/portage and mount it directly to /usr/portage, but I prefer to do something like mount all my data in one big remote partition under /mnt/data and then symlink directories as needed. I would likely have /home reside here as well.

Perhaps two separate partition scheme like so :

/mnt/os_data
/mnt/my_data

I figure you get the gist.

2
  • this is a lot of work to save on SSD space, for my "OS's" I generally only need ~150GB for Windows and I like to have say ~30GB for Linux. I then store all personal data on a separate HDD. I would be only concerned with the intensive RW you mentioned. Commented Nov 6, 2018 at 11:21
  • I thought this would be an easier process than it turned out to be. I’ll consider this method, but I’ll wait the full 7 days in case others answer with creating the Initial Ramdisk etc.
    – eyoung100
    Commented Nov 6, 2018 at 19:26
0
  1. Can I use the rsync command to move /usr while in the Gentoo install where /usr needs to be moved? The ServerFault question hints at this.

Yes, you certainly can (copy, not move?), but I would always use a Live USB for these kinds of things. On a system in use, it's plausible that some process writes to /usr while you are copying it, which could potentially result in an incomplete transfer.

  1. If #1 isn't possible, and I use the GParted Live USB to issue the rsync command, do the file/directory owners change since the LiveUSB is based on a Debian distribution?

No, as long as you are using -a, permissions should be preserved for a local copy.

  1. What are the proper options for rsync besides -a for archive? The comments in the selected answer at AskUbuntu hint at adding -H to ensure hardlinks are followed, but then the OP contradicts the comments in his own answer.

As discussed in the comments, if you look for -a in man rsync, it excludes -H, -A, and -X. These flags preserve hard links, ACLs, and extended attributes. I strongly doubt that /usr contains any of these, but there is no harm in using the flags, just in case. If the source doesn't use them, then there is nothing to preserve, so rsync would function just as if you had not used the flags. I also tend to use -P, which allows you to continue aborted transfers, and also shows you the progress as you are copying.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .